diff --git a/.gitignore b/.gitignore index eea54c3..f389ff1 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ charts [._]s[a-rt-v][a-z] [._]ss[a-gi-z] [._]sw[a-p] + +__snapshot__ \ No newline at end of file diff --git a/.helmignore b/.helmignore index 8904c0d..e09cb82 100644 --- a/.helmignore +++ b/.helmignore @@ -20,3 +20,5 @@ .idea/ *.tmprojt tests/ + +__snapshot__/ \ No newline at end of file diff --git a/README.md b/README.md index 9527adf..caad2ec 100644 --- a/README.md +++ b/README.md @@ -198,6 +198,11 @@ The following table lists the configurable parameters of the Concourse chart and | `web.ingress.ingressClassName` | IngressClass to register to | `nil` | | `web.ingress.rulesOverride` | Concourse Web Ingress rules (override) (alternate to `web.ingress.hosts`) | `[]` | | `web.ingress.tls` | Concourse Web Ingress TLS configuration | `[]` | +| `web.route.annotations` | Concourse Web HTTPRoute annotations | `{}` | +| `web.route.enabled` | Enable Concourse Web HTTPRoute | `false` | +| `web.route.hostnames` | Concourse Web HTTPRoutes Hostnames | `[]` | +| `web.route.parentRefs` | Concourse Web HTTPRoute parentRefs (gateways) | `[]` | +| `web.route.labels` | Concourse Web HTTPRoute labels | `[]` | | `web.keySecretsPath` | Specify the mount directory of the web keys secrets | `/concourse-keys` | | `web.labels`| Additional labels to be added to the web deployment `metadata.labels` | `{}` | | `web.deploymentAnnotations` | Additional annotations to be added to the web deployment `metadata.annotations` | `{}` | @@ -289,6 +294,7 @@ The following table lists the configurable parameters of the Concourse chart and | `worker.priorityClassName` | Sets a PriorityClass for the worker pods | `nil` | | `worker.terminationGracePeriodSeconds` | Upper bound for graceful shutdown to allow the worker to drain its tasks | `60` | | `worker.tolerations` | Tolerations for the worker nodes | `[]` | +| `worker.persistentVolumeClaimRetentionPolicy` | `Retain` or `Delete` (requires Kubernetes >= 1.32) | `Retain` | | `worker.updateStrategy` | `OnDelete` or `RollingUpdate` (requires Kubernetes >= 1.7) | `RollingUpdate` | For configurable Concourse parameters, refer to [`values.yaml`](values.yaml)' `concourse` section. All parameters under this section are strictly mapped from the `concourse` binary commands. @@ -769,3 +775,25 @@ Instead, you may add a comment specifying the default, such as This prevents the behaviour drifting from that of the binary in case the binary's default values change. We understand that the comment stating the binary's default can become stale. The current solution is a suboptimal one. It may be improved in the future by generating a list of the default values from the binary. + +## Helm Unit Test + +When running unit tests for helm, from the root of the repository, you can simply run the following. + +```bash +helm unittest -f test/unittest/**/*.yaml . +``` + +If you are debugging specific tests, simply target the folder or yaml file you want to run tests on. + +`Folder` + +```bash +helm unittest -f test/unittest/gateway-apis/*.yaml . +``` + +`Specific Test Suite` + +```bash +helm unittest -f test/unittest/gateway-apis/web-route-test.yaml . +``` \ No newline at end of file diff --git a/templates/web-deployment.yaml b/templates/web-deployment.yaml index b403c3a..2a483d4 100644 --- a/templates/web-deployment.yaml +++ b/templates/web-deployment.yaml @@ -623,7 +623,7 @@ spec: {{- end }} {{- if .Values.concourse.web.vault.tokenPath }} - name: CONCOURSE_VAULT_CLIENT_TOKEN_PATH - value: "{{ .Values.concourse.web.vault.tokenPath | quote }}" + value: {{ .Values.concourse.web.vault.tokenPath | quote }} {{- end }} {{- if eq .Values.concourse.web.vault.authBackend "cert" }} - name: CONCOURSE_VAULT_CLIENT_CERT diff --git a/templates/web-route.yaml b/templates/web-route.yaml new file mode 100644 index 0000000..ba1b3b9 --- /dev/null +++ b/templates/web-route.yaml @@ -0,0 +1,42 @@ +{{- if .Values.web.enabled -}} +{{- if .Values.web.route.enabled -}} +{{- $route := .Values.web.route -}} +{{- $releaseName := .Release.Name -}} +{{- $serviceName := include "concourse.web.fullname" . -}} +{{- $servicePort := .Values.concourse.web.bindPort -}} +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: {{ template "concourse.web.fullname" . }} + labels: + app: {{ template "concourse.web.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" + {{- with $route.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with $route.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and $route.parentRefs (gt (len $route.parentRefs) 0) }} + parentRefs: + {{- toYaml $route.parentRefs | nindent 2 }} + {{- end }} + {{- if and $route.hostnames (gt (len $route.hostnames) 0) }} + hostnames: + {{- toYaml $route.hostnames | nindent 2 }} + {{- end }} + rules: + - matches: + - path: + type: PathPrefix + value: / + backendRefs: + - name: {{ $serviceName }} + port: {{ $servicePort }} + namespace: {{ .Release.Namespace | quote }} +{{- end -}} +{{- end -}} diff --git a/templates/worker-deployment.yaml b/templates/worker-deployment.yaml index 38b4a1c..463c832 100644 --- a/templates/worker-deployment.yaml +++ b/templates/worker-deployment.yaml @@ -116,6 +116,10 @@ spec: subPath: worker-additional-certs.pem readOnly: true {{- end }} + {{- if include "concourse.are-there-additional-volumes.with-the-name.concourse-work-dir" . | not }} + - name: concourse-work-dir + mountPath: {{ .Values.concourse.worker.workDir | quote }} + {{- end }} {{- if .Values.worker.additionalVolumeMounts }} {{ toYaml .Values.worker.additionalVolumeMounts | indent 12 }} @@ -147,6 +151,13 @@ spec: release: {{ .Release.Name | quote }} {{- end }} volumes: + {{- if include "concourse.are-there-additional-volumes.with-the-name.concourse-work-dir" . | not }} + - name: concourse-work-dir + emptyDir: + {{- if .Values.worker.emptyDirSize }} + sizeLimit: {{ .Values.worker.emptyDirSize | quote }} + {{- end }} + {{- end }} {{- if .Values.worker.additionalVolumes }} {{ toYaml .Values.worker.additionalVolumes | indent 8 }} {{- end }} diff --git a/templates/worker-policy.yaml b/templates/worker-policy.yaml index 890623b..d280639 100644 --- a/templates/worker-policy.yaml +++ b/templates/worker-policy.yaml @@ -17,4 +17,5 @@ spec: selector: matchLabels: app: {{ template "concourse.worker.fullname" . }} + release: {{ .Release.Name }} {{- end }} diff --git a/templates/worker-statefulset.yaml b/templates/worker-statefulset.yaml index e7de269..f4913c6 100644 --- a/templates/worker-statefulset.yaml +++ b/templates/worker-statefulset.yaml @@ -231,6 +231,10 @@ spec: {{- end }} {{- end }} {{- end }} + {{ if semverCompare ">=1.32-0" .Capabilities.KubeVersion.Version -}} + persistentVolumeClaimRetentionPolicy: +{{ toYaml .Values.worker.persistentVolumeClaimRetentionPolicy | indent 4 }} + {{- end }} {{- if semverCompare "^1.7-0" .Capabilities.KubeVersion.Version }} updateStrategy: {{ toYaml .Values.worker.updateStrategy | indent 4 }} diff --git a/test/unittest/gateway-apis/web-route-test.yaml b/test/unittest/gateway-apis/web-route-test.yaml new file mode 100644 index 0000000..5cbe2c3 --- /dev/null +++ b/test/unittest/gateway-apis/web-route-test.yaml @@ -0,0 +1,151 @@ +suite: GatewayApis + +tests: + - it: Route Disabled + set: + web: + route: + enabled: false + template: web-route.yaml + asserts: + - hasDocuments: + count: 0 + + - it: Route Exposure + set: + web: + route: + enabled: true + parentRefs: + - name: test-parent + namespace: test-namespace + group: gateway.networking.k8s.io + sectionName: test-section + kind: Gateway + hostnames: + - concourse.example.com + template: web-route.yaml + asserts: + - equal: + path: spec.hostnames[0] + value: concourse.example.com + - equal: + path: spec.parentRefs[0].name + value: test-parent + - equal: + path: spec.parentRefs[0].namespace + value: test-namespace + - equal: + path: spec.parentRefs[0].group + value: gateway.networking.k8s.io + - equal: + path: spec.parentRefs[0].sectionName + value: test-section + - equal: + path: spec.parentRefs[0].kind + value: Gateway + + - it: Route Extra Annotations + set: + web: + route: + enabled: true + annotations: + test.annotation: test-annotation + parentRefs: + - name: test-parent + namespace: test-namespace + hostnames: + - concourse.example.com + template: templates/web-route.yaml + asserts: + - equal: + path: metadata.annotations["test.annotation"] + value: test-annotation + + - it: Route Extra Labels + set: + web: + route: + enabled: true + labels: + test.label: test-label + parentRefs: + - name: test-parent + namespace: test-namespace + hostnames: + - concourse.example.com + template: web-route.yaml + asserts: + - equal: + path: metadata.labels["test.label"] + value: test-label + + - it: Route Service Exposure + set: + web: + route: + enabled: true + parentRefs: + - name: test-parent + namespace: test-namespace + hostnames: + - concourse.example.com + template: web-route.yaml + asserts: + - equal: + path: spec.rules[0].backendRefs[0].name + value: RELEASE-NAME-web + - equal: + path: spec.rules[0].matches[0].path.value + value: / + - equal: + path: spec.rules[0].backendRefs[0].port + value: 8080 + + - it: Multiple Hostnames + set: + web: + route: + enabled: true + parentRefs: + - name: test-parent + namespace: test-namespace + hostnames: + - concourse.example.com + - concourse.alternate.com + template: web-route.yaml + asserts: + - equal: + path: spec.hostnames[0] + value: concourse.example.com + - equal: + path: spec.hostnames[1] + value: concourse.alternate.com + - lengthEqual: + path: spec.hostnames + count: 2 + + - it: Multiple ParentRefs + set: + web: + route: + enabled: true + parentRefs: + - name: test-parent-1 + namespace: test-namespace-1 + - name: test-parent-2 + namespace: test-namespace-2 + hostnames: + - concourse.example.com + template: web-route.yaml + asserts: + - equal: + path: spec.parentRefs[0].name + value: test-parent-1 + - equal: + path: spec.parentRefs[1].name + value: test-parent-2 + - lengthEqual: + path: spec.parentRefs + count: 2 diff --git a/values.yaml b/values.yaml index 319544a..31f91bc 100644 --- a/values.yaml +++ b/values.yaml @@ -2471,6 +2471,41 @@ web: ## tls: + ## Route configuration + ## Ref: https://gateway-api.sigs.k8s.io/api-types/httproute/ + ## + route: + + ## Enable HTTPRoutes + ## + enabled: false + + ## Label to be added to the web route. + ## Example: + ## my.label: my-label-value + ## + labels: {} + + ## Annotations to be added to the web route. + ## Example: + ## my.annotation: my-annotation-value + ## + annotations: {} + + ## Gateway API Parent Refs + ## Example + ## - name: envoy + ## namespace: networking + ## sectionName: https + ## group: gateway.networking.k8s.io + ## kind: Gateway + parentRefs: [] + + ## Hosts to attach to the HTTPRoute + ## Example: + ## - "concourse.example.com" + hostnames: [] + ## Configuration values for Concourse Worker components. ## For more information regarding the characteristics of ## Concourse Workers, see https://concourse-ci.org/concourse-worker.html @@ -2697,6 +2732,17 @@ worker: ## terminationGracePeriodSeconds: 60 + ## Controls how PVCs are deleted during the lifecycle of a StatefulSet (requires Kubernetes 1.32+) + ## Ref: https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#persistentvolumeclaim-retention + ## + ## "Retain" is default functionality. + ## "Delete" whenDeleted - all PVCs are deleted after their Pods have been deleted + ## "Delete" whenScaled - only PVCs are deleted when corresponding pod being scaled down is deleted + ## + persistentVolumeClaimRetentionPolicy: + whenDeleted: Retain + whenScaled: Retain + ## Strategy for StatefulSet updates (requires Kubernetes 1.6+) ## Ref: https://kubernetes.io/docs/concepts/workloads/controllers/statefulset ## @@ -2718,7 +2764,8 @@ worker: ## Ignored for Kind Deployment podManagementPolicy: Parallel - ## When persistance is disabled this value will be used to limit the emptyDir volume size + ## When persistance is disabled or using a Deployment, this value will be used + ## to limit the emptyDir volume size ## Ref: https://kubernetes.io/docs/concepts/storage/volumes/#emptydir ## ## Example: 20Gi