From 6a0e6cd750f6fca373b496e3ec3d24bcad1c3bb5 Mon Sep 17 00:00:00 2001 From: Rajan Gupta Date: Sat, 20 Jan 2024 13:49:14 +0800 Subject: [PATCH 1/2] Add wait-etcd initContainer and support extraInitContainers --- charts/apisix-dashboard/Chart.yaml | 2 +- charts/apisix-dashboard/README.md | 5 +++++ .../apisix-dashboard/templates/deployment.yaml | 11 +++++++++++ charts/apisix-dashboard/values.yaml | 18 ++++++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/charts/apisix-dashboard/Chart.yaml b/charts/apisix-dashboard/Chart.yaml index cf180d53..6104f62f 100644 --- a/charts/apisix-dashboard/Chart.yaml +++ b/charts/apisix-dashboard/Chart.yaml @@ -31,7 +31,7 @@ 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.8.1 +version: 0.8.2 # 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 diff --git a/charts/apisix-dashboard/README.md b/charts/apisix-dashboard/README.md index 80560b6e..937150b1 100644 --- a/charts/apisix-dashboard/README.md +++ b/charts/apisix-dashboard/README.md @@ -75,6 +75,7 @@ _See [helm upgrade](https://helm.sh/docs/helm/helm_upgrade/) for command documen | config.conf.log.errorLog.filePath | string | `"/dev/stderr"` | Access log path | | config.conf.plugins | list | `[]` | Overrides plugins in the APISIX Dashboard conf | | config.schema.configMap | object | `{}` | Overrides APISIX Dashboard schema.json by mounting configMap containing schema.json | +| extraInitContainers | list | `[]` | Additional `initContainers`, See [Kubernetes initContainers](https://kubernetes.io/docs/concepts/workloads/pods/init-containers/) for the detail. | | fullnameOverride | string | `""` | String to fully override apisix-dashboard.fullname template | | image.pullPolicy | string | `"IfNotPresent"` | Apache APISIX Dashboard image pull policy | | image.repository | string | `"apache/apisix-dashboard"` | Apache APISIX Dashboard image repository | @@ -85,6 +86,10 @@ _See [helm upgrade](https://helm.sh/docs/helm/helm_upgrade/) for command documen | ingress.enabled | bool | `false` | Set to true to enable ingress record generation | | ingress.hosts | list | `[{"host":"apisix-dashboard.local","paths":[]}]` | The list of hostnams to be covered with this ingress record | | ingress.tls | list | `[]` | Create TLS Secret | +| initContainer | object | `{"image":"busybox","securityContext":{},"tag":1.28}` | Set initContainer for Apache APISIX Dashboard pods | +| initContainer.image | string | `"busybox"` | Init container image | +| initContainer.securityContext | object | `{}` | Set the securityContext for the init container | +| initContainer.tag | float | `1.28` | Init container tag | | labelsOverride | object | `{}` | Override default labels assigned to Apache APISIX dashboard resource | | nameOverride | string | `""` | String to partially override apisix-dashboard.fullname template (will maintain the release name) | | nodeSelector | object | `{}` | Node labels for pod assignment | diff --git a/charts/apisix-dashboard/templates/deployment.yaml b/charts/apisix-dashboard/templates/deployment.yaml index 3689d84e..078fe06d 100644 --- a/charts/apisix-dashboard/templates/deployment.yaml +++ b/charts/apisix-dashboard/templates/deployment.yaml @@ -53,6 +53,17 @@ spec: serviceAccountName: {{ include "apisix-dashboard.serviceAccountName" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} + initContainers: + - name: wait-etcd + image: {{ .Values.initContainer.image }}:{{ .Values.initContainer.tag }} + command: ['sh', '-c', 'IFS=","; for endpoint in {{ .Values.config.conf.etcd.endpoints }}; do endpoint=$(echo "$endpoint" | tr -d "[]"); until nc -z "$endpoint" && echo "SUCCESS"; do echo "waiting for etcd at $endpoint `date`"; sleep 2; done; done; unset IFS;'] + {{- with .Values.initContainer.securityContext }} + securityContext: + {{- . | toYaml | nindent 8 }} + {{- end }} + {{- if .Values.extraInitContainers }} + {{- toYaml .Values.extraInitContainers | nindent 4 }} + {{- end }} containers: - name: {{ .Chart.Name }} securityContext: diff --git a/charts/apisix-dashboard/values.yaml b/charts/apisix-dashboard/values.yaml index 2f0d89b2..556ad990 100644 --- a/charts/apisix-dashboard/values.yaml +++ b/charts/apisix-dashboard/values.yaml @@ -197,3 +197,21 @@ affinity: {} # -- Topology Spread Constraints for pod assignment spread across your cluster among failure-domains # ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods topologySpreadConstraints: [] + +# -- Set initContainer for Apache APISIX Dashboard pods +initContainer: + # -- Init container image + image: busybox + # -- Init container tag + tag: 1.28 + # -- Set the securityContext for the init container + securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +# -- Additional `initContainers`, See [Kubernetes initContainers](https://kubernetes.io/docs/concepts/workloads/pods/init-containers/) for the detail. +extraInitContainers: [] From e4789e9fc6e7793fa38d14876b851375ffe77b04 Mon Sep 17 00:00:00 2001 From: Rajan Gupta Date: Sat, 20 Jan 2024 13:55:50 +0800 Subject: [PATCH 2/2] Add example for extraInitContainers --- charts/apisix-dashboard/values.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/charts/apisix-dashboard/values.yaml b/charts/apisix-dashboard/values.yaml index 556ad990..926eeae5 100644 --- a/charts/apisix-dashboard/values.yaml +++ b/charts/apisix-dashboard/values.yaml @@ -215,3 +215,9 @@ initContainer: # -- Additional `initContainers`, See [Kubernetes initContainers](https://kubernetes.io/docs/concepts/workloads/pods/init-containers/) for the detail. extraInitContainers: [] + # - name: your-image-name + # image: your-image + # imagePullPolicy: Always + # ports: + # - name: portname + # containerPort: 1234