Rico Lin | cf86b12 | 2023-11-02 01:29:14 +0800 | [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 "bgp_dragentLivenessProbeTemplate" }} |
| 16 | exec: |
| 17 | command: |
| 18 | - bash |
| 19 | - -c |
| 20 | - pidof -x /var/lib/openstack/bin/neutron-bgp-dragent |
| 21 | {{- end }} |
| 22 | |
| 23 | |
| 24 | {{- define "neutron.bgp_dragent.daemonset" }} |
| 25 | {{- $daemonset := index . 0 }} |
| 26 | {{- $configMapName := index . 1 }} |
| 27 | {{- $serviceAccountName := index . 2 }} |
| 28 | {{- $envAll := index . 3 }} |
| 29 | {{- with $envAll }} |
| 30 | |
| 31 | {{- $mounts_neutron_bgp_dragent := .Values.pod.mounts.bgp_dragent.bgp_dragent }} |
| 32 | {{- $mounts_neutron_bgp_dragent_init := .Values.pod.mounts.bgp_dragent.init_container }} |
| 33 | |
| 34 | --- |
| 35 | apiVersion: apps/v1 |
| 36 | kind: DaemonSet |
| 37 | metadata: |
| 38 | name: bgp-dragent |
| 39 | annotations: |
| 40 | {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }} |
| 41 | labels: |
| 42 | {{ tuple $envAll "neutron" "bgp-dragent" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} |
| 43 | spec: |
| 44 | selector: |
| 45 | matchLabels: |
| 46 | {{ tuple $envAll "neutron" "bgp-dragent" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 6 }} |
| 47 | {{ tuple $envAll "bgp_dragent" | include "helm-toolkit.snippets.kubernetes_upgrades_daemonset" | indent 2 }} |
| 48 | template: |
| 49 | metadata: |
| 50 | labels: |
| 51 | {{ tuple $envAll "neutron" "bgp-dragent" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} |
| 52 | annotations: |
| 53 | {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" | indent 8 }} |
| 54 | configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "helm-toolkit.utils.hash" }} |
| 55 | configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "helm-toolkit.utils.hash" }} |
Rico Lin | 0e15348 | 2024-05-03 03:29:14 +0800 | [diff] [blame] | 56 | {{ tuple "neutron_bgp_dragent" . | include "helm-toolkit.snippets.custom_pod_annotations" | indent 8 }} |
Rico Lin | cf86b12 | 2023-11-02 01:29:14 +0800 | [diff] [blame] | 57 | spec: |
| 58 | {{ dict "envAll" $envAll "application" "neutron_bgp_dragent" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 6 }} |
Dong Ma | 36b8922 | 2025-02-13 16:15:52 +0000 | [diff] [blame] | 59 | {{ with .Values.pod.priorityClassName.bgp_dragent }} |
Dong Ma | e5bd5a3 | 2025-02-11 11:03:48 +0000 | [diff] [blame] | 60 | priorityClassName: {{ . }} |
| 61 | {{ end }} |
Dong Ma | 36b8922 | 2025-02-13 16:15:52 +0000 | [diff] [blame] | 62 | {{ with .Values.pod.runtimeClassName.bgp_dragent }} |
Dong Ma | e5bd5a3 | 2025-02-11 11:03:48 +0000 | [diff] [blame] | 63 | runtimeClassName: {{ . }} |
| 64 | {{ end }} |
Rico Lin | cf86b12 | 2023-11-02 01:29:14 +0800 | [diff] [blame] | 65 | serviceAccountName: {{ $serviceAccountName }} |
| 66 | {{ if $envAll.Values.pod.tolerations.neutron.enabled }} |
| 67 | {{ tuple $envAll "neutron" | include "helm-toolkit.snippets.kubernetes_tolerations" | indent 6 }} |
| 68 | {{ end }} |
| 69 | nodeSelector: |
| 70 | {{ .Values.labels.bgp_dragent.node_selector_key }}: {{ .Values.labels.bgp_dragent.node_selector_value }} |
| 71 | dnsPolicy: ClusterFirstWithHostNet |
| 72 | hostNetwork: true |
| 73 | {{- if or ( gt .Capabilities.KubeVersion.Major "1" ) ( ge .Capabilities.KubeVersion.Minor "10" ) }} |
| 74 | shareProcessNamespace: true |
| 75 | {{- else }} |
| 76 | hostPID: true |
| 77 | {{- end }} |
| 78 | containers: |
| 79 | - name: neutron-bgp-dragent |
| 80 | {{ tuple $envAll "neutron_bgp_dragent" | include "helm-toolkit.snippets.image" | indent 10 }} |
| 81 | {{ tuple $envAll $envAll.Values.pod.resources.agent.bgp_dragent | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} |
| 82 | {{ dict "envAll" $envAll "application" "neutron_bgp_dragent" "container" "neutron_bgp_dragent" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }} |
| 83 | {{ dict "envAll" $envAll "component" "bgp_dragent" "container" "bgp_dragent" "type" "liveness" "probeTemplate" (include "bgp_dragentLivenessProbeTemplate" $envAll | fromYaml) | include "helm-toolkit.snippets.kubernetes_probe" | indent 10 }} |
| 84 | command: |
| 85 | - /tmp/neutron-bgp-dragent.sh |
| 86 | volumeMounts: |
| 87 | - name: pod-tmp |
| 88 | mountPath: /tmp |
| 89 | - name: pod-var-neutron |
| 90 | mountPath: {{ .Values.conf.neutron.DEFAULT.state_path }} |
| 91 | - name: neutron-bin |
| 92 | mountPath: /tmp/neutron-bgp-dragent.sh |
| 93 | subPath: neutron-bgp-dragent.sh |
| 94 | readOnly: true |
| 95 | - name: neutron-bin |
| 96 | mountPath: /tmp/health-probe.py |
| 97 | subPath: health-probe.py |
| 98 | readOnly: true |
| 99 | - name: neutron-etc |
| 100 | mountPath: /etc/neutron/neutron.conf |
| 101 | subPath: neutron.conf |
| 102 | readOnly: true |
| 103 | {{- if .Values.conf.neutron.DEFAULT.log_config_append }} |
| 104 | - name: neutron-etc |
| 105 | mountPath: {{ .Values.conf.neutron.DEFAULT.log_config_append }} |
| 106 | subPath: {{ base .Values.conf.neutron.DEFAULT.log_config_append }} |
| 107 | readOnly: true |
| 108 | {{- end }} |
| 109 | - name: neutron-etc |
| 110 | mountPath: /etc/neutron/bgp_dragent.ini |
| 111 | subPath: bgp_dragent.ini |
| 112 | readOnly: true |
| 113 | - name: neutron-etc |
| 114 | # NOTE (Portdirect): We mount here to override Kollas |
| 115 | # custom sudoers file when using Kolla images, this |
| 116 | # location will also work fine for other images. |
| 117 | mountPath: /etc/sudoers.d/kolla_neutron_sudoers |
| 118 | subPath: neutron_sudoers |
| 119 | readOnly: true |
| 120 | - name: neutron-etc |
| 121 | mountPath: /etc/neutron/rootwrap.conf |
| 122 | subPath: rootwrap.conf |
| 123 | readOnly: true |
| 124 | {{- range $key, $value := $envAll.Values.conf.rootwrap_filters }} |
| 125 | {{- if ( has "bgp_dragent" $value.pods ) }} |
| 126 | {{- $filePrefix := replace "_" "-" $key }} |
| 127 | {{- $rootwrapFile := printf "/etc/neutron/rootwrap.d/%s.filters" $filePrefix }} |
| 128 | - name: neutron-etc |
| 129 | mountPath: {{ $rootwrapFile }} |
| 130 | subPath: {{ base $rootwrapFile }} |
| 131 | readOnly: true |
| 132 | {{- end }} |
| 133 | {{- end }} |
| 134 | - name: libmodules |
| 135 | mountPath: /lib/modules |
| 136 | readOnly: true |
| 137 | - name: run |
| 138 | mountPath: /run |
| 139 | {{ if $mounts_neutron_bgp_dragent.volumeMounts }}{{ toYaml $mounts_neutron_bgp_dragent.volumeMounts | indent 12 }}{{ end }} |
| 140 | volumes: |
| 141 | - name: pod-tmp |
| 142 | emptyDir: {} |
| 143 | - name: pod-var-neutron |
| 144 | emptyDir: {} |
| 145 | - name: neutron-bin |
| 146 | configMap: |
| 147 | name: neutron-bin |
| 148 | defaultMode: 0555 |
| 149 | - name: neutron-etc |
| 150 | secret: |
| 151 | secretName: {{ $configMapName }} |
| 152 | defaultMode: 0444 |
| 153 | - name: libmodules |
| 154 | hostPath: |
| 155 | path: /lib/modules |
| 156 | - name: run |
| 157 | hostPath: |
| 158 | path: /run |
| 159 | {{ if $mounts_neutron_bgp_dragent.volumes }}{{ toYaml $mounts_neutron_bgp_dragent.volumes | indent 8 }}{{ end }} |
| 160 | {{- end }} |
| 161 | {{- end }} |
| 162 | |
| 163 | {{- if .Values.manifests.daemonset_bgp_dragent }} |
| 164 | {{- $envAll := . }} |
| 165 | {{- $daemonset := "bgp-dragent" }} |
| 166 | {{- $configMapName := "neutron-etc" }} |
| 167 | {{- $serviceAccountName := "neutron-bgp-dragent" }} |
| 168 | {{- $dependencyOpts := dict "envAll" $envAll "dependencyMixinParam" $envAll.Values.network.backend "dependencyKey" "bgp_dragent" -}} |
| 169 | {{- $_ := include "helm-toolkit.utils.dependency_resolver" $dependencyOpts | toString | fromYaml }} |
| 170 | {{ tuple $envAll "pod_dependency" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} |
| 171 | {{- $daemonset_yaml := list $daemonset $configMapName $serviceAccountName . | include "neutron.bgp_dragent.daemonset" | toString | fromYaml }} |
| 172 | {{- $configmap_yaml := "neutron.configmap.etc" }} |
| 173 | {{- list $daemonset $daemonset_yaml $configmap_yaml $configMapName . | include "helm-toolkit.utils.daemonset_overrides" }} |
| 174 | {{- end }} |