From 90804f948dd28a0bc943e3fa458529c9bc7e1416 Mon Sep 17 00:00:00 2001 From: Vasyl Saienko Date: Wed, 18 Dec 2024 07:13:02 +0000 Subject: [PATCH] Unhardcode liveness/readiness endpoint params for glance and barbican * Unify liveness/readiness for glance and barbican api checks. Path now obtained from .Values.endpoint section * Use healthcheck endpoint when TLS is enabled for glance * Make timeout values configurable via values for barbican Change-Id: Ifc5f9cd8aa904d3dece7db3d5dd528bd307ea9bc --- barbican/templates/deployment-api.yaml | 20 ++++++++--------- barbican/values.yaml | 15 +++++++++++++ glance/templates/deployment-api.yaml | 31 ++++++++------------------ glance/values.yaml | 1 + 4 files changed, 35 insertions(+), 32 deletions(-) diff --git a/barbican/templates/deployment-api.yaml b/barbican/templates/deployment-api.yaml index 651abdcd2d..53d77e2855 100644 --- a/barbican/templates/deployment-api.yaml +++ b/barbican/templates/deployment-api.yaml @@ -12,6 +12,14 @@ See the License for the specific language governing permissions and limitations under the License. */}} +{{- define "probeTemplate" }} +{{- $health_path := tuple "key_manager" "healthcheck" "internal" . | include "helm-toolkit.endpoints.keystone_endpoint_path_lookup" }} +httpGet: + scheme: {{ tuple "key_manager" "service" "api" . | include "helm-toolkit.endpoints.keystone_endpoint_scheme_lookup" | upper }} + path: {{ $health_path }} + port: {{ tuple "key_manager" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} +{{- end }} + {{- if .Values.manifests.deployment_api }} {{- $envAll := . }} @@ -62,6 +70,8 @@ spec: {{ tuple $envAll "barbican_api" | include "helm-toolkit.snippets.image" | indent 10 }} {{ tuple $envAll $envAll.Values.pod.resources.api | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} {{ dict "envAll" $envAll "application" "barbican" "container" "barbican_api" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }} +{{ dict "envAll" $envAll "component" "api" "container" "barbican-api" "type" "readiness" "probeTemplate" (include "probeTemplate" $envAll | fromYaml) | include "helm-toolkit.snippets.kubernetes_probe" | indent 10 }} +{{ dict "envAll" $envAll "component" "api" "container" "barbican-api" "type" "liveness" "probeTemplate" (include "probeTemplate" $envAll | fromYaml) | include "helm-toolkit.snippets.kubernetes_probe" | indent 10 }} command: - /tmp/barbican.sh - start @@ -79,16 +89,6 @@ spec: ports: - name: b-api containerPort: {{ tuple "key_manager" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} - livenessProbe: - httpGet: - scheme: HTTP - path: /healthcheck - port: {{ tuple "key_manager" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} - readinessProbe: - httpGet: - scheme: HTTP - path: /healthcheck - port: {{ tuple "key_manager" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} volumeMounts: - name: pod-tmp mountPath: /tmp diff --git a/barbican/values.yaml b/barbican/values.yaml index 91f11a0cc7..a51c132264 100644 --- a/barbican/values.yaml +++ b/barbican/values.yaml @@ -121,6 +121,20 @@ pod: disruption_budget: api: min_available: 0 + probes: + api: + barbican-api: + readiness: + enabled: true + params: + periodSeconds: 10 + timeoutSeconds: 5 + liveness: + enabled: true + params: + initialDelaySeconds: 5 + periodSeconds: 10 + timeoutSeconds: 5 resources: enabled: false api: @@ -588,6 +602,7 @@ endpoints: name: ca-clusterissuer path: default: / + healthcheck: /healthcheck scheme: default: http service: http diff --git a/glance/templates/deployment-api.yaml b/glance/templates/deployment-api.yaml index f60b8b3299..2bde3e59a0 100644 --- a/glance/templates/deployment-api.yaml +++ b/glance/templates/deployment-api.yaml @@ -12,33 +12,20 @@ See the License for the specific language governing permissions and limitations under the License. */}} -{{- define "readinessProbeTemplate" }} +{{- define "probeTemplate" }} +{{- $health_path := tuple "image" "healthcheck" "internal" . | include "helm-toolkit.endpoints.keystone_endpoint_path_lookup" }} +{{- $health_port := tuple "image" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} {{- if .Values.manifests.certificates }} exec: - command: + command: - python - -c - - "import requests; requests.get('http://127.0.0.1:{{ tuple "image" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}')" + - "import requests; requests.get('http://127.0.0.1:{{ $health_port }}{{ $health_path }}')" {{- else }} httpGet: + path: {{ $health_path }} scheme: {{ tuple "image" "service" "api" . | include "helm-toolkit.endpoints.keystone_endpoint_scheme_lookup" | upper }} - path: /healthcheck - port: {{ tuple "image" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} -{{- end }} -{{- end }} - -{{- define "livenessProbeTemplate" }} -{{- if .Values.manifests.certificates }} -exec: - command: - - python - - -c - - "import requests; requests.get('http://127.0.0.1:{{ tuple "image" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}')" -{{- else }} -httpGet: - scheme: {{ tuple "image" "service" "api" . | include "helm-toolkit.endpoints.keystone_endpoint_scheme_lookup" | upper }} - path: /healthcheck - port: {{ tuple "image" "service" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} + port: {{ $health_port }} {{- end }} {{- end }} @@ -178,8 +165,8 @@ spec: {{ tuple $envAll "glance_api" | include "helm-toolkit.snippets.image" | indent 10 }} {{ tuple $envAll $envAll.Values.pod.resources.api | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} {{ dict "envAll" $envAll "application" "glance" "container" "glance_api" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }} -{{ dict "envAll" $envAll "component" "api" "container" "glance-api" "type" "readiness" "probeTemplate" (include "readinessProbeTemplate" $envAll | fromYaml) | include "helm-toolkit.snippets.kubernetes_probe" | indent 10 }} -{{ dict "envAll" $envAll "component" "api" "container" "glance-api" "type" "liveness" "probeTemplate" (include "livenessProbeTemplate" $envAll | fromYaml) | include "helm-toolkit.snippets.kubernetes_probe" | indent 10 }} +{{ dict "envAll" $envAll "component" "api" "container" "glance-api" "type" "readiness" "probeTemplate" (include "probeTemplate" $envAll | fromYaml) | include "helm-toolkit.snippets.kubernetes_probe" | indent 10 }} +{{ dict "envAll" $envAll "component" "api" "container" "glance-api" "type" "liveness" "probeTemplate" (include "probeTemplate" $envAll | fromYaml) | include "helm-toolkit.snippets.kubernetes_probe" | indent 10 }} command: - /tmp/glance-api.sh - start diff --git a/glance/values.yaml b/glance/values.yaml index 38e32b844a..aaf9d4afa1 100644 --- a/glance/values.yaml +++ b/glance/values.yaml @@ -646,6 +646,7 @@ endpoints: # key: null path: default: null + healthcheck: /healthcheck scheme: default: http service: http