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 "ovsAgentReadinessProbeTemplate" }} |
| 16 | exec: |
| 17 | command: |
| 18 | - /tmp/neutron-openvswitch-agent-readiness.sh |
| 19 | {{- end }} |
| 20 | {{- define "ovsAgentLivenessProbeTemplate" }} |
| 21 | exec: |
| 22 | command: |
Mohammed Naser | a720f88 | 2023-06-30 23:48:02 -0400 | [diff] [blame] | 23 | - /tmp/neutron-openvswitch-agent-liveness.sh |
Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 24 | {{- end }} |
| 25 | |
| 26 | {{- define "neutron.ovs_agent.daemonset" }} |
| 27 | {{- $daemonset := index . 0 }} |
| 28 | {{- $configMapName := index . 1 }} |
| 29 | {{- $serviceAccountName := index . 2 }} |
| 30 | {{- $envAll := index . 3 }} |
| 31 | {{- with $envAll }} |
| 32 | |
| 33 | {{- $mounts_neutron_ovs_agent := .Values.pod.mounts.neutron_ovs_agent.neutron_ovs_agent }} |
| 34 | {{- $mounts_neutron_ovs_agent_init := .Values.pod.mounts.neutron_ovs_agent.init_container }} |
| 35 | |
| 36 | --- |
| 37 | apiVersion: apps/v1 |
| 38 | kind: DaemonSet |
| 39 | metadata: |
| 40 | name: neutron-ovs-agent |
| 41 | annotations: |
| 42 | {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }} |
| 43 | labels: |
| 44 | {{ tuple $envAll "neutron" "neutron-ovs-agent" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} |
| 45 | spec: |
| 46 | selector: |
| 47 | matchLabels: |
| 48 | {{ tuple $envAll "neutron" "neutron-ovs-agent" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 6 }} |
| 49 | {{ tuple $envAll "ovs_agent" | include "helm-toolkit.snippets.kubernetes_upgrades_daemonset" | indent 2 }} |
| 50 | template: |
| 51 | metadata: |
| 52 | labels: |
| 53 | {{ tuple $envAll "neutron" "neutron-ovs-agent" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} |
| 54 | annotations: |
| 55 | {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" | indent 8 }} |
| 56 | configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "helm-toolkit.utils.hash" }} |
| 57 | configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "helm-toolkit.utils.hash" }} |
Rico Lin | 0e15348 | 2024-05-03 03:29:14 +0800 | [diff] [blame] | 58 | {{ tuple "neutron_ovs_agent" . | include "helm-toolkit.snippets.custom_pod_annotations" | indent 8 }} |
Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 59 | {{ dict "envAll" $envAll "podName" "$configMapName" "containerNames" (list "neutron-ovs-agent" "init" "neutron-openvswitch-agent-kernel-modules" "neutron-ovs-agent-init") | include "helm-toolkit.snippets.kubernetes_mandatory_access_control_annotation" | indent 8 }} |
| 60 | spec: |
| 61 | {{ dict "envAll" $envAll "application" "neutron_ovs_agent" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 6 }} |
Dong Ma | e5bd5a3 | 2025-02-11 11:03:48 +0000 | [diff] [blame] | 62 | {{ with .Values.pod.priorityClassName.neutron_ovs_agent }} |
| 63 | priorityClassName: {{ . }} |
| 64 | {{ end }} |
| 65 | {{ with .Values.pod.runtimeClassName.neutron_ovs_agent }} |
| 66 | runtimeClassName: {{ . }} |
| 67 | {{ end }} |
Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 68 | serviceAccountName: {{ $serviceAccountName }} |
| 69 | nodeSelector: |
| 70 | {{ .Values.labels.ovs.node_selector_key }}: {{ .Values.labels.ovs.node_selector_value }} |
| 71 | {{ if $envAll.Values.pod.tolerations.neutron.enabled }} |
| 72 | {{ tuple $envAll "neutron" | include "helm-toolkit.snippets.kubernetes_tolerations" | indent 6 }} |
| 73 | {{ end }} |
| 74 | dnsPolicy: ClusterFirstWithHostNet |
| 75 | hostNetwork: true |
| 76 | {{- if or ( gt .Capabilities.KubeVersion.Major "1" ) ( ge .Capabilities.KubeVersion.Minor "10" ) }} |
| 77 | shareProcessNamespace: true |
| 78 | {{- else }} |
| 79 | hostPID: true |
| 80 | {{- end }} |
| 81 | initContainers: |
| 82 | {{ tuple $envAll "pod_dependency" $mounts_neutron_ovs_agent_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} |
| 83 | - name: neutron-openvswitch-agent-kernel-modules |
| 84 | {{ tuple $envAll "neutron_openvswitch_agent" | include "helm-toolkit.snippets.image" | indent 10 }} |
| 85 | {{ dict "envAll" $envAll "application" "neutron_ovs_agent" "container" "neutron_openvswitch_agent_kernel_modules" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }} |
| 86 | command: |
| 87 | - /tmp/neutron-openvswitch-agent-init-modules.sh |
| 88 | volumeMounts: |
| 89 | - name: pod-tmp |
| 90 | mountPath: /tmp |
| 91 | - name: neutron-bin |
| 92 | mountPath: /tmp/neutron-openvswitch-agent-init-modules.sh |
| 93 | subPath: neutron-openvswitch-agent-init-modules.sh |
| 94 | readOnly: true |
| 95 | - name: host-rootfs |
| 96 | mountPath: /mnt/host-rootfs |
| 97 | mountPropagation: HostToContainer |
| 98 | readOnly: true |
| 99 | {{- if .Values.conf.ovs_dpdk.enabled }} |
| 100 | - name: pci-devices |
| 101 | mountPath: /sys/bus/pci/devices |
| 102 | {{- end }} |
ricolin | 18e6fd3 | 2023-07-17 06:17:15 +0000 | [diff] [blame] | 103 | {{- if .Values.conf.netoffload.enabled }} |
Mohammed Naser | a720f88 | 2023-06-30 23:48:02 -0400 | [diff] [blame] | 104 | - name: netoffload |
| 105 | {{ tuple $envAll "netoffload" | include "helm-toolkit.snippets.image" | indent 10 }} |
| 106 | {{ dict "envAll" $envAll "application" "neutron_ovs_agent" "container" "netoffload" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }} |
| 107 | command: |
| 108 | - /tmp/neutron-openvswitch-agent-init-netoffload.sh |
| 109 | volumeMounts: |
| 110 | - name: pod-tmp |
| 111 | mountPath: /tmp |
| 112 | - name: neutron-bin |
| 113 | mountPath: /tmp/neutron-openvswitch-agent-init-netoffload.sh |
| 114 | subPath: neutron-openvswitch-agent-init-netoffload.sh |
| 115 | readOnly: true |
| 116 | - name: neutron-etc |
| 117 | mountPath: /tmp/netoffload |
| 118 | subPath: netoffload |
| 119 | readOnly: true |
| 120 | - name: run |
| 121 | mountPath: /run |
ricolin | 18e6fd3 | 2023-07-17 06:17:15 +0000 | [diff] [blame] | 122 | {{- end }} |
Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 123 | - name: neutron-ovs-agent-init |
| 124 | {{ tuple $envAll "neutron_openvswitch_agent" | include "helm-toolkit.snippets.image" | indent 10 }} |
| 125 | {{ tuple $envAll $envAll.Values.pod.resources.agent.ovs | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} |
| 126 | {{ dict "envAll" $envAll "application" "neutron_ovs_agent" "container" "neutron_ovs_agent_init" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }} |
| 127 | {{- if .Values.conf.ovs_dpdk.enabled }} |
| 128 | env: |
| 129 | - name: UPDATE_DPDK_BOND_CONFIG |
| 130 | valueFrom: |
| 131 | secretKeyRef: |
| 132 | name: {{ $configMapName }} |
| 133 | key: update_dpdk_bond_config |
| 134 | {{- end }} |
| 135 | command: |
| 136 | - /tmp/neutron-openvswitch-agent-init.sh |
| 137 | volumeMounts: |
| 138 | - name: pod-tmp |
| 139 | mountPath: /tmp |
| 140 | - name: neutron-bin |
| 141 | mountPath: /tmp/neutron-openvswitch-agent-init.sh |
| 142 | subPath: neutron-openvswitch-agent-init.sh |
| 143 | readOnly: true |
| 144 | - name: pod-shared |
| 145 | mountPath: /tmp/pod-shared |
| 146 | - name: neutron-etc |
| 147 | mountPath: /etc/neutron/neutron.conf |
| 148 | subPath: neutron.conf |
| 149 | readOnly: true |
| 150 | - name: neutron-etc |
| 151 | mountPath: /etc/neutron/plugins/ml2/ml2_conf.ini |
| 152 | subPath: ml2_conf.ini |
| 153 | readOnly: true |
| 154 | - name: neutron-etc |
| 155 | mountPath: /etc/neutron/plugins/ml2/openvswitch_agent.ini |
| 156 | subPath: openvswitch_agent.ini |
| 157 | readOnly: true |
| 158 | {{- if .Values.conf.neutron.DEFAULT.log_config_append }} |
| 159 | - name: neutron-etc |
| 160 | mountPath: {{ .Values.conf.neutron.DEFAULT.log_config_append }} |
| 161 | subPath: {{ base .Values.conf.neutron.DEFAULT.log_config_append }} |
| 162 | readOnly: true |
| 163 | {{- end }} |
| 164 | {{- if .Values.conf.plugins.taas.taas.enabled }} |
| 165 | - name: neutron-etc |
| 166 | mountPath: /etc/neutron/plugins/ml2/taas.ini |
| 167 | subPath: taas.ini |
| 168 | readOnly: true |
| 169 | {{- end }} |
| 170 | - name: neutron-etc |
| 171 | # NOTE (Portdirect): We mount here to override Kollas |
| 172 | # custom sudoers file when using Kolla images, this |
| 173 | # location will also work fine for other images. |
| 174 | mountPath: /etc/sudoers.d/kolla_neutron_sudoers |
| 175 | subPath: neutron_sudoers |
| 176 | readOnly: true |
| 177 | - name: neutron-etc |
| 178 | mountPath: /tmp/auto_bridge_add |
| 179 | subPath: auto_bridge_add |
| 180 | readOnly: true |
| 181 | - name: neutron-etc |
| 182 | mountPath: /etc/neutron/rootwrap.conf |
| 183 | subPath: rootwrap.conf |
| 184 | readOnly: true |
| 185 | {{- if .Values.conf.ovs_dpdk.enabled }} |
| 186 | - name: neutron-etc |
| 187 | mountPath: /tmp/dpdk.conf |
| 188 | subPath: dpdk.conf |
| 189 | readOnly: true |
| 190 | {{- end }} |
| 191 | {{- range $key, $value := $envAll.Values.conf.rootwrap_filters }} |
| 192 | {{- if ( has "ovs_agent" $value.pods ) }} |
| 193 | {{- $filePrefix := replace "_" "-" $key }} |
| 194 | {{- $rootwrapFile := printf "/etc/neutron/rootwrap.d/%s.filters" $filePrefix }} |
| 195 | - name: neutron-etc |
| 196 | mountPath: {{ $rootwrapFile }} |
| 197 | subPath: {{ base $rootwrapFile }} |
| 198 | readOnly: true |
| 199 | {{- end }} |
| 200 | {{- end }} |
| 201 | - name: run |
| 202 | mountPath: /run |
| 203 | {{ if $mounts_neutron_ovs_agent.volumeMounts }}{{ toYaml $mounts_neutron_ovs_agent.volumeMounts | indent 12 }}{{ end }} |
| 204 | containers: |
| 205 | - name: neutron-ovs-agent |
| 206 | {{ tuple $envAll "neutron_openvswitch_agent" | include "helm-toolkit.snippets.image" | indent 10 }} |
| 207 | {{ tuple $envAll $envAll.Values.pod.resources.agent.ovs | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} |
| 208 | env: |
| 209 | - name: RPC_PROBE_TIMEOUT |
| 210 | value: "{{ .Values.pod.probes.rpc_timeout }}" |
| 211 | - name: RPC_PROBE_RETRIES |
| 212 | value: "{{ .Values.pod.probes.rpc_retries }}" |
| 213 | {{ dict "envAll" $envAll "component" "ovs_agent" "container" "ovs_agent" "type" "readiness" "probeTemplate" (include "ovsAgentReadinessProbeTemplate" $envAll | fromYaml) | include "helm-toolkit.snippets.kubernetes_probe" | indent 10 }} |
| 214 | {{ dict "envAll" $envAll "component" "ovs_agent" "container" "ovs_agent" "type" "liveness" "probeTemplate" (include "ovsAgentLivenessProbeTemplate" $envAll | fromYaml) | include "helm-toolkit.snippets.kubernetes_probe" | indent 10 }} |
| 215 | {{ dict "envAll" $envAll "application" "neutron_ovs_agent" "container" "neutron_ovs_agent" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }} |
| 216 | command: |
| 217 | - /tmp/neutron-openvswitch-agent.sh |
| 218 | volumeMounts: |
| 219 | - name: pod-tmp |
| 220 | mountPath: /tmp |
| 221 | - name: pod-var-neutron |
| 222 | mountPath: {{ .Values.conf.neutron.DEFAULT.state_path }} |
| 223 | - name: neutron-bin |
| 224 | mountPath: /tmp/neutron-openvswitch-agent.sh |
| 225 | subPath: neutron-openvswitch-agent.sh |
| 226 | readOnly: true |
| 227 | - name: neutron-bin |
| 228 | mountPath: /tmp/neutron-openvswitch-agent-readiness.sh |
| 229 | subPath: neutron-openvswitch-agent-readiness.sh |
| 230 | readOnly: true |
| 231 | - name: neutron-bin |
Mohammed Naser | a720f88 | 2023-06-30 23:48:02 -0400 | [diff] [blame] | 232 | mountPath: /tmp/neutron-openvswitch-agent-liveness.sh |
| 233 | subPath: neutron-openvswitch-agent-liveness.sh |
| 234 | readOnly: true |
| 235 | - name: neutron-bin |
Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 236 | mountPath: /tmp/health-probe.py |
| 237 | subPath: health-probe.py |
| 238 | readOnly: true |
| 239 | - name: pod-shared |
| 240 | mountPath: /tmp/pod-shared |
| 241 | - name: neutron-etc |
| 242 | mountPath: /etc/neutron/neutron.conf |
| 243 | subPath: neutron.conf |
| 244 | readOnly: true |
| 245 | {{- if .Values.conf.neutron.DEFAULT.log_config_append }} |
| 246 | - name: neutron-etc |
| 247 | mountPath: {{ .Values.conf.neutron.DEFAULT.log_config_append }} |
| 248 | subPath: {{ base .Values.conf.neutron.DEFAULT.log_config_append }} |
| 249 | readOnly: true |
| 250 | {{- end }} |
| 251 | - name: neutron-etc |
| 252 | mountPath: /etc/neutron/plugins/ml2/ml2_conf.ini |
| 253 | subPath: ml2_conf.ini |
| 254 | readOnly: true |
| 255 | - name: neutron-etc |
| 256 | mountPath: /etc/neutron/plugins/ml2/openvswitch_agent.ini |
| 257 | subPath: openvswitch_agent.ini |
| 258 | readOnly: true |
| 259 | {{- if .Values.conf.plugins.taas.taas.enabled }} |
| 260 | - name: neutron-etc |
| 261 | mountPath: /etc/neutron/plugins/ml2/taas.ini |
| 262 | subPath: taas.ini |
| 263 | readOnly: true |
| 264 | {{- end }} |
| 265 | - name: neutron-etc |
| 266 | # NOTE (Portdirect): We mount here to override Kollas |
| 267 | # custom sudoers file when using Kolla images, this |
| 268 | # location will also work fine for other images. |
| 269 | mountPath: /etc/sudoers.d/kolla_neutron_sudoers |
| 270 | subPath: neutron_sudoers |
| 271 | readOnly: true |
| 272 | - name: neutron-etc |
| 273 | mountPath: /etc/neutron/rootwrap.conf |
| 274 | subPath: rootwrap.conf |
| 275 | readOnly: true |
| 276 | {{- range $key, $value := $envAll.Values.conf.rootwrap_filters }} |
| 277 | {{- if ( has "ovs_agent" $value.pods ) }} |
| 278 | {{- $filePrefix := replace "_" "-" $key }} |
| 279 | {{- $rootwrapFile := printf "/etc/neutron/rootwrap.d/%s.filters" $filePrefix }} |
| 280 | - name: neutron-etc |
| 281 | mountPath: {{ $rootwrapFile }} |
| 282 | subPath: {{ base $rootwrapFile }} |
| 283 | readOnly: true |
| 284 | {{- end }} |
| 285 | {{- end }} |
| 286 | - name: run |
| 287 | mountPath: /run |
| 288 | {{- 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 }} |
| 289 | {{ if $mounts_neutron_ovs_agent.volumeMounts }}{{ toYaml $mounts_neutron_ovs_agent.volumeMounts | indent 12 }}{{ end }} |
| 290 | volumes: |
| 291 | - name: pod-tmp |
| 292 | emptyDir: {} |
| 293 | - name: pod-var-neutron |
| 294 | emptyDir: {} |
| 295 | - name: varlibopenvswitch |
| 296 | emptyDir: {} |
| 297 | - name: pod-shared |
| 298 | emptyDir: {} |
| 299 | - name: neutron-bin |
| 300 | configMap: |
| 301 | name: neutron-bin |
| 302 | defaultMode: 0555 |
| 303 | - name: neutron-etc |
| 304 | secret: |
| 305 | secretName: {{ $configMapName }} |
| 306 | defaultMode: 0444 |
| 307 | - name: run |
| 308 | hostPath: |
| 309 | path: /run |
| 310 | - name: host-rootfs |
| 311 | hostPath: |
| 312 | path: / |
| 313 | {{- if .Values.conf.ovs_dpdk.enabled }} |
| 314 | - name: pci-devices |
| 315 | hostPath: |
| 316 | path: /sys/bus/pci/devices |
| 317 | type: Directory |
| 318 | {{- end }} |
| 319 | {{- 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 }} |
| 320 | {{ if $mounts_neutron_ovs_agent.volumes }}{{ toYaml $mounts_neutron_ovs_agent.volumes | indent 8 }}{{ end }} |
| 321 | {{- end }} |
| 322 | {{- end }} |
| 323 | |
| 324 | {{- if and .Values.manifests.daemonset_ovs_agent ( has "openvswitch" .Values.network.backend ) }} |
| 325 | {{- $envAll := . }} |
| 326 | {{- $daemonset := "ovs-agent" }} |
| 327 | {{- $configMapName := "neutron-etc" }} |
| 328 | {{- $serviceAccountName := "neutron-ovs-agent" }} |
| 329 | {{- $dependencyOpts := dict "envAll" $envAll "dependencyMixinParam" $envAll.Values.network.backend "dependencyKey" "ovs_agent" -}} |
| 330 | {{- $_ := include "helm-toolkit.utils.dependency_resolver" $dependencyOpts | toString | fromYaml }} |
| 331 | {{ tuple $envAll "pod_dependency" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} |
| 332 | {{- $daemonset_yaml := list $daemonset $configMapName $serviceAccountName . | include "neutron.ovs_agent.daemonset" | toString | fromYaml }} |
| 333 | {{- $configmap_yaml := "neutron.configmap.etc" }} |
| 334 | {{- list $daemonset $daemonset_yaml $configmap_yaml $configMapName . | include "helm-toolkit.utils.daemonset_overrides" }} |
| 335 | {{- end }} |