-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use deterministic names for httpproxies (#11)
* use deterministic names for httpproxies * add helm chart * update README
- Loading branch information
1 parent
d7327ea
commit fd5d587
Showing
21 changed files
with
575 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Release Helm Chart | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
release: | ||
name: release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Configure Git | ||
run: | | ||
git config user.name "$GITHUB_ACTOR" | ||
git config user.email "[email protected]" | ||
- name: Install Helm | ||
uses: azure/setup-helm@v3 | ||
|
||
- name: Run chart-releaser | ||
uses: helm/[email protected] | ||
env: | ||
CR_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
charts_dir: deploy/charts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,3 +164,14 @@ tidy: | |
.PHONY: vendor | ||
vendor: tidy | ||
go mod vendor | ||
|
||
######################### Helmify | ||
HELMIFY ?= $(LOCALBIN)/helmify | ||
|
||
.PHONY: helmify | ||
helmify: $(HELMIFY) ## Download helmify locally if necessary. | ||
$(HELMIFY): $(LOCALBIN) | ||
test -s $(LOCALBIN)/helmify || GOBIN=$(LOCALBIN) go install github.com/arttor/helmify/cmd/[email protected] | ||
|
||
helm: manifests kustomize helmify | ||
$(KUSTOMIZE) build config/default | $(HELMIFY) deploy/charts/route-to-contour-httpproxy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,9 @@ | ||
# Work In Progress... | ||
|
||
# route-to-contour-httpproxy | ||
|
||
A Kubernetes controller for converting Openshift HAProxy Route to Contour HTTPProxy | ||
|
||
## Description | ||
|
||
Currently, the project consists of a single controller which watches `route` and `httpproxy` resources. | ||
The controller tries to create/update an `httpproxy` that matches the corresponding `route` in functionalities, e.g. tls | ||
The controller tries to create/update an `httpproxy` that matches the corresponding `route(s)` in functionalities, e.g. tls | ||
termination, port mapping, etc. | ||
|
||
## Getting Started | ||
|
||
You’ll need a Kubernetes cluster to run against. You can use [KIND](https://sigs.k8s.io/kind) to get a local cluster for | ||
testing, or run against a remote cluster. | ||
**Note:** Your controller will automatically use the current context in your kubeconfig file (i.e. whatever | ||
cluster `kubectl cluster-info` shows). | ||
|
||
### Running on the cluster | ||
|
||
1. Build and push your image to the location specified by `IMG`: | ||
|
||
```sh | ||
make docker-build docker-push IMG=<some-registry>/route-to-contour-httpproxy:tag | ||
``` | ||
|
||
2. Deploy the controller to the cluster with the image specified by `IMG`: | ||
|
||
```sh | ||
make deploy IMG=<some-registry>/route-to-contour-httpproxy:tag | ||
``` | ||
|
||
### Undeploy controller | ||
|
||
UnDeploy the controller from the cluster: | ||
|
||
```sh | ||
make undeploy | ||
``` | ||
|
||
## Contributing | ||
|
||
### How it works | ||
|
||
This project aims to follow the | ||
Kubernetes [Operator pattern](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/). | ||
|
||
It uses [Controllers](https://kubernetes.io/docs/concepts/architecture/controller/), | ||
which provide a reconcile function responsible for synchronizing resources until the desired state is reached on the | ||
cluster. | ||
|
||
### Running Tests | ||
|
||
1. Make sure the sample config exists first. | ||
|
||
```shell | ||
ls -l hack/config.yaml | ||
``` | ||
|
||
2. Run the tests defined inside Makefile. These tests run on envtest, so you don't need to connect to a working cluster. | ||
```shell | ||
make test | ||
``` | ||
### Test It Out | ||
1. Run the controller (this will run in the foreground, so switch to a new terminal if you want to leave it running): | ||
```sh | ||
make run | ||
``` | ||
**NOTE:** Run `make --help` for more information on all potential `make` targets | ||
More information can be found via the [Kubebuilder Documentation](https://book.kubebuilder.io/introduction.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: v2 | ||
name: route-to-contour-httpproxy | ||
description: A Helm chart for Kubernetes | ||
# A chart can be either an 'application' or a 'library' chart. | ||
# | ||
# Application charts are a collection of templates that can be packaged into versioned archives | ||
# to be deployed. | ||
# | ||
# Library charts provide useful utilities or functions for the chart developer. They're included as | ||
# a dependency of application charts to inject those utilities and functions into the rendering | ||
# pipeline. Library charts do not define any templates and therefore cannot be deployed. | ||
type: application | ||
# This is the chart version. This version number should be incremented each time you make changes | ||
# to the chart and its templates, including the app version. | ||
# Versions are expected to follow Semantic Versioning (https://semver.org/) | ||
version: 0.1.0 | ||
# This is the version number of the application being deployed. This version number should be | ||
# incremented each time you make changes to the application. Versions are not expected to | ||
# follow Semantic Versioning. They should reflect the version the application is using. | ||
# It is recommended to use it with quotes. | ||
appVersion: "0.1.0" |
62 changes: 62 additions & 0 deletions
62
deploy/charts/route-to-contour-httpproxy/templates/_helpers.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "route-to-contour-httpproxy.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "route-to-contour-httpproxy.fullname" -}} | ||
{{- if .Values.fullnameOverride }} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- $name := default .Chart.Name .Values.nameOverride }} | ||
{{- if contains $name .Release.Name }} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "route-to-contour-httpproxy.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "route-to-contour-httpproxy.labels" -}} | ||
helm.sh/chart: {{ include "route-to-contour-httpproxy.chart" . }} | ||
{{ include "route-to-contour-httpproxy.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "route-to-contour-httpproxy.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "route-to-contour-httpproxy.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "route-to-contour-httpproxy.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create }} | ||
{{- default (include "route-to-contour-httpproxy.fullname" .) .Values.serviceAccount.name }} | ||
{{- else }} | ||
{{- default "default" .Values.serviceAccount.name }} | ||
{{- end }} | ||
{{- end }} |
9 changes: 9 additions & 0 deletions
9
deploy/charts/route-to-contour-httpproxy/templates/controller-manager-config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ include "route-to-contour-httpproxy.fullname" . }}-controller-manager-config | ||
labels: | ||
{{- include "route-to-contour-httpproxy.labels" . | nindent 4 }} | ||
data: | ||
config.yaml: {{ .Values.controllerManagerConfig.configYaml | toYaml | indent 1 | ||
}} |
60 changes: 60 additions & 0 deletions
60
deploy/charts/route-to-contour-httpproxy/templates/deployment.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ include "route-to-contour-httpproxy.fullname" . }}-controller-manager | ||
labels: | ||
app.kubernetes.io/component: manager | ||
app.kubernetes.io/created-by: route-to-contour-httpproxy | ||
app.kubernetes.io/part-of: route-to-contour-httpproxy | ||
control-plane: controller-manager | ||
{{- include "route-to-contour-httpproxy.labels" . | nindent 4 }} | ||
spec: | ||
replicas: {{ .Values.controllerManager.replicas }} | ||
selector: | ||
matchLabels: | ||
control-plane: controller-manager | ||
{{- include "route-to-contour-httpproxy.selectorLabels" . | nindent 6 }} | ||
template: | ||
metadata: | ||
labels: | ||
control-plane: controller-manager | ||
{{- include "route-to-contour-httpproxy.selectorLabels" . | nindent 8 }} | ||
annotations: | ||
kubectl.kubernetes.io/default-container: manager | ||
spec: | ||
containers: | ||
- args: {{- toYaml .Values.controllerManager.manager.args | nindent 8 }} | ||
command: | ||
- /manager | ||
env: | ||
- name: KUBERNETES_CLUSTER_DOMAIN | ||
value: {{ quote .Values.kubernetesClusterDomain }} | ||
image: {{ .Values.controllerManager.manager.image.repository }}:{{ .Values.controllerManager.manager.image.tag | ||
| default .Chart.AppVersion }} | ||
livenessProbe: | ||
httpGet: | ||
path: /healthz | ||
port: 8081 | ||
initialDelaySeconds: 15 | ||
periodSeconds: 20 | ||
name: manager | ||
readinessProbe: | ||
httpGet: | ||
path: /readyz | ||
port: 8081 | ||
initialDelaySeconds: 5 | ||
periodSeconds: 10 | ||
resources: {{- toYaml .Values.controllerManager.manager.resources | nindent 10 | ||
}} | ||
volumeMounts: | ||
- mountPath: /route-to-contour-httpproxy/config/ | ||
name: config-volume | ||
serviceAccountName: {{ include "route-to-contour-httpproxy.fullname" . }}-controller-manager | ||
terminationGracePeriodSeconds: 10 | ||
volumes: | ||
- configMap: | ||
items: | ||
- key: config.yaml | ||
path: config.yaml | ||
name: {{ include "route-to-contour-httpproxy.fullname" . }}-controller-manager-config | ||
name: config-volume |
59 changes: 59 additions & 0 deletions
59
deploy/charts/route-to-contour-httpproxy/templates/leader-election-rbac.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: {{ include "route-to-contour-httpproxy.fullname" . }}-leader-election-role | ||
labels: | ||
app.kubernetes.io/component: rbac | ||
app.kubernetes.io/created-by: route-to-contour-httpproxy | ||
app.kubernetes.io/part-of: route-to-contour-httpproxy | ||
{{- include "route-to-contour-httpproxy.labels" . | nindent 4 }} | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- configmaps | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- create | ||
- update | ||
- patch | ||
- delete | ||
- apiGroups: | ||
- coordination.k8s.io | ||
resources: | ||
- leases | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- create | ||
- update | ||
- patch | ||
- delete | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- events | ||
verbs: | ||
- create | ||
- patch | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: {{ include "route-to-contour-httpproxy.fullname" . }}-leader-election-rolebinding | ||
labels: | ||
app.kubernetes.io/component: rbac | ||
app.kubernetes.io/created-by: route-to-contour-httpproxy | ||
app.kubernetes.io/part-of: route-to-contour-httpproxy | ||
{{- include "route-to-contour-httpproxy.labels" . | nindent 4 }} | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: '{{ include "route-to-contour-httpproxy.fullname" . }}-leader-election-role' | ||
subjects: | ||
- kind: ServiceAccount | ||
name: '{{ include "route-to-contour-httpproxy.fullname" . }}-controller-manager' | ||
namespace: '{{ .Release.Namespace }}' |
Oops, something went wrong.