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 | {{- define "l2gwAgentLivenessProbeTemplate" }} |
| 16 | exec: |
| 17 | command: |
| 18 | - python |
| 19 | - /tmp/health-probe.py |
| 20 | - --config-file |
| 21 | - /etc/neutron/neutron.conf |
| 22 | - --config-file |
| 23 | - /etc/neutron/l2gw_agent.ini |
| 24 | - --agent-queue-name |
| 25 | - l2gateway_agent |
| 26 | - --liveness-probe |
| 27 | {{- if .Values.pod.use_fqdn.neutron_agent }} |
| 28 | - --use-fqdn |
| 29 | {{- end }} |
| 30 | {{- end }} |
| 31 | |
| 32 | {{- define "l2gwAgentReadinessProbeTemplate" }} |
| 33 | exec: |
| 34 | command: |
| 35 | - python |
| 36 | - /tmp/health-probe.py |
| 37 | - --config-file |
| 38 | - /etc/neutron/neutron.conf |
| 39 | - --config-file |
| 40 | - /etc/neutron/l2gw_agent.ini |
| 41 | - --agent-queue-name |
| 42 | - l2gateway_agent |
| 43 | {{- if .Values.pod.use_fqdn.neutron_agent }} |
| 44 | - --use-fqdn |
| 45 | {{- end }} |
| 46 | {{- end }} |
| 47 | |
| 48 | {{- define "neutron.l2gw_agent.daemonset" }} |
| 49 | {{- $daemonset := index . 0 }} |
| 50 | {{- $configMapName := index . 1 }} |
| 51 | {{- $serviceAccountName := index . 2 }} |
| 52 | {{- $envAll := index . 3 }} |
| 53 | {{- with $envAll }} |
| 54 | |
| 55 | {{- $mounts_neutron_l2gw_agent := .Values.pod.mounts.neutron_l2gw_agent.neutron_l2gw_agent }} |
| 56 | {{- $mounts_neutron_l2gw_agent_init := .Values.pod.mounts.neutron_l2gw_agent.init_container }} |
| 57 | |
| 58 | --- |
| 59 | apiVersion: apps/v1 |
| 60 | kind: DaemonSet |
| 61 | metadata: |
| 62 | name: neutron-l2gw-agent |
| 63 | annotations: |
| 64 | {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }} |
| 65 | labels: |
| 66 | {{ tuple $envAll "neutron" "l2gw-agent" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} |
| 67 | spec: |
| 68 | selector: |
| 69 | matchLabels: |
| 70 | {{ tuple $envAll "neutron" "l2gw-agent" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 6 }} |
| 71 | {{ tuple $envAll "l2gw_agent" | include "helm-toolkit.snippets.kubernetes_upgrades_daemonset" | indent 2 }} |
| 72 | template: |
| 73 | metadata: |
| 74 | labels: |
| 75 | {{ tuple $envAll "neutron" "l2gw-agent" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} |
| 76 | annotations: |
| 77 | {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" | indent 8 }} |
| 78 | configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "helm-toolkit.utils.hash" }} |
| 79 | configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "helm-toolkit.utils.hash" }} |
Rico Lin | 0e15348 | 2024-05-03 03:29:14 +0800 | [diff] [blame] | 80 | {{ tuple "neutron_l2gw_agent" . | include "helm-toolkit.snippets.custom_pod_annotations" | indent 8 }} |
Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 81 | spec: |
| 82 | {{ dict "envAll" $envAll "application" "neutron_l2gw_agent" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 6 }} |
Dong Ma | e5bd5a3 | 2025-02-11 11:03:48 +0000 | [diff] [blame] | 83 | {{ with .Values.pod.priorityClassName.neutron_l2gw_agent }} |
| 84 | priorityClassName: {{ . }} |
| 85 | {{ end }} |
| 86 | {{ with .Values.pod.runtimeClassName.neutron_l2gw_agent }} |
| 87 | runtimeClassName: {{ . }} |
| 88 | {{ end }} |
Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 89 | serviceAccountName: {{ $serviceAccountName }} |
| 90 | {{ if $envAll.Values.pod.tolerations.neutron.enabled }} |
| 91 | {{ tuple $envAll "neutron" | include "helm-toolkit.snippets.kubernetes_tolerations" | indent 6 }} |
| 92 | {{ end }} |
| 93 | nodeSelector: |
| 94 | {{ .Values.labels.agent.l2gw.node_selector_key }}: {{ .Values.labels.agent.l2gw.node_selector_value }} |
| 95 | dnsPolicy: ClusterFirstWithHostNet |
| 96 | hostNetwork: true |
| 97 | {{- if or ( gt .Capabilities.KubeVersion.Major "1" ) ( ge .Capabilities.KubeVersion.Minor "10" ) }} |
| 98 | shareProcessNamespace: true |
| 99 | {{- else }} |
| 100 | hostPID: true |
| 101 | {{- end }} |
| 102 | initContainers: |
| 103 | {{ tuple $envAll "pod_dependency" $mounts_neutron_l2gw_agent_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} |
| 104 | containers: |
| 105 | - name: neutron-l2gw-agent |
| 106 | {{ tuple $envAll "neutron_l2gw" | include "helm-toolkit.snippets.image" | indent 10 }} |
| 107 | {{ tuple $envAll $envAll.Values.pod.resources.agent.l2gw | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} |
| 108 | {{ dict "envAll" $envAll "application" "neutron_l2gw_agent" "container" "neutron_l2gw_agent" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }} |
| 109 | env: |
| 110 | - name: RPC_PROBE_TIMEOUT |
| 111 | value: "{{ .Values.pod.probes.rpc_timeout }}" |
| 112 | - name: RPC_PROBE_RETRIES |
| 113 | value: "{{ .Values.pod.probes.rpc_retries }}" |
| 114 | {{ dict "envAll" $envAll "component" "l2gw_agent" "container" "l2gw_agent" "type" "liveness" "probeTemplate" (include "l2gwAgentLivenessProbeTemplate" $envAll | fromYaml) | include "helm-toolkit.snippets.kubernetes_probe" | indent 10 }} |
| 115 | {{ dict "envAll" $envAll "component" "l2gw_agent" "container" "l2gw_agent" "type" "readiness" "probeTemplate" (include "l2gwAgentReadinessProbeTemplate" $envAll | fromYaml) | include "helm-toolkit.snippets.kubernetes_probe" | indent 10 }} |
| 116 | command: |
| 117 | - /tmp/neutron-l2gw-agent.sh |
| 118 | volumeMounts: |
| 119 | - name: pod-tmp |
| 120 | mountPath: /tmp |
| 121 | - name: pod-var-neutron |
| 122 | mountPath: {{ .Values.conf.neutron.DEFAULT.state_path }} |
| 123 | - name: neutron-bin |
| 124 | mountPath: /tmp/neutron-l2gw-agent.sh |
| 125 | subPath: neutron-l2gw-agent.sh |
| 126 | readOnly: true |
| 127 | - name: neutron-bin |
| 128 | mountPath: /tmp/health-probe.py |
| 129 | subPath: health-probe.py |
| 130 | readOnly: true |
| 131 | - name: neutron-etc |
| 132 | mountPath: /etc/neutron/neutron.conf |
| 133 | subPath: neutron.conf |
| 134 | readOnly: true |
| 135 | {{- if .Values.conf.neutron.DEFAULT.log_config_append }} |
| 136 | - name: neutron-etc |
| 137 | mountPath: {{ .Values.conf.neutron.DEFAULT.log_config_append }} |
| 138 | subPath: {{ base .Values.conf.neutron.DEFAULT.log_config_append }} |
| 139 | readOnly: true |
| 140 | {{- end }} |
| 141 | - name: neutron-etc |
| 142 | mountPath: /etc/neutron/l2gw_agent.ini |
| 143 | subPath: l2gw_agent.ini |
| 144 | readOnly: true |
| 145 | {{- dict "enabled" $envAll.Values.manifests.certificates "name" $envAll.Values.endpoints.oslo_messaging.auth.admin.secret.tls.internal "path" "/etc/rabbitmq/certs" | include "helm-toolkit.snippets.tls_volume_mount" | indent 12 }} |
| 146 | {{ if $mounts_neutron_l2gw_agent.volumeMounts }}{{ toYaml $mounts_neutron_l2gw_agent.volumeMounts | indent 12 }}{{ end }} |
| 147 | volumes: |
| 148 | - name: pod-tmp |
| 149 | emptyDir: {} |
| 150 | - name: pod-var-neutron |
| 151 | emptyDir: {} |
| 152 | - name: neutron-bin |
| 153 | configMap: |
| 154 | name: neutron-bin |
| 155 | defaultMode: 0555 |
| 156 | - name: neutron-etc |
| 157 | secret: |
| 158 | secretName: {{ $configMapName }} |
| 159 | defaultMode: 0444 |
| 160 | {{- dict "enabled" $envAll.Values.manifests.certificates "name" $envAll.Values.endpoints.oslo_messaging.auth.admin.secret.tls.internal | include "helm-toolkit.snippets.tls_volume" | indent 8 }} |
| 161 | {{ if $mounts_neutron_l2gw_agent.volumes }}{{ toYaml $mounts_neutron_l2gw_agent.volumes | indent 8 }}{{ end }} |
| 162 | {{- end }} |
| 163 | {{- end }} |
| 164 | |
| 165 | {{- if .Values.manifests.daemonset_l2gw_agent }} |
| 166 | {{- $envAll := . }} |
| 167 | {{- $daemonset := "l2gw-agent" }} |
| 168 | {{- $configMapName := "neutron-etc" }} |
| 169 | {{- $serviceAccountName := "neutron-l2gw-agent" }} |
| 170 | {{- $dependencyOpts := dict "envAll" $envAll "dependencyMixinParam" $envAll.Values.network.backend "dependencyKey" "l2gateway" -}} |
| 171 | {{- $_ := include "helm-toolkit.utils.dependency_resolver" $dependencyOpts | toString | fromYaml }} |
| 172 | {{ tuple $envAll "pod_dependency" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} |
| 173 | {{- $daemonset_yaml := list $daemonset $configMapName $serviceAccountName . | include "neutron.l2gw_agent.daemonset" | toString | fromYaml }} |
| 174 | {{- $configmap_yaml := "neutron.configmap.etc" }} |
| 175 | {{- list $daemonset $daemonset_yaml $configmap_yaml $configMapName . | include "helm-toolkit.utils.daemonset_overrides" }} |
| 176 | {{- end }} |