Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 1 | {{/* |
| 2 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | you may not use this file except in compliance with the License. |
| 4 | You may obtain a copy of the License at |
| 5 | |
| 6 | http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | |
| 8 | Unless required by applicable law or agreed to in writing, software |
| 9 | distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | See the License for the specific language governing permissions and |
| 12 | limitations under the License. |
| 13 | */}} |
| 14 | |
| 15 | {{- if (.Values.global).subchart_release_name }} |
| 16 | {{- $_ := set . "deployment_name" .Chart.Name }} |
| 17 | {{- else }} |
| 18 | {{- $_ := set . "deployment_name" .Release.Name }} |
| 19 | {{- end }} |
| 20 | |
| 21 | {{- if .Values.manifests.deployment }} |
| 22 | {{- $envAll := . }} |
| 23 | |
| 24 | {{- $rcControllerName := printf "%s-%s" $envAll.deployment_name "memcached" }} |
| 25 | {{- $configMapBinName := printf "%s-%s" $envAll.deployment_name "memcached-bin" }} |
| 26 | |
| 27 | {{ tuple $envAll "memcached" $rcControllerName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} |
| 28 | --- |
| 29 | apiVersion: apps/v1 |
| 30 | kind: Deployment |
| 31 | metadata: |
| 32 | name: {{ $rcControllerName | quote }} |
| 33 | annotations: |
| 34 | {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }} |
| 35 | labels: |
| 36 | {{ tuple $envAll "memcached" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} |
| 37 | spec: |
| 38 | replicas: {{ .Values.pod.replicas.server }} |
| 39 | selector: |
| 40 | matchLabels: |
| 41 | {{ tuple $envAll "memcached" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 6 }} |
| 42 | {{ tuple $envAll | include "helm-toolkit.snippets.kubernetes_upgrades_deployment" | indent 2 }} |
| 43 | template: |
| 44 | metadata: |
| 45 | annotations: |
| 46 | {{ dict "envAll" $envAll "podName" "memcached" "containerNames" (list "init" "memcached") | include "helm-toolkit.snippets.kubernetes_mandatory_access_control_annotation" | indent 8 }} |
| 47 | {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" | indent 8 }} |
| 48 | configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "helm-toolkit.utils.hash" }} |
| 49 | labels: |
| 50 | {{ tuple $envAll "memcached" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} |
| 51 | spec: |
| 52 | {{ dict "envAll" $envAll "application" "server" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 6 }} |
| 53 | shareProcessNamespace: true |
| 54 | serviceAccountName: {{ $rcControllerName | quote }} |
| 55 | affinity: |
| 56 | {{ tuple $envAll "memcached" "server" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 8 }} |
| 57 | nodeSelector: |
| 58 | {{ .Values.labels.server.node_selector_key }}: {{ .Values.labels.server.node_selector_value | quote }} |
| 59 | {{ if $envAll.Values.pod.tolerations.memcached.enabled }} |
| 60 | {{ tuple $envAll "memcached" | include "helm-toolkit.snippets.kubernetes_tolerations" | indent 6 }} |
| 61 | {{ end }} |
| 62 | terminationGracePeriodSeconds: {{ .Values.pod.lifecycle.termination_grace_period.memcached.timeout | default "30" }} |
| 63 | initContainers: |
| 64 | {{ tuple $envAll "memcached" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} |
| 65 | {{ dict "envAll" $envAll | include "helm-toolkit.snippets.kubernetes_apparmor_loader_init_container" | indent 8 }} |
| 66 | containers: |
| 67 | - name: memcached |
| 68 | {{ tuple $envAll "memcached" | include "helm-toolkit.snippets.image" | indent 10 }} |
| 69 | {{ tuple $envAll $envAll.Values.pod.resources.server | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} |
| 70 | {{ dict "envAll" $envAll "application" "server" "container" "memcached" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }} |
| 71 | env: |
| 72 | - name: MEMCACHED_PORT |
| 73 | value: {{ tuple "oslo_cache" "internal" "memcache" . | include "helm-toolkit.endpoints.endpoint_port_lookup" | quote }} |
| 74 | - name: MEMCACHED_MAX_CONNECTIONS |
| 75 | value: {{ .Values.conf.memcached.max_connections | quote }} |
| 76 | - name: MEMCACHED_MEMORY |
| 77 | value: {{ .Values.conf.memcached.memory | quote }} |
| 78 | command: |
| 79 | - /tmp/memcached.sh |
| 80 | ports: |
| 81 | - containerPort: {{ tuple "oslo_cache" "internal" "memcache" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} |
| 82 | readinessProbe: |
| 83 | tcpSocket: |
| 84 | port: {{ tuple "oslo_cache" "internal" "memcache" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} |
| 85 | volumeMounts: |
| 86 | - name: pod-tmp |
| 87 | mountPath: /tmp |
| 88 | - name: memcached-bin |
| 89 | mountPath: /tmp/memcached.sh |
| 90 | subPath: memcached.sh |
| 91 | readOnly: true |
| 92 | {{- if .Values.monitoring.prometheus.enabled }} |
| 93 | - name: memcached-exporter |
| 94 | image: {{ .Values.images.tags.prometheus_memcached_exporter }} |
| 95 | imagePullPolicy: {{ .Values.images.pull_policy }} |
| 96 | {{ tuple $envAll $envAll.Values.pod.resources.prometheus_memcached_exporter | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} |
| 97 | {{ dict "envAll" $envAll "application" "server" "container" "memcached_exporter" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }} |
| 98 | command: |
| 99 | - /tmp/memcached-exporter.sh |
| 100 | - start |
| 101 | ports: |
| 102 | - name: metrics |
| 103 | containerPort: {{ tuple "oslo_cache" "internal" "metrics" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} |
| 104 | readinessProbe: |
| 105 | tcpSocket: |
| 106 | port: {{ tuple "oslo_cache" "internal" "metrics" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} |
| 107 | volumeMounts: |
| 108 | - name: pod-tmp |
| 109 | mountPath: /tmp |
| 110 | - name: memcached-bin |
| 111 | mountPath: /tmp/memcached-exporter.sh |
| 112 | subPath: memcached-exporter.sh |
| 113 | readOnly: true |
| 114 | {{- end }} |
| 115 | volumes: |
| 116 | - name: pod-tmp |
| 117 | emptyDir: {} |
| 118 | - name: memcached-bin |
| 119 | configMap: |
| 120 | name: {{ $configMapBinName | quote }} |
| 121 | defaultMode: 0555 |
| 122 | {{ dict "envAll" $envAll "component" "memcached" "requireSys" true | include "helm-toolkit.snippets.kubernetes_apparmor_volumes" | indent 8 }} |
| 123 | {{- end }} |