diff --git a/packages/system/kubeovn/Chart.yaml b/packages/system/kubeovn/Chart.yaml index b1a4e05b3..d15327948 100644 --- a/packages/system/kubeovn/Chart.yaml +++ b/packages/system/kubeovn/Chart.yaml @@ -1,3 +1,3 @@ apiVersion: v2 name: cozy-kubeovn -version: 0.38.0 +version: 0.39.0 diff --git a/packages/system/kubeovn/charts/kube-ovn/Chart.yaml b/packages/system/kubeovn/charts/kube-ovn/Chart.yaml index 9c01c123a..d025e7de3 100644 --- a/packages/system/kubeovn/charts/kube-ovn/Chart.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/Chart.yaml @@ -15,12 +15,12 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: v1.15.10 +version: v1.15.26 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "1.15.10" +appVersion: "1.15.26" kubeVersion: ">= 1.29.0-0" diff --git a/packages/system/kubeovn/charts/kube-ovn/README.md b/packages/system/kubeovn/charts/kube-ovn/README.md index 74e5c3f13..eed32a283 100644 --- a/packages/system/kubeovn/charts/kube-ovn/README.md +++ b/packages/system/kubeovn/charts/kube-ovn/README.md @@ -50,5 +50,9 @@ and use the following options to install this Helm-chart: --set cni_conf.MOUNT_LOCAL_BIN_DIR=false --set OPENVSWITCH_DIR=/var/lib/openvswitch --set OVN_DIR=/var/lib/ovn +--set OVN_IPSEC_KEY_DIR=/var/lib/ovs_ipsec_keys --set DISABLE_MODULES_MANAGEMENT=true ``` + +`OVN_IPSEC_KEY_DIR` only becomes a host mount when `func.ENABLE_OVN_IPSEC` is enabled, but setting it up +front keeps IPSEC from failing later with `mkdir /etc/origin: read-only file system`. diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/_helpers.tpl b/packages/system/kubeovn/charts/kube-ovn/templates/_helpers.tpl index ce144769e..19141bb85 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/_helpers.tpl +++ b/packages/system/kubeovn/charts/kube-ovn/templates/_helpers.tpl @@ -10,10 +10,10 @@ a dry-run/template call and return nothing. {{- $label := splitList "=" $.Values.MASTER_NODES_LABEL }} {{- $key := index $label 0 }} {{- $val := "" }} - {{- if eq (len $label) 2 }} - {{- $val = index $label 1 }} + {{- if gt (len $label) 1 }} + {{- $val = join "=" (rest $label) }} {{- end }} - {{- if eq (index $node.metadata.labels $key) $val -}} + {{- if and (hasKey $node.metadata.labels $key) (or (eq $val "") (eq (index $node.metadata.labels $key) $val)) -}} {{- range $address := $node.status.addresses -}} {{- if eq $address.type "InternalIP" -}} {{- $ips = append $ips $address.address -}} @@ -29,6 +29,33 @@ a dry-run/template call and return nothing. {{- end -}} {{- end -}} +{{/* +Render nodeAffinity for master node scheduling. +Uses Exists operator when MASTER_NODES_LABEL has no value or empty value +(matches any value), and In operator when a specific value is given. +Handles "key", "key=value", "key=" and "key=val=ue" formats correctly. +*/}} +{{- define "kubeovn.masterNodeAffinity" -}} +{{- $parts := splitList "=" .Values.MASTER_NODES_LABEL -}} +{{- $key := index $parts 0 -}} +{{- $val := "" -}} +{{- if gt (len $parts) 1 -}} + {{- $val = join "=" (rest $parts) -}} +{{- end -}} +nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: {{ $key }} + {{- if ne $val "" }} + operator: In + values: + - {{ $val | quote }} + {{- else }} + operator: Exists + {{- end }} +{{- end -}} + {{/* Number of master nodes */}} @@ -36,50 +63,284 @@ Number of master nodes {{- len (split "," (.Values.MASTER_NODES | default (include "kubeovn.nodeIPs" .))) }} {{- end -}} +{{/* +Number of Kubernetes nodes, falling back to MASTER_NODES for offline rendering. +*/}} +{{- define "kubeovn.k8sNodeCount" -}} +{{- $nodes := lookup "v1" "Node" "" "" -}} +{{- if and $nodes $nodes.items -}} +{{- len $nodes.items -}} +{{- else -}} +{{- include "kubeovn.nodeCount" . -}} +{{- end -}} +{{- end -}} + +{{/* +Replica count for the ovn-central Deployment. Single mode always uses 1; +cluster mode uses one replica per master node. +*/}} +{{- define "kubeovn.ovnCentralReplicas" -}} +{{- if index .Values "ovn-central" "hcp" "enabled" -}} +{{- index .Values "ovn-central" "hcp" "replicas" -}} +{{- else if eq .Values.OVN_CENTRAL_MODE "single" -}} +1 +{{- else -}} +{{- include "kubeovn.nodeCount" . -}} +{{- end -}} +{{- end -}} + +{{- define "kubeovn.centralNamespace" -}} +{{- if index .Values "ovn-central" "hcp" "enabled" -}} +{{- default .Values.namespace (index .Values "ovn-central" "hcp" "namespace") -}} +{{- else -}} +{{- .Values.namespace -}} +{{- end -}} +{{- end -}} + +{{- define "kubeovn.centralRaftAddresses" -}} +{{- $namespace := include "kubeovn.centralNamespace" . -}} +{{- $addresses := list -}} +{{- range $i := until (int (index .Values "ovn-central" "hcp" "replicas")) -}} +{{- $addresses = append $addresses (printf "ovn-central-%d.ovn-central.%s.svc" $i $namespace) -}} +{{- end -}} +{{- join "," $addresses -}} +{{- end -}} + +{{/* +Environment variables used by the OVN NB/SB database server TLS setup. +*/}} +{{- define "kubeovn.ovnCentralTLSEnv" -}} +- name: ENABLE_SSL + value: {{ .Values.networking.ENABLE_SSL | quote }} +- name: TLS_MIN_VERSION + value: {{ .Values.networking.TLS_MIN_VERSION | quote }} +- name: TLS_MAX_VERSION + value: {{ .Values.networking.TLS_MAX_VERSION | quote }} +- name: TLS_CIPHER_SUITES + value: {{ join "," .Values.networking.TLS_CIPHER_SUITES | quote }} +{{- end -}} + +{{/* +TLS arguments for kube-ovn components that expose HTTPS endpoints. +*/}} +{{- define "kubeovn.componentTLSArgs" -}} +{{- if .Values.networking.TLS_MIN_VERSION }} +- --tls-min-version={{ .Values.networking.TLS_MIN_VERSION }} +{{- end }} +{{- if .Values.networking.TLS_MAX_VERSION }} +- --tls-max-version={{ .Values.networking.TLS_MAX_VERSION }} +{{- end }} +{{- if .Values.networking.TLS_CIPHER_SUITES }} +{{- range .Values.networking.TLS_CIPHER_SUITES }} +- --tls-cipher-suites={{ . }} +{{- end }} +{{- end }} +{{- end -}} + +{{/* +Replica count for the kube-ovn-controller Deployment. +dataPlaneOnly runs against a hosted ovn-central, so cap controller +replicas at two while allowing single-node clusters to run one. +*/}} +{{- define "kubeovn.controllerReplicas" -}} +{{- $override := dig "replicas" nil (index .Values "kube-ovn-controller") -}} +{{- if eq .Values.installMode "dataPlaneOnly" -}} +{{- min 2 (include "kubeovn.k8sNodeCount" . | int) -}} +{{- else if $override -}} +{{ $override }} +{{- else -}} +{{- include "kubeovn.nodeCount" . -}} +{{- end -}} +{{- end -}} + +{{/* +Value of the NODE_IPS / OVN_DB_IPS env variable. + - dataPlaneOnly: invalid; workload components use OVN_NB_ADDR/OVN_SB_ADDR. + - single (control-plane / full): emit empty so start-db.sh takes the + standalone path and clients fall back to Service ClusterIP via the + auto-injected OVN_*_SERVICE_HOST env vars. + - cluster (default raft): emit comma-separated master node IPs. +*/}} +{{- define "kubeovn.ovnCentralNodeIPs" -}} +{{- if index .Values "ovn-central" "hcp" "enabled" -}} +{{- include "kubeovn.centralRaftAddresses" . -}} +{{- else if eq .Values.installMode "dataPlaneOnly" -}} +{{- fail "installMode=dataPlaneOnly uses OVN_NB_ADDR/OVN_SB_ADDR; do not render OVN_DB_IPS" -}} +{{- else if eq .Values.OVN_CENTRAL_MODE "single" -}} +{{- else -}} +{{ .Values.MASTER_NODES | default (include "kubeovn.nodeIPs" .) }} +{{- end -}} +{{- end -}} + +{{- define "kubeovn.externalOvnNbAddress" -}} +{{- $endpoint := required "installMode=dataPlaneOnly requires externalOvnCentral.nbEndpoint" .Values.externalOvnCentral.nbEndpoint -}} +tcp:{{ include "kubeovn.externalOvnHost" $endpoint }}:{{ .Values.externalOvnCentral.nbPort | default 6641 }} +{{- end -}} + +{{- define "kubeovn.externalOvnSbAddress" -}} +{{- $endpoint := required "installMode=dataPlaneOnly requires externalOvnCentral.sbEndpoint" .Values.externalOvnCentral.sbEndpoint -}} +tcp:{{ include "kubeovn.externalOvnHost" $endpoint }}:{{ .Values.externalOvnCentral.sbPort | default 6642 }} +{{- end -}} + +{{- define "kubeovn.externalOvnHost" -}} +{{- if and (contains ":" .) (not (hasPrefix "[" .)) -}} +[{{ . }}] +{{- else -}} +{{ . }} +{{- end -}} +{{- end -}} + +{{- define "kubeovn.ovnNbAddress" -}} +{{- if not (index .Values "ovn-central" "hcp" "nbAddress") -}} +{{- fail "ovn-central.hcp.nbAddress must be set when ovn-central.hcp.enabled is true" -}} +{{- end -}} +{{- index .Values "ovn-central" "hcp" "nbAddress" -}} +{{- end -}} + +{{- define "kubeovn.ovnSbAddress" -}} +{{- if not (index .Values "ovn-central" "hcp" "sbAddress") -}} +{{- fail "ovn-central.hcp.sbAddress must be set when ovn-central.hcp.enabled is true" -}} +{{- end -}} +{{- index .Values "ovn-central" "hcp" "sbAddress" -}} +{{- end -}} + +{{/* +Validate the ovn-central.service block. Currently the only invariant we +enforce is that LoadBalancer service type must come with an explicit +loadBalancerIP, because ovn-nb / ovn-sb / ovn-northd should land on the same +stable VIP when exposed through that Service type. Without it cloud LBs may +allocate three different IPs unexpectedly. Use {{- include "kubeovn.validateService" . }} +anywhere a Service is rendered so the validation runs on every template. +*/}} +{{- define "kubeovn.validateService" -}} +{{- $svc := index .Values "ovn-central" "service" -}} +{{- if eq $svc.type "LoadBalancer" -}} +{{- if not $svc.loadBalancerIP -}} +{{- fail "ovn-central.service.type=LoadBalancer requires ovn-central.service.loadBalancerIP to be set so ovn-nb / ovn-sb / ovn-northd share a stable VIP. Pick a VIP, configure your LB controller to assign it (MetalLB allow-shared-ip annotation is emitted automatically), then re-run helm." -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Port the agents/controller should use to connect to ovn-nb. In dataPlaneOnly +mode this picks up externalOvnCentral.nbPort so NodePort or non-default +LoadBalancer port mappings work. Other modes use the in-cluster Service port +6641. +*/}} +{{- define "kubeovn.ovnNbPort" -}} +{{- if eq .Values.installMode "dataPlaneOnly" -}} +{{ .Values.externalOvnCentral.nbPort | default 6641 }} +{{- else -}} +6641 +{{- end -}} +{{- end -}} + +{{/* +Port the agents/controller should use to connect to ovn-sb. Mirror of +kubeovn.ovnNbPort for the southbound DB. +*/}} +{{- define "kubeovn.ovnSbPort" -}} +{{- if eq .Values.installMode "dataPlaneOnly" -}} +{{ .Values.externalOvnCentral.sbPort | default 6642 }} +{{- else -}} +6642 +{{- end -}} +{{- end -}} + +{{/* +Render gate for control-plane resources (ovn-central + Services + its RBAC). +Emits "true" when this Helm release should render control-plane resources; +empty otherwise. Use with {{- if include "kubeovn.renderControlPlane" . }}. +*/}} +{{- define "kubeovn.renderControlPlane" -}} +{{- if or (eq .Values.installMode "full") (eq .Values.installMode "controlPlaneOnly") -}} +true +{{- end -}} +{{- end -}} + +{{/* +Render gate for data-plane resources (CRDs + kube-ovn-controller + ovs-ovn + +kube-ovn-cni + kube-ovn-pinger + kube-ovn-monitor + their RBAC). +*/}} +{{- define "kubeovn.renderDataPlane" -}} +{{- if or (eq .Values.installMode "full") (eq .Values.installMode "dataPlaneOnly") -}} +true +{{- end -}} +{{- end -}} + +{{/* +Render gate for components that only make sense in a single-cluster install: +- ovn-dpdk DaemonSet (start-ovs-dpdk-v2.sh still talks to OVN_SB_SERVICE_HOST, + no externalOvnCentral support yet) +- pre-upgrade-ovs-ovn / upgrade-ovs-ovn hooks (upgrade-ovs.sh checks a local + deploy/ovn-central, so it fails on tenant-only installs) +Use `kubeovn.renderFullOnly` when the resource is not yet ready for the +split-cluster hosted ovn-central deployment. +*/}} +{{- define "kubeovn.renderFullOnly" -}} +{{- if eq .Values.installMode "full" -}} +true +{{- end -}} +{{- end -}} + +{{/* +Kube-OVN TLS is owned by the management cluster in dataPlaneOnly installs. +Disable local rotation there so a tenant cluster cannot replace the shared CA. +*/}} +{{- define "kubeovn.kubeOVNTLSRotationInterval" -}} +{{- if eq .Values.installMode "dataPlaneOnly" -}} +0 +{{- else -}} +{{ .Values.networking.KUBE_OVN_TLS_ROTATION_INTERVAL }} +{{- end -}} +{{- end -}} + +{{/* +Determine the updateStrategy type for the ovs-ovn DaemonSet. +If ovs-ovn.updateStrategy.type is set, use it directly. +Otherwise, auto-detect based on the currently deployed DaemonSet. +*/}} {{- define "kubeovn.ovs-ovn.updateStrategy" -}} - {{- $ds := lookup "apps/v1" "DaemonSet" $.Values.namespace "ovs-ovn" -}} - {{- if $ds -}} - {{- if eq $ds.spec.updateStrategy.type "RollingUpdate" -}} - RollingUpdate - {{- else -}} - {{- $chartVersion := index $ds.metadata.annotations "chart-version" }} - {{- $newChartVersion := printf "%s-%s" .Chart.Name .Chart.Version }} - {{- $imageVersion := (index $ds.spec.template.spec.containers 0).image | splitList ":" | last | trimPrefix "v" -}} - {{- $versionRegex := `^(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)` -}} - {{- if and (ne $newChartVersion $chartVersion) (regexMatch $versionRegex $imageVersion) -}} - {{- if regexFind $versionRegex $imageVersion | semverCompare ">= 1.12.0" -}} - RollingUpdate + {{- $updateStrategy := index $.Values "ovs-ovn" "updateStrategy" -}} + {{- $desiredStrategy := "" -}} + {{- if $updateStrategy -}} + {{- $desiredStrategy = index $updateStrategy "type" -}} + {{- end -}} + {{- if $desiredStrategy -}} + {{- $desiredStrategy -}} + {{- else -}} + {{- $ds := lookup "apps/v1" "DaemonSet" $.Values.namespace "ovs-ovn" -}} + {{- if $ds -}} + {{- if eq $ds.spec.updateStrategy.type "RollingUpdate" -}} + RollingUpdate + {{- else -}} + {{- $chartVersion := index $ds.metadata.annotations "chart-version" }} + {{- $newChartVersion := printf "%s-%s" .Chart.Name .Chart.Version }} + {{- $imageVersion := (index $ds.spec.template.spec.containers 0).image | splitList ":" | last | trimPrefix "v" -}} + {{- $versionRegex := `^(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)` -}} + {{- if and (ne $newChartVersion $chartVersion) (regexMatch $versionRegex $imageVersion) -}} + {{- if regexFind $versionRegex $imageVersion | semverCompare ">= 1.12.0" -}} + RollingUpdate + {{- else -}} + OnDelete + {{- end -}} {{- else -}} OnDelete {{- end -}} - {{- else -}} - OnDelete {{- end -}} + {{- else -}} + RollingUpdate {{- end -}} - {{- else -}} - RollingUpdate {{- end -}} {{- end -}} -{{- define "kubeovn.ovn.versionCompatibility" -}} +{{- define "kubeovn.ovn.upgradeNeeded" -}} {{- $ds := lookup "apps/v1" "DaemonSet" $.Values.namespace "ovs-ovn" -}} {{- if $ds -}} {{- $chartVersion := index $ds.metadata.annotations "chart-version" }} {{- $newChartVersion := printf "%s-%s" .Chart.Name .Chart.Version }} - {{- $imageVersion := (index $ds.spec.template.spec.containers 0).image | splitList ":" | last | trimPrefix "v" -}} - {{- $versionRegex := `^(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)` -}} - {{- if and (ne $newChartVersion $chartVersion) (regexMatch $versionRegex $imageVersion) -}} - {{- if regexFind $versionRegex $imageVersion | semverCompare ">= 1.15.0" -}} - 25.03 - {{- else if regexFind $versionRegex $imageVersion | semverCompare ">= 1.13.0" -}} - 24.03 - {{- else if regexFind $versionRegex $imageVersion | semverCompare ">= 1.12.0" -}} - 22.12 - {{- else if regexFind $versionRegex $imageVersion | semverCompare ">= 1.11.0" -}} - 22.03 - {{- else -}} - 21.06 - {{- end -}} + {{- if ne $newChartVersion $chartVersion -}} + true {{- end -}} {{- end -}} {{- end -}} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/central-deploy.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/central-deploy.yaml index 1bb0ece45..db3fc161f 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/central-deploy.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/central-deploy.yaml @@ -1,18 +1,55 @@ -kind: Deployment +{{- if include "kubeovn.renderControlPlane" . }} +{{- /* +Guard against in-place mode switches that would silently drop the live OVN +DB. Switching from raft cluster (hostPath /etc/ovn) to single (PVC) leaves +the new pod starting against an empty PVC; reverse direction loses the +PVC-backed DB. Detect the existing Deployment's volume type via `lookup` and +fail with explicit migration instructions if it disagrees with the rendered +OVN_CENTRAL_MODE. `lookup` returns empty during dry-run / template, so this +only fires on a real install/upgrade against a cluster. +*/}} +{{- $existing := lookup "apps/v1" "Deployment" .Values.namespace "ovn-central" }} +{{- if not (index .Values "ovn-central" "hcp" "enabled") }} +{{- if $existing }} + {{- range $existing.spec.template.spec.volumes }} + {{- if eq .name "host-config-ovn" }} + {{- if and (eq $.Values.OVN_CENTRAL_MODE "single") .hostPath }} + {{- fail "Refusing to switch OVN_CENTRAL_MODE in place from raft (hostPath) to single (PVC). The new render would start ovn-central against an empty PVC and lose live OVN state. Migrate explicitly: (1) snapshot the current DB with `bash dist/images/restore-ovn-nb-db.sh` style backup; (2) `helm uninstall` the current release; (3) `helm install` with OVN_CENTRAL_MODE=single onto a fresh namespace or after clearing the existing ovn-central Deployment; (4) restore the snapshot via `bash dist/images/restore-ovn-nb-db.sh single `." }} + {{- end }} + {{- if and (ne $.Values.OVN_CENTRAL_MODE "single") .persistentVolumeClaim }} + {{- fail "Refusing to switch OVN_CENTRAL_MODE in place from single (PVC) to raft (hostPath). The new render would lose the PVC-backed DB. Migrate explicitly: snapshot the DB, helm uninstall, then helm install in the target mode and restore the snapshot." }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} +{{- end }} +kind: {{ ternary "StatefulSet" "Deployment" (index .Values "ovn-central" "hcp" "enabled") }} apiVersion: apps/v1 metadata: name: ovn-central - namespace: {{ .Values.namespace }} + namespace: {{ include "kubeovn.centralNamespace" . }} annotations: kubernetes.io/description: | OVN components: northd, nb and sb. spec: - replicas: {{ include "kubeovn.nodeCount" . }} + replicas: {{ include "kubeovn.ovnCentralReplicas" . }} + {{- if index .Values "ovn-central" "hcp" "enabled" }} + serviceName: ovn-central + podManagementPolicy: Parallel + persistentVolumeClaimRetentionPolicy: + whenDeleted: Delete + whenScaled: Delete + {{- else }} strategy: + {{- if eq .Values.OVN_CENTRAL_MODE "single" }} + type: Recreate + {{- else }} rollingUpdate: maxSurge: 0 maxUnavailable: 1 type: RollingUpdate + {{- end }} + {{- end }} selector: matchLabels: app: ovn-central @@ -24,48 +61,68 @@ spec: type: infra spec: tolerations: - - effect: NoSchedule - operator: Exists - - effect: NoExecute - operator: Exists + {{- with (index .Values "ovn-central" "tolerations") }} + {{- toYaml . | nindent 8 }} + {{- end }} - key: CriticalAddonsOnly operator: Exists affinity: + {{- if or (index .Values "ovn-central" "hcp" "enabled") (ne .Values.OVN_CENTRAL_MODE "single") }} podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchLabels: app: ovn-central topologyKey: kubernetes.io/hostname + {{- end }} + {{- if not (index .Values "ovn-central" "hcp" "enabled") }} + {{- include "kubeovn.masterNodeAffinity" . | nindent 8 }} + {{- end }} priorityClassName: system-cluster-critical - serviceAccountName: ovn-ovs + serviceAccountName: {{ ternary "ovn-central" "ovn-ovs" (index .Values "ovn-central" "hcp" "enabled") }} automountServiceAccountToken: true - hostNetwork: true + hostNetwork: {{ ternary "false" "true" (index .Values "ovn-central" "hcp" "enabled") }} securityContext: seccompProfile: type: RuntimeDefault initContainers: - - name: hostpath-init + - name: {{ ternary "volume-init" "hostpath-init" (index .Values "ovn-central" "hcp" "enabled") }} image: {{ .Values.global.registry.address }}/{{ .Values.global.images.kubeovn.repository }}:{{ .Values.global.images.kubeovn.tag }} imagePullPolicy: {{ .Values.image.pullPolicy }} command: - sh - -c + {{- if index .Values "ovn-central" "hcp" "enabled" }} - "chown -R nobody: /var/run/ovn /etc/ovn /var/log/ovn" + {{- else }} + {{- if eq .Values.OVN_CENTRAL_MODE "single" }} + # /etc/ovn comes from a PVC in single-replica mode. Backends like + # root-squashed NFS reject chown by root, so make the OVN DB + # directory chown best-effort; the OVN containers run as `nobody` + # and will create new files with the correct owner regardless. + - "chown -R nobody: /var/run/ovn /var/log/ovn && (chown -R nobody: /etc/ovn 2>/dev/null || echo 'chown /etc/ovn skipped (likely root-squashed NFS); ovn will write as nobody anyway')" + {{- else }} + - "chown -R nobody: /var/run/ovn /etc/ovn /var/log/ovn" + {{- end }} + {{- end }} securityContext: - allowPrivilegeEscalation: true + allowPrivilegeEscalation: {{ ternary "false" "true" (index .Values "ovn-central" "hcp" "enabled") }} capabilities: + {{- if index .Values "ovn-central" "hcp" "enabled" }} + add: + - CHOWN + {{- end }} drop: - ALL - privileged: true + privileged: {{ ternary "false" "true" (index .Values "ovn-central" "hcp" "enabled") }} runAsUser: 0 volumeMounts: - mountPath: /var/run/ovn - name: host-run-ovn + name: {{ ternary "run-ovn" "host-run-ovn" (index .Values "ovn-central" "hcp" "enabled") }} - mountPath: /etc/ovn - name: host-config-ovn + name: {{ ternary "ovn-data" "host-config-ovn" (index .Values "ovn-central" "hcp" "enabled") }} - mountPath: /var/log/ovn - name: host-log-ovn + name: {{ ternary "log-ovn" "host-log-ovn" (index .Values "ovn-central" "hcp" "enabled") }} containers: - name: ovn-central image: {{ .Values.global.registry.address }}/{{ .Values.global.images.kubeovn.repository }}:{{ .Values.global.images.kubeovn.tag }} @@ -81,14 +138,8 @@ spec: - NET_BIND_SERVICE - SYS_NICE env: - - name: ENABLE_SSL - value: "{{ .Values.networking.ENABLE_SSL }}" - - name: NODE_IPS - value: "{{ .Values.MASTER_NODES | default (include "kubeovn.nodeIPs" .) }}" - - name: POD_IP - valueFrom: - fieldRef: - fieldPath: status.podIP +{{- include "kubeovn.ovnCentralTLSEnv" . | nindent 12 }} + {{- if index .Values "ovn-central" "hcp" "enabled" }} - name: POD_NAME valueFrom: fieldRef: @@ -97,12 +148,37 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace + {{- end }} + - name: NODE_IPS + value: "{{ include "kubeovn.ovnCentralNodeIPs" . }}" + {{- if index .Values "ovn-central" "hcp" "enabled" }} + - name: DB_CLUSTER_ADDR + value: "$(POD_NAME).ovn-central.$(POD_NAMESPACE).svc" + {{- end }} + - name: POD_IP + {{- if index .Values "ovn-central" "hcp" "enabled" }} + value: "$(DB_CLUSTER_ADDR)" + {{- else }} + valueFrom: + fieldRef: + fieldPath: status.podIP + {{- end }} + {{- if not (index .Values "ovn-central" "hcp" "enabled") }} + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + {{- end }} - name: POD_IPS valueFrom: fieldRef: fieldPath: status.podIPs - name: ENABLE_BIND_LOCAL_IP - value: "{{- .Values.func.ENABLE_BIND_LOCAL_IP }}" + value: "{{ ternary false .Values.func.ENABLE_BIND_LOCAL_IP (index .Values "ovn-central" "hcp" "enabled") }}" - name: PROBE_INTERVAL value: "{{ .Values.networking.PROBE_INTERVAL }}" - name: OVN_NORTHD_PROBE_INTERVAL @@ -113,8 +189,6 @@ spec: value: "{{ .Values.networking.OVN_NORTHD_N_THREADS }}" - name: ENABLE_COMPACT value: "{{ .Values.networking.ENABLE_COMPACT }}" - - name: OVN_VERSION_COMPATIBILITY - value: '{{ include "kubeovn.ovn.versionCompatibility" . }}' resources: requests: cpu: {{ index .Values "ovn-central" "requests" "cpu" }} @@ -125,14 +199,16 @@ spec: ephemeral-storage: {{ index .Values "ovn-central" "limits" "ephemeral-storage" }} volumeMounts: - mountPath: /var/run/ovn - name: host-run-ovn + name: {{ ternary "run-ovn" "host-run-ovn" (index .Values "ovn-central" "hcp" "enabled") }} - mountPath: /etc/ovn - name: host-config-ovn + name: {{ ternary "ovn-data" "host-config-ovn" (index .Values "ovn-central" "hcp" "enabled") }} - mountPath: /var/log/ovn - name: host-log-ovn + name: {{ ternary "log-ovn" "host-log-ovn" (index .Values "ovn-central" "hcp" "enabled") }} + {{- if not (index .Values "ovn-central" "hcp" "enabled") }} - mountPath: /etc/localtime name: localtime readOnly: true + {{- end }} - mountPath: /var/run/tls name: kube-ovn-tls readinessProbe: @@ -151,26 +227,56 @@ spec: periodSeconds: 15 failureThreshold: 5 timeoutSeconds: 45 + {{- $nodeSelector := index .Values "ovn-central" "nodeSelector" }} + {{- if $nodeSelector }} nodeSelector: - kubernetes.io/os: "linux" - {{- with splitList "=" .Values.MASTER_NODES_LABEL }} - {{ index . 0 }}: "{{ if eq (len .) 2 }}{{ index . 1 }}{{ end }}" - {{- end }} + {{- toYaml $nodeSelector | nindent 8 }} + {{- end }} volumes: + {{- if index .Values "ovn-central" "hcp" "enabled" }} + - name: run-ovn + emptyDir: {} + - name: log-ovn + emptyDir: {} + {{- else }} - name: host-run-ovn hostPath: path: /run/ovn - name: host-config-ovn + {{- if eq .Values.OVN_CENTRAL_MODE "single" }} + persistentVolumeClaim: + claimName: {{ (index .Values "ovn-central" "storage").existingClaim | default "ovn-central-data" }} + {{- else }} hostPath: path: {{ .Values.OVN_DIR }} + {{- end }} - name: host-log-ovn hostPath: path: {{ .Values.log_conf.LOG_DIR }}/ovn - name: localtime hostPath: path: /etc/localtime + {{- end }} - name: kube-ovn-tls secret: optional: true secretName: kube-ovn-tls + {{- if index .Values "ovn-central" "hcp" "enabled" }} + volumeClaimTemplates: + - metadata: + name: ovn-data + labels: + app: ovn-central + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ index .Values "ovn-central" "hcp" "storage" "size" }} + {{- if index .Values "ovn-central" "hcp" "storage" "storageClassName" }} + storageClassName: {{ index .Values "ovn-central" "hcp" "storage" "storageClassName" | quote }} + {{- end }} + {{- end }} + +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/central-hcp-rbac.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/central-hcp-rbac.yaml new file mode 100644 index 000000000..58dad2baa --- /dev/null +++ b/packages/system/kubeovn/charts/kube-ovn/templates/central-hcp-rbac.yaml @@ -0,0 +1,62 @@ +{{- if include "kubeovn.renderControlPlane" . }} +{{- if index .Values "ovn-central" "hcp" "enabled" }} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: ovn-central + namespace: {{ include "kubeovn.centralNamespace" . }} +automountServiceAccountToken: false +{{- if .Values.global.registry.imagePullSecrets }} +imagePullSecrets: +{{- range $index, $secret := .Values.global.registry.imagePullSecrets }} +{{- if $secret }} + - name: {{ $secret | quote}} +{{- end }} +{{- end }} +{{- end }} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: ovn-central + namespace: {{ include "kubeovn.centralNamespace" . }} +rules: + - apiGroups: + - "" + resources: + - pods + verbs: + - get + - list + - watch + - patch + - apiGroups: + - "" + resources: + - services + verbs: + - get + - apiGroups: + - discovery.k8s.io + resources: + - endpointslices + verbs: + - get + - list + - watch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: ovn-central + namespace: {{ include "kubeovn.centralNamespace" . }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: ovn-central +subjects: + - kind: ServiceAccount + name: ovn-central + namespace: {{ include "kubeovn.centralNamespace" . }} +{{- end }} +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/central-pvc.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/central-pvc.yaml new file mode 100644 index 000000000..4958b8233 --- /dev/null +++ b/packages/system/kubeovn/charts/kube-ovn/templates/central-pvc.yaml @@ -0,0 +1,36 @@ +{{- if include "kubeovn.renderControlPlane" . }} +{{- if eq .Values.OVN_CENTRAL_MODE "single" }} +{{- $storage := index .Values "ovn-central" "storage" }} +{{- /* +PVC for the standalone OVN DB. Always created in single-replica mode because +the Deployment unconditionally mounts a PVC claim. Set +ovn-central.storage.existingClaim= to point the Deployment at an +externally-managed claim and skip in-chart PVC creation. +*/ -}} +{{- if not $storage.existingClaim }} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: ovn-central-data + namespace: {{ .Values.namespace }} + annotations: + # Pin the PVC so an installMode switch (e.g. full -> dataPlaneOnly) that + # stops rendering this template does NOT delete the volume holding the + # standalone OVN DB. Operators can `kubectl delete pvc ovn-central-data` + # explicitly when they really mean to discard the DB. + helm.sh/resource-policy: keep + kubernetes.io/description: | + Persistent storage for the ovn-central standalone OVN DB files. +spec: + accessModes: +{{ toYaml $storage.accessModes | indent 4 }} + resources: + requests: + storage: {{ $storage.size }} + {{- with $storage.storageClassName }} + storageClassName: {{ . | quote }} + {{- end }} +{{- end }} +{{- end }} + +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/central-svc.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/central-svc.yaml new file mode 100644 index 000000000..88d8b0c68 --- /dev/null +++ b/packages/system/kubeovn/charts/kube-ovn/templates/central-svc.yaml @@ -0,0 +1,23 @@ +{{- if include "kubeovn.renderControlPlane" . }} +{{- if index .Values "ovn-central" "hcp" "enabled" }} +kind: Service +apiVersion: v1 +metadata: + name: ovn-central + namespace: {{ include "kubeovn.centralNamespace" . }} +spec: + clusterIP: None + publishNotReadyAddresses: true + ports: + - name: nb-raft + protocol: TCP + port: 6643 + targetPort: 6643 + - name: sb-raft + protocol: TCP + port: 6644 + targetPort: 6644 + selector: + app: ovn-central +{{- end }} +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/controller-deploy.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/controller-deploy.yaml index 69e27b23a..86f98f8a7 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/controller-deploy.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/controller-deploy.yaml @@ -1,3 +1,4 @@ +{{- if include "kubeovn.renderDataPlane" . }} kind: Deployment apiVersion: apps/v1 metadata: @@ -7,7 +8,7 @@ metadata: kubernetes.io/description: | kube-ovn controller spec: - replicas: {{ include "kubeovn.nodeCount" . }} + replicas: {{ include "kubeovn.controllerReplicas" . }} selector: matchLabels: app: kube-ovn-controller @@ -75,6 +76,15 @@ spec: imagePullPolicy: {{ .Values.image.pullPolicy }} args: - /kube-ovn/start-controller.sh + {{- if (index .Values "kube-ovn-controller" "leaderElection" "leaseDuration") }} + - --leader-elect-lease-duration={{ index .Values "kube-ovn-controller" "leaderElection" "leaseDuration" }} + {{- end }} + {{- if (index .Values "kube-ovn-controller" "leaderElection" "renewDeadline") }} + - --leader-elect-renew-deadline={{ index .Values "kube-ovn-controller" "leaderElection" "renewDeadline" }} + {{- end }} + {{- if (index .Values "kube-ovn-controller" "leaderElection" "retryPeriod") }} + - --leader-elect-retry-period={{ index .Values "kube-ovn-controller" "leaderElection" "retryPeriod" }} + {{- end }} - --default-ls={{ .Values.networking.DEFAULT_SUBNET }} - --default-cidr= {{- if eq .Values.networking.NET_STACK "dual_stack" -}} @@ -127,6 +137,12 @@ spec: - --enable-np={{- .Values.func.ENABLE_NP }} - --np-enforcement={{- .Values.func.NP_ENFORCEMENT }} - --enable-eip-snat={{- .Values.networking.ENABLE_EIP_SNAT }} + {{- if .Values.networking.EXTERNAL_GATEWAY_CONFIG_NS }} + - --external-gateway-config-ns={{- .Values.networking.EXTERNAL_GATEWAY_CONFIG_NS }} + {{- end }} + {{- if .Values.networking.EXTERNAL_GATEWAY_SWITCH }} + - --external-gateway-switch={{- .Values.networking.EXTERNAL_GATEWAY_SWITCH }} + {{- end }} - --enable-external-vpc={{- .Values.func.ENABLE_EXTERNAL_VPC }} - --enable-ecmp={{- .Values.networking.ENABLE_ECMP }} - --logtostderr=false @@ -140,6 +156,9 @@ spec: - --enable-metrics={{- .Values.networking.ENABLE_METRICS }} - --node-local-dns-ip={{- .Values.networking.NODE_LOCAL_DNS_IP }} - --secure-serving={{- .Values.func.SECURE_SERVING }} + {{- if or .Values.networking.TLS_MIN_VERSION .Values.networking.TLS_MAX_VERSION .Values.networking.TLS_CIPHER_SUITES }} + {{- include "kubeovn.componentTLSArgs" . | nindent 10 }} + {{- end }} - --enable-ovn-ipsec={{- .Values.func.ENABLE_OVN_IPSEC }} - --enable-anp={{- .Values.func.ENABLE_ANP }} - --enable-dns-name-resolver={{- .Values.func.ENABLE_DNS_NAME_RESOLVER }} @@ -160,6 +179,8 @@ spec: env: - name: ENABLE_SSL value: "{{ .Values.networking.ENABLE_SSL }}" + - name: KUBE_OVN_TLS_ROTATION_INTERVAL + value: "{{ include "kubeovn.kubeOVNTLSRotationInterval" . }}" - name: POD_NAME valueFrom: fieldRef: @@ -172,8 +193,24 @@ spec: valueFrom: fieldRef: fieldPath: spec.nodeName + {{- if index .Values "ovn-central" "hcp" "enabled" }} + - name: OVN_NB_ADDR + value: "{{ include "kubeovn.ovnNbAddress" . }}" + - name: OVN_SB_ADDR + value: "{{ include "kubeovn.ovnSbAddress" . }}" + {{- else if eq .Values.installMode "dataPlaneOnly" }} + - name: OVN_NB_ADDR + value: "{{ include "kubeovn.externalOvnNbAddress" . }}" + - name: OVN_SB_ADDR + value: "{{ include "kubeovn.externalOvnSbAddress" . }}" + {{- else }} - name: OVN_DB_IPS - value: "{{ .Values.MASTER_NODES | default (include "kubeovn.nodeIPs" .) }}" + value: "{{ include "kubeovn.ovnCentralNodeIPs" . }}" + - name: KUBE_OVN_NB_PORT + value: "{{ include "kubeovn.ovnNbPort" . }}" + - name: KUBE_OVN_SB_PORT + value: "{{ include "kubeovn.ovnSbPort" . }}" + {{- end }} - name: POD_IP valueFrom: fieldRef: @@ -235,3 +272,5 @@ spec: secret: optional: true secretName: kube-ovn-tls + +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/controller-svc.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/controller-svc.yaml index b4d39619d..2cf0ae3e1 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/controller-svc.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/controller-svc.yaml @@ -1,3 +1,4 @@ +{{- if include "kubeovn.renderDataPlane" . }} kind: Service apiVersion: v1 metadata: @@ -14,3 +15,5 @@ spec: {{- if eq .Values.networking.NET_STACK "dual_stack" }} ipFamilyPolicy: PreferDualStack {{- end }} + +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/ic-controller-deploy.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/ic-controller-deploy.yaml index dc932a633..106624bad 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/ic-controller-deploy.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/ic-controller-deploy.yaml @@ -1,3 +1,4 @@ +{{- if include "kubeovn.renderDataPlane" . }} {{- if .Values.func.ENABLE_IC }} kind: Deployment apiVersion: apps/v1 @@ -91,8 +92,24 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace + {{- if index .Values "ovn-central" "hcp" "enabled" }} + - name: OVN_NB_ADDR + value: "{{ include "kubeovn.ovnNbAddress" . }}" + - name: OVN_SB_ADDR + value: "{{ include "kubeovn.ovnSbAddress" . }}" + {{- else if eq .Values.installMode "dataPlaneOnly" }} + - name: OVN_NB_ADDR + value: "{{ include "kubeovn.externalOvnNbAddress" . }}" + - name: OVN_SB_ADDR + value: "{{ include "kubeovn.externalOvnSbAddress" . }}" + {{- else }} - name: OVN_DB_IPS - value: "{{ .Values.MASTER_NODES | default (include "kubeovn.nodeIPs" .) }}" + value: "{{ include "kubeovn.ovnCentralNodeIPs" . }}" + - name: KUBE_OVN_NB_PORT + value: "{{ include "kubeovn.ovnNbPort" . }}" + - name: KUBE_OVN_SB_PORT + value: "{{ include "kubeovn.ovnSbPort" . }}" + {{- end }} resources: requests: cpu: 300m @@ -135,3 +152,5 @@ spec: optional: true secretName: kube-ovn-tls {{- end }} + +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/kube-ovn-crd.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/kube-ovn-crd.yaml index 62ae328e4..a7f8f8781 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/kube-ovn-crd.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/kube-ovn-crd.yaml @@ -1,3 +1,4 @@ +{{- if include "kubeovn.renderDataPlane" . }} apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -1414,16 +1415,24 @@ spec: type: object bandwidth: type: object - description: Optional bandwidth limit for each egress gateway instance in both ingress and egress directions. + description: |- + Optional bandwidth limit for each egress gateway instance in both ingress and egress directions. + If not specified, there will be no bandwidth limit. properties: ingress: - type: integer - format: int64 - description: ingress bandwidth limit in Mbps + description: ingress bandwidth limit, specified as an integer in Mbps or a Kubernetes quantity such as 100M or 1Gi in bits per second + pattern: ^([0-9]+|([0-9]+(\.[0-9]+)?|\.[0-9]+)(M|Mi|G|Gi))$ + x-kubernetes-int-or-string: true + x-kubernetes-validations: + - message: integer bandwidth must be between 0 and 9223372036854 Mbps + rule: 'type(self) == int ? self >= 0 && self <= 9223372036854 : true' egress: - type: integer - format: int64 - description: egress bandwidth limit in Mbps + description: egress bandwidth limit, specified as an integer in Mbps or a Kubernetes quantity such as 100M or 1Gi in bits per second + pattern: ^([0-9]+|([0-9]+(\.[0-9]+)?|\.[0-9]+)(M|Mi|G|Gi))$ + x-kubernetes-int-or-string: true + x-kubernetes-validations: + - message: integer bandwidth must be between 0 and 9223372036854 Mbps + rule: 'type(self) == int ? self >= 0 && self <= 9223372036854 : true' --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition @@ -3095,6 +3104,13 @@ spec: type: string dstIPs: type: string + u2oFeatures: + description: Feature configurations for underlay to overlay interconnection. + properties: + overlayOnlyRouting: + description: OverlayOnlyRouting controls whether only overlay CIDRs use U2O routing. + type: boolean + type: object u2oInterconnection: description: Enable underlay to overlay interconnection. type: boolean @@ -3773,3 +3789,4 @@ spec: x-kubernetes-list-map-keys: - name x-kubernetes-list-type: map +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/monitor-deploy.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/monitor-deploy.yaml index 2d4980981..35d327b10 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/monitor-deploy.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/monitor-deploy.yaml @@ -1,3 +1,4 @@ +{{- if include "kubeovn.renderFullOnly" . }} kind: Deployment apiVersion: apps/v1 metadata: @@ -67,6 +68,9 @@ spec: command: ["/kube-ovn/start-ovn-monitor.sh"] args: - --secure-serving={{- .Values.func.SECURE_SERVING }} + {{- if or .Values.networking.TLS_MIN_VERSION .Values.networking.TLS_MAX_VERSION .Values.networking.TLS_CIPHER_SUITES }} + {{- include "kubeovn.componentTLSArgs" . | nindent 10 }} + {{- end }} - --log_file=/var/log/kube-ovn/kube-ovn-monitor.log - --logtostderr=false - --alsologtostderr=true @@ -171,3 +175,5 @@ spec: - name: kube-ovn-log hostPath: path: {{ .Values.log_conf.LOG_DIR }}/kube-ovn + +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/monitor-svc.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/monitor-svc.yaml index 1ad1800d8..b9fd6f6f4 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/monitor-svc.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/monitor-svc.yaml @@ -1,3 +1,4 @@ +{{- if include "kubeovn.renderFullOnly" . }} kind: Service apiVersion: v1 metadata: @@ -16,3 +17,5 @@ spec: {{- if eq .Values.networking.NET_STACK "dual_stack" }} ipFamilyPolicy: PreferDualStack {{- end }} + +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/nb-svc.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/nb-svc.yaml index 43992e91c..08290ebaf 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/nb-svc.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/nb-svc.yaml @@ -1,19 +1,48 @@ +{{- if include "kubeovn.renderControlPlane" . }} +{{- $svc := index .Values "ovn-central" "service" }} +{{- $hcp := index .Values "ovn-central" "hcp" }} +{{- $hcpSvc := index .Values "ovn-central" "hcp" "service" }} +{{- if not $hcp.enabled }} +{{- include "kubeovn.validateService" . }} +{{- end }} kind: Service apiVersion: v1 metadata: name: ovn-nb - namespace: {{ .Values.namespace }} + namespace: {{ include "kubeovn.centralNamespace" . }} + {{- if and (not $hcp.enabled) (eq $svc.type "LoadBalancer") $svc.loadBalancerIP }} + annotations: + # MetalLB allows multiple Services to share a single VIP only when they + # carry the same allow-shared-ip annotation. The three ovn-* Services all + # opt into the same group so a Kamaji-style data plane can dial nb / sb / + # northd on one VIP, distinguished only by port. Harmless on non-MetalLB + # load balancers; remove the annotation if your provider rejects it. + metallb.universe.tf/allow-shared-ip: kube-ovn-central + {{- end }} spec: ports: - name: ovn-nb protocol: TCP port: 6641 targetPort: 6641 - type: ClusterIP + {{- if and $hcp.enabled (or (eq $hcpSvc.type "NodePort") (eq $hcpSvc.type "LoadBalancer")) }} + nodePort: {{ $hcpSvc.nbNodePort }} + {{- end }} + type: {{ ternary ($hcpSvc.type | default "ClusterIP") ($svc.type | default "ClusterIP") $hcp.enabled }} + {{- if and (not $hcp.enabled) (eq $svc.type "LoadBalancer") $svc.loadBalancerIP }} + loadBalancerIP: {{ $svc.loadBalancerIP | quote }} + {{- end }} + {{- if and (not $hcp.enabled) (or (eq $svc.type "LoadBalancer") (eq $svc.type "NodePort")) $svc.externalTrafficPolicy }} + externalTrafficPolicy: {{ $svc.externalTrafficPolicy }} + {{- end }} {{- if eq .Values.networking.NET_STACK "dual_stack" }} ipFamilyPolicy: PreferDualStack {{- end }} selector: app: ovn-central + {{- if or $hcp.enabled (ne .Values.OVN_CENTRAL_MODE "single") }} ovn-nb-leader: "true" + {{- end }} sessionAffinity: None + +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/northd-svc.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/northd-svc.yaml index cec072330..2568cdfab 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/northd-svc.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/northd-svc.yaml @@ -1,19 +1,39 @@ +{{- if include "kubeovn.renderControlPlane" . }} +{{- $svc := index .Values "ovn-central" "service" }} +{{- $hcp := index .Values "ovn-central" "hcp" }} +{{- if not $hcp.enabled }} +{{- include "kubeovn.validateService" . }} +{{- end }} kind: Service apiVersion: v1 metadata: name: ovn-northd - namespace: {{ .Values.namespace }} + namespace: {{ include "kubeovn.centralNamespace" . }} + {{- if and (not $hcp.enabled) (eq $svc.type "LoadBalancer") $svc.loadBalancerIP }} + annotations: + metallb.universe.tf/allow-shared-ip: kube-ovn-central + {{- end }} spec: ports: - name: ovn-northd protocol: TCP port: 6643 targetPort: 6643 - type: ClusterIP + type: {{ ternary "ClusterIP" ($svc.type | default "ClusterIP") $hcp.enabled }} + {{- if and (not $hcp.enabled) (eq $svc.type "LoadBalancer") $svc.loadBalancerIP }} + loadBalancerIP: {{ $svc.loadBalancerIP | quote }} + {{- end }} + {{- if and (not $hcp.enabled) (or (eq $svc.type "LoadBalancer") (eq $svc.type "NodePort")) $svc.externalTrafficPolicy }} + externalTrafficPolicy: {{ $svc.externalTrafficPolicy }} + {{- end }} {{- if eq .Values.networking.NET_STACK "dual_stack" }} ipFamilyPolicy: PreferDualStack {{- end }} selector: app: ovn-central + {{- if or $hcp.enabled (ne .Values.OVN_CENTRAL_MODE "single") }} ovn-northd-leader: "true" + {{- end }} sessionAffinity: None + +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/ovn-CR.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/ovn-CR.yaml index 1caaecdf6..237718c06 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/ovn-CR.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/ovn-CR.yaml @@ -1,3 +1,11 @@ +{{- /* +ClusterRoles / Role partitioned by installMode: +- system:ovn : data plane (kube-ovn-controller, ic-controller) +- system:ovn-ovs : both planes (ovn-central in mgmt, ovs-ovn in tenant) +- system:kube-ovn-cni : data plane +- secret-reader-ovn-ipsec / system:kube-ovn-app : data plane +*/}} +{{- if include "kubeovn.renderDataPlane" . }} --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole @@ -153,6 +161,14 @@ rules: - get - list - watch + - apiGroups: + - metallb.io + resources: + - servicel2statuses + verbs: + - get + - list + - watch - apiGroups: - apps resources: @@ -234,6 +250,14 @@ rules: verbs: - get - create + - apiGroups: + - "" + resources: + - secrets + resourceNames: + - kube-ovn-tls + verbs: + - update - apiGroups: - certificates.k8s.io resourceNames: @@ -257,6 +281,7 @@ rules: - customresourcedefinitions verbs: - get +{{- end }} --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole @@ -291,6 +316,7 @@ rules: verbs: - get - list +{{- if include "kubeovn.renderDataPlane" . }} --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole @@ -420,3 +446,4 @@ rules: - subjectaccessreviews verbs: - create +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/ovn-CRB.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/ovn-CRB.yaml index 638093bac..b3e0866ef 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/ovn-CRB.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/ovn-CRB.yaml @@ -1,3 +1,11 @@ +{{- /* +ClusterRoleBindings / RoleBindings partitioned by installMode: +- ovn : data plane (kube-ovn-controller, ic-controller) +- ovn-ovs : both planes (ovn-central in mgmt, ovs-ovn in tenant) +- kube-ovn-cni : data plane +- kube-ovn-app : data plane +*/}} +{{- if include "kubeovn.renderDataPlane" . }} apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: @@ -25,6 +33,7 @@ subjects: name: ovn namespace: {{ .Values.namespace }} --- +{{- end }} apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: @@ -38,6 +47,7 @@ subjects: name: ovn-ovs namespace: {{ .Values.namespace }} +{{- if include "kubeovn.renderDataPlane" . }} --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding @@ -106,3 +116,4 @@ subjects: - kind: ServiceAccount name: kube-ovn-app namespace: {{ .Values.namespace }} +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/ovn-dpdk-ds.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/ovn-dpdk-ds.yaml index 5e18230e1..9cba0c51f 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/ovn-dpdk-ds.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/ovn-dpdk-ds.yaml @@ -1,3 +1,4 @@ +{{- if include "kubeovn.renderFullOnly" . }} {{- if .Values.HYBRID_DPDK }} kind: DaemonSet apiVersion: apps/v1 @@ -58,8 +59,16 @@ spec: valueFrom: fieldRef: fieldPath: spec.nodeName + {{- if index .Values "ovn-central" "hcp" "enabled" }} + - name: OVN_SB_ADDR + value: "{{ include "kubeovn.ovnSbAddress" . }}" + {{- else if eq .Values.installMode "dataPlaneOnly" }} + - name: OVN_SB_ADDR + value: "{{ include "kubeovn.externalOvnSbAddress" . }}" + {{- else }} - name: OVN_DB_IPS value: "{{ .Values.MASTER_NODES | default (include "kubeovn.nodeIPs" .) }}" + {{- end }} - name: OVN_REMOTE_PROBE_INTERVAL value: "{{ .Values.networking.OVN_REMOTE_PROBE_INTERVAL }}" - name: OVN_REMOTE_OPENFLOW_INTERVAL @@ -165,3 +174,5 @@ spec: optional: true secretName: kube-ovn-tls {{- end }} + +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/ovn-sa.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/ovn-sa.yaml index 744b3b90b..08505c909 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/ovn-sa.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/ovn-sa.yaml @@ -1,3 +1,11 @@ +{{- /* +ServiceAccounts. Partitioned by installMode: +- ovn : used by kube-ovn-controller / ic-controller → data plane +- ovn-ovs : used by ovn-central AND ovs-ovn → both planes +- kube-ovn-cni : used by kube-ovn-cni DaemonSet → data plane +- kube-ovn-app : used by kube-ovn-monitor / kube-ovn-pinger → data plane +*/}} +{{- if include "kubeovn.renderDataPlane" . }} apiVersion: v1 kind: ServiceAccount metadata: @@ -14,6 +22,7 @@ imagePullSecrets: {{- end }} --- +{{- end }} apiVersion: v1 kind: ServiceAccount metadata: @@ -29,6 +38,7 @@ imagePullSecrets: {{- end }} {{- end }} +{{- if include "kubeovn.renderDataPlane" . }} --- apiVersion: v1 kind: ServiceAccount @@ -60,3 +70,4 @@ imagePullSecrets: {{- end }} {{- end }} {{- end }} +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/ovn-tls-secret.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/ovn-tls-secret.yaml index dde402039..06ff0f59d 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/ovn-tls-secret.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/ovn-tls-secret.yaml @@ -1,4 +1,16 @@ {{- if .Values.networking.ENABLE_SSL }} +{{- $existingSecret := lookup "v1" "Secret" .Values.namespace "kube-ovn-tls" }} +{{- if eq .Values.installMode "dataPlaneOnly" }} + {{- if not $existingSecret }} + {{- fail (printf "installMode=dataPlaneOnly with networking.ENABLE_SSL=true requires the kube-ovn-tls Secret in namespace %q to be pre-seeded with the SAME CA/cert/key as the management cluster's ovn-central. Self-signing locally would produce certs the management cluster does not trust, breaking every NB/SB connection. Sync the Secret from the mgmt cluster (kubectl get secret kube-ovn-tls -o yaml | kubectl --context=tenant apply -f -) and re-run helm." .Values.namespace) }} + {{- end }} + {{- /* + Intentionally do NOT render the Secret manifest in dataPlaneOnly: the + operator owns its lifecycle (out-of-band sync from the management + cluster). Rendering it here would make Helm try to create or adopt the + pre-seeded Secret and fail with "resource already exists". + */ -}} +{{- else }} {{- $cn := "ovn" -}} {{- $ca := genCA "ovn-ca" 3650 -}} --- @@ -8,7 +20,6 @@ metadata: name: kube-ovn-tls namespace: {{ .Values.namespace }} data: -{{- $existingSecret := lookup "v1" "Secret" .Values.namespace "kube-ovn-tls" }} {{- if $existingSecret }} cacert: {{ index $existingSecret.data "cacert" }} cert: {{ index $existingSecret.data "cert" }} @@ -21,3 +32,4 @@ data: {{- end }} {{- end }} {{- end }} +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/ovncni-ds.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/ovncni-ds.yaml index 06971d014..66d96097d 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/ovncni-ds.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/ovncni-ds.yaml @@ -1,3 +1,4 @@ +{{- if include "kubeovn.renderDataPlane" . }} kind: DaemonSet apiVersion: apps/v1 metadata: @@ -123,6 +124,9 @@ spec: - --enable-tproxy={{ .Values.func.ENABLE_TPROXY }} - --ovs-vsctl-concurrency={{ .Values.performance.OVS_VSCTL_CONCURRENCY }} - --secure-serving={{- .Values.func.SECURE_SERVING }} + {{- if or .Values.networking.TLS_MIN_VERSION .Values.networking.TLS_MAX_VERSION .Values.networking.TLS_CIPHER_SUITES }} + {{- include "kubeovn.componentTLSArgs" . | nindent 10 }} + {{- end }} - --enable-ovn-ipsec={{- .Values.func.ENABLE_OVN_IPSEC }} - --set-vxlan-tx-off={{- .Values.func.SET_VXLAN_TX_OFF }} - --non-primary-cni-mode={{- .Values.cni_conf.NON_PRIMARY_CNI }} @@ -290,3 +294,5 @@ spec: hostPath: path: {{ .Values.OVN_IPSEC_KEY_DIR }} {{- end }} + +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/ovncni-svc.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/ovncni-svc.yaml index e1c47c806..122589fcb 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/ovncni-svc.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/ovncni-svc.yaml @@ -1,3 +1,4 @@ +{{- if include "kubeovn.renderDataPlane" . }} kind: Service apiVersion: v1 metadata: @@ -14,3 +15,5 @@ spec: {{- if eq .Values.networking.NET_STACK "dual_stack" }} ipFamilyPolicy: PreferDualStack {{- end }} + +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/ovsovn-ds.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/ovsovn-ds.yaml index b15fd24e2..2d59d955f 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/ovsovn-ds.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/ovsovn-ds.yaml @@ -1,3 +1,4 @@ +{{- if include "kubeovn.renderDataPlane" . }} kind: DaemonSet apiVersion: apps/v1 metadata: @@ -11,11 +12,14 @@ spec: selector: matchLabels: app: ovs + {{- $updateStrategyType := include "kubeovn.ovs-ovn.updateStrategy" . | trim }} updateStrategy: - type: {{ include "kubeovn.ovs-ovn.updateStrategy" . }} + type: {{ $updateStrategyType }} + {{- if eq $updateStrategyType "RollingUpdate" }} rollingUpdate: maxSurge: 1 maxUnavailable: 0 + {{- end }} template: metadata: labels: @@ -119,8 +123,18 @@ spec: valueFrom: fieldRef: fieldPath: spec.nodeName + {{- if index .Values "ovn-central" "hcp" "enabled" }} + - name: OVN_SB_ADDR + value: "{{ include "kubeovn.ovnSbAddress" . }}" + {{- else if eq .Values.installMode "dataPlaneOnly" }} + - name: OVN_SB_ADDR + value: "{{ include "kubeovn.externalOvnSbAddress" . }}" + {{- else }} - name: OVN_DB_IPS - value: "{{ .Values.MASTER_NODES | default (include "kubeovn.nodeIPs" .) }}" + value: "{{ include "kubeovn.ovnCentralNodeIPs" . }}" + - name: KUBE_OVN_SB_PORT + value: "{{ include "kubeovn.ovnSbPort" . }}" + {{- end }} - name: OVN_REMOTE_PROBE_INTERVAL value: "{{ .Values.networking.OVN_REMOTE_PROBE_INTERVAL }}" - name: OVN_REMOTE_OPENFLOW_INTERVAL @@ -207,3 +221,5 @@ spec: - hostPath: path: /var/run/containerd name: cruntime + +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/pinger-ds.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/pinger-ds.yaml index e52cf45df..55d5b13c4 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/pinger-ds.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/pinger-ds.yaml @@ -1,3 +1,4 @@ +{{- if include "kubeovn.renderDataPlane" . }} kind: DaemonSet apiVersion: apps/v1 metadata: @@ -177,3 +178,5 @@ spec: secret: optional: true secretName: kube-ovn-tls + +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/pinger-svc.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/pinger-svc.yaml index ef169e8e9..4b4378822 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/pinger-svc.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/pinger-svc.yaml @@ -1,3 +1,4 @@ +{{- if include "kubeovn.renderDataPlane" . }} kind: Service apiVersion: v1 metadata: @@ -14,3 +15,5 @@ spec: {{- if eq .Values.networking.NET_STACK "dual_stack" }} ipFamilyPolicy: PreferDualStack {{- end }} + +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/post-delete-hook.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/post-delete-hook.yaml index 1272257fd..35acf981b 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/post-delete-hook.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/post-delete-hook.yaml @@ -1,3 +1,4 @@ +{{- if include "kubeovn.renderDataPlane" . }} apiVersion: v1 kind: ServiceAccount metadata: @@ -119,7 +120,10 @@ spec: command: - sh - -c - - /kube-ovn/remove-finalizer.sh 2>&1 | tee -a /var/log/kube-ovn/remove-finalizer.log + - | + touch /var/log/kube-ovn/remove-finalizer.log + chmod 640 /var/log/kube-ovn/remove-finalizer.log + /kube-ovn/remove-finalizer.sh 2>&1 | tee -a /var/log/kube-ovn/remove-finalizer.log resources: requests: cpu: 100m @@ -135,3 +139,5 @@ spec: - name: kube-ovn-log hostPath: path: {{ .Values.log_conf.LOG_DIR }}/kube-ovn + +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/pre-upgrade-ovs-ovn.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/pre-upgrade-ovs-ovn.yaml index a18a41115..f28e4da4d 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/pre-upgrade-ovs-ovn.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/pre-upgrade-ovs-ovn.yaml @@ -1,4 +1,5 @@ -{{- if include "kubeovn.ovn.versionCompatibility" . -}} +{{- if include "kubeovn.renderFullOnly" . }} +{{- if include "kubeovn.ovn.upgradeNeeded" . -}} --- apiVersion: v1 kind: ServiceAccount @@ -118,7 +119,10 @@ spec: - -eo - pipefail - -c - - bash /kube-ovn/pre-upgrade-ovs.sh 2>&1 | tee -a /var/log/kube-ovn/pre-upgrade-ovs.log + - | + touch /var/log/kube-ovn/pre-upgrade-ovs.log + chmod 640 /var/log/kube-ovn/pre-upgrade-ovs.log + bash /kube-ovn/pre-upgrade-ovs.sh 2>&1 | tee -a /var/log/kube-ovn/pre-upgrade-ovs.log volumeMounts: - mountPath: /var/log/kube-ovn name: kube-ovn-log @@ -127,3 +131,5 @@ spec: hostPath: path: {{ .Values.log_conf.LOG_DIR }}/kube-ovn {{- end -}} + +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/sb-svc.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/sb-svc.yaml index 36a4a27ab..3033fe441 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/sb-svc.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/sb-svc.yaml @@ -1,19 +1,43 @@ +{{- if include "kubeovn.renderControlPlane" . }} +{{- $svc := index .Values "ovn-central" "service" }} +{{- $hcp := index .Values "ovn-central" "hcp" }} +{{- $hcpSvc := index .Values "ovn-central" "hcp" "service" }} +{{- if not $hcp.enabled }} +{{- include "kubeovn.validateService" . }} +{{- end }} kind: Service apiVersion: v1 metadata: name: ovn-sb - namespace: {{ .Values.namespace }} + namespace: {{ include "kubeovn.centralNamespace" . }} + {{- if and (not $hcp.enabled) (eq $svc.type "LoadBalancer") $svc.loadBalancerIP }} + annotations: + metallb.universe.tf/allow-shared-ip: kube-ovn-central + {{- end }} spec: ports: - name: ovn-sb protocol: TCP port: 6642 targetPort: 6642 - type: ClusterIP + {{- if and $hcp.enabled (or (eq $hcpSvc.type "NodePort") (eq $hcpSvc.type "LoadBalancer")) }} + nodePort: {{ $hcpSvc.sbNodePort }} + {{- end }} + type: {{ ternary ($hcpSvc.type | default "ClusterIP") ($svc.type | default "ClusterIP") $hcp.enabled }} + {{- if and (not $hcp.enabled) (eq $svc.type "LoadBalancer") $svc.loadBalancerIP }} + loadBalancerIP: {{ $svc.loadBalancerIP | quote }} + {{- end }} + {{- if and (not $hcp.enabled) (or (eq $svc.type "LoadBalancer") (eq $svc.type "NodePort")) $svc.externalTrafficPolicy }} + externalTrafficPolicy: {{ $svc.externalTrafficPolicy }} + {{- end }} {{- if eq .Values.networking.NET_STACK "dual_stack" }} ipFamilyPolicy: PreferDualStack {{- end }} selector: app: ovn-central + {{- if or $hcp.enabled (ne .Values.OVN_CENTRAL_MODE "single") }} ovn-sb-leader: "true" + {{- end }} sessionAffinity: None + +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/upgrade-ovs-ovn.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/upgrade-ovs-ovn.yaml index b85ce8faa..b93168a00 100644 --- a/packages/system/kubeovn/charts/kube-ovn/templates/upgrade-ovs-ovn.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/upgrade-ovs-ovn.yaml @@ -1,4 +1,5 @@ -{{- if include "kubeovn.ovn.versionCompatibility" . -}} +{{- if include "kubeovn.renderFullOnly" . }} +{{- if include "kubeovn.ovn.upgradeNeeded" . -}} --- apiVersion: v1 kind: ServiceAccount @@ -149,18 +150,15 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - - name: ENABLE_SSL - value: "{{ .Values.networking.ENABLE_SSL }}" - - name: OVN_DB_IPS - value: "{{ .Values.MASTER_NODES | default (include "kubeovn.nodeIPs" .) }}" - - name: OVN_VERSION_COMPATIBILITY - value: '{{ include "kubeovn.ovn.versionCompatibility" . }}' command: - bash - -eo - pipefail - -c - - /kube-ovn/upgrade-ovs.sh 2>&1 | tee -a /var/log/kube-ovn/upgrade-ovs.log + - | + touch /var/log/kube-ovn/upgrade-ovs.log + chmod 640 /var/log/kube-ovn/upgrade-ovs.log + /kube-ovn/upgrade-ovs.sh 2>&1 | tee -a /var/log/kube-ovn/upgrade-ovs.log volumeMounts: - mountPath: /var/log/kube-ovn name: kube-ovn-log @@ -175,3 +173,5 @@ spec: optional: true secretName: kube-ovn-tls {{- end -}} + +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/templates/vpc-nat-config.yaml b/packages/system/kubeovn/charts/kube-ovn/templates/vpc-nat-config.yaml old mode 100755 new mode 100644 index 92e2fd948..b0b7dc511 --- a/packages/system/kubeovn/charts/kube-ovn/templates/vpc-nat-config.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/templates/vpc-nat-config.yaml @@ -1,3 +1,4 @@ +{{- if include "kubeovn.renderDataPlane" . }} kind: ConfigMap apiVersion: v1 metadata: @@ -17,3 +18,5 @@ metadata: namespace: {{ .Values.namespace }} data: enable-vpc-nat-gw: "{{ .Values.func.ENABLE_NAT_GW }}" + +{{- end }} diff --git a/packages/system/kubeovn/charts/kube-ovn/tests/central_hcp_test.yaml b/packages/system/kubeovn/charts/kube-ovn/tests/central_hcp_test.yaml new file mode 100644 index 000000000..1aad41ad2 --- /dev/null +++ b/packages/system/kubeovn/charts/kube-ovn/tests/central_hcp_test.yaml @@ -0,0 +1,270 @@ +suite: OVN central HCP deployment +templates: + - central-deploy.yaml + - central-hcp-rbac.yaml + - central-svc.yaml + - nb-svc.yaml + - sb-svc.yaml + - controller-deploy.yaml + - ic-controller-deploy.yaml + - ovsovn-ds.yaml + - ovn-dpdk-ds.yaml +tests: + - it: renders ovn-central as a PVC-backed StatefulSet in the HCP namespace + template: central-deploy.yaml + set: + ovn-central.hcp.enabled: true + ovn-central.hcp.namespace: hcp + ovn-central.hcp.nbAddress: tcp:ovn-nb.example.com:6641 + ovn-central.hcp.sbAddress: tcp:ovn-sb.example.com:6642 + ovn-central.hcp.replicas: 3 + ovn-central.hcp.storage.size: 5Gi + ovn-central.hcp.storage.storageClassName: topolvm + ovn-central.nodeSelector.dedicated: hcp-ovn + ovn-central.tolerations: + - key: dedicated + operator: Equal + value: hcp-ovn + effect: NoSchedule + asserts: + - isKind: + of: StatefulSet + - equal: + path: metadata.namespace + value: hcp + - equal: + path: spec.replicas + value: 3 + - equal: + path: spec.serviceName + value: ovn-central + - equal: + path: spec.persistentVolumeClaimRetentionPolicy.whenDeleted + value: Delete + - equal: + path: spec.persistentVolumeClaimRetentionPolicy.whenScaled + value: Delete + - equal: + path: spec.template.spec.hostNetwork + value: false + - equal: + path: spec.template.spec.serviceAccountName + value: ovn-central + - equal: + path: spec.template.spec.automountServiceAccountToken + value: true + - isNotNull: + path: spec.template.spec.affinity.podAntiAffinity + - notExists: + path: spec.template.spec.affinity.nodeAffinity + - equal: + path: spec.template.spec.nodeSelector.dedicated + value: hcp-ovn + - contains: + path: spec.template.spec.tolerations + content: + key: dedicated + operator: Equal + value: hcp-ovn + effect: NoSchedule + - contains: + path: spec.template.spec.containers[0].env + content: + name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - contains: + path: spec.template.spec.containers[0].env + content: + name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - contains: + path: spec.template.spec.containers[0].env + content: + name: NODE_IPS + value: ovn-central-0.ovn-central.hcp.svc,ovn-central-1.ovn-central.hcp.svc,ovn-central-2.ovn-central.hcp.svc + - contains: + path: spec.template.spec.containers[0].env + content: + name: DB_CLUSTER_ADDR + value: $(POD_NAME).ovn-central.$(POD_NAMESPACE).svc + - equal: + path: spec.volumeClaimTemplates[0].spec.resources.requests.storage + value: 5Gi + - equal: + path: spec.volumeClaimTemplates[0].spec.storageClassName + value: topolvm + + - it: creates dedicated namespaced RBAC for HCP ovn-central + template: central-hcp-rbac.yaml + documentIndex: 0 + set: + ovn-central.hcp.enabled: true + ovn-central.hcp.namespace: hcp + ovn-central.hcp.nbAddress: tcp:ovn-nb.example.com:6641 + ovn-central.hcp.sbAddress: tcp:ovn-sb.example.com:6642 + asserts: + - isKind: + of: ServiceAccount + - equal: + path: metadata.name + value: ovn-central + - equal: + path: metadata.namespace + value: hcp + - equal: + path: automountServiceAccountToken + value: false + + - it: creates a headless service for StatefulSet raft DNS + template: central-svc.yaml + set: + ovn-central.hcp.enabled: true + ovn-central.hcp.namespace: hcp + ovn-central.hcp.nbAddress: tcp:ovn-nb.example.com:6641 + ovn-central.hcp.sbAddress: tcp:ovn-sb.example.com:6642 + asserts: + - equal: + path: metadata.name + value: ovn-central + - equal: + path: metadata.namespace + value: hcp + - equal: + path: spec.clusterIP + value: None + - equal: + path: spec.publishNotReadyAddresses + value: true + + - it: exposes nb and sb through HCP node ports + template: nb-svc.yaml + set: + ovn-central.hcp.enabled: true + ovn-central.hcp.namespace: hcp + ovn-central.hcp.service.type: NodePort + ovn-central.hcp.service.nbNodePort: 30641 + ovn-central.hcp.nbAddress: tcp:ovn-nb.example.com:6641 + ovn-central.hcp.sbAddress: tcp:ovn-sb.example.com:6642 + asserts: + - equal: + path: metadata.namespace + value: hcp + - equal: + path: spec.type + value: NodePort + - equal: + path: spec.ports[0].nodePort + value: 30641 + + - it: omits node ports when HCP services are rendered as ClusterIP + template: nb-svc.yaml + set: + ovn-central.hcp.enabled: true + ovn-central.hcp.namespace: hcp + ovn-central.hcp.service.type: ClusterIP + ovn-central.hcp.nbAddress: tcp:ovn-nb.example.com:6641 + ovn-central.hcp.sbAddress: tcp:ovn-sb.example.com:6642 + asserts: + - equal: + path: spec.type + value: ClusterIP + - notExists: + path: spec.ports[0].nodePort + + - it: defaults empty HCP NB service type to ClusterIP + template: nb-svc.yaml + set: + ovn-central.hcp.enabled: true + ovn-central.hcp.namespace: hcp + ovn-central.hcp.service.type: "" + ovn-central.hcp.nbAddress: tcp:ovn-nb.example.com:6641 + ovn-central.hcp.sbAddress: tcp:ovn-sb.example.com:6642 + asserts: + - equal: + path: spec.type + value: ClusterIP + - notExists: + path: spec.ports[0].nodePort + + - it: defaults empty HCP SB service type to ClusterIP + template: sb-svc.yaml + set: + ovn-central.hcp.enabled: true + ovn-central.hcp.namespace: hcp + ovn-central.hcp.service.type: "" + ovn-central.hcp.nbAddress: tcp:ovn-nb.example.com:6641 + ovn-central.hcp.sbAddress: tcp:ovn-sb.example.com:6642 + asserts: + - equal: + path: spec.type + value: ClusterIP + - notExists: + path: spec.ports[0].nodePort + + - it: points workload components at independent HCP OVN DB addresses + template: controller-deploy.yaml + set: + ovn-central.hcp.enabled: true + ovn-central.hcp.nbAddress: tcp:ovn-nb.example.com:6641 + ovn-central.hcp.sbAddress: tcp:ovn-sb.example.com:6642 + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: OVN_NB_ADDR + value: tcp:ovn-nb.example.com:6641 + - contains: + path: spec.template.spec.containers[0].env + content: + name: OVN_SB_ADDR + value: tcp:ovn-sb.example.com:6642 + + - it: points ic-controller at independent HCP OVN DB addresses + template: ic-controller-deploy.yaml + set: + func.ENABLE_IC: true + ovn-central.hcp.enabled: true + ovn-central.hcp.nbAddress: tcp:ovn-nb.example.com:6641 + ovn-central.hcp.sbAddress: tcp:ovn-sb.example.com:6642 + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: OVN_NB_ADDR + value: tcp:ovn-nb.example.com:6641 + - contains: + path: spec.template.spec.containers[0].env + content: + name: OVN_SB_ADDR + value: tcp:ovn-sb.example.com:6642 + + - it: points ovs-ovn at the HCP OVN SB address + template: ovsovn-ds.yaml + set: + ovn-central.hcp.enabled: true + ovn-central.hcp.nbAddress: tcp:ovn-nb.example.com:6641 + ovn-central.hcp.sbAddress: tcp:ovn-sb.example.com:6642 + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: OVN_SB_ADDR + value: tcp:ovn-sb.example.com:6642 + + - it: points ovs-ovn-dpdk at the HCP OVN SB address + template: ovn-dpdk-ds.yaml + set: + HYBRID_DPDK: true + ovn-central.hcp.enabled: true + ovn-central.hcp.nbAddress: tcp:ovn-nb.example.com:6641 + ovn-central.hcp.sbAddress: tcp:ovn-sb.example.com:6642 + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: OVN_SB_ADDR + value: tcp:ovn-sb.example.com:6642 diff --git a/packages/system/kubeovn/charts/kube-ovn/tests/controller_data_plane_test.yaml b/packages/system/kubeovn/charts/kube-ovn/tests/controller_data_plane_test.yaml new file mode 100644 index 000000000..c7a749b9c --- /dev/null +++ b/packages/system/kubeovn/charts/kube-ovn/tests/controller_data_plane_test.yaml @@ -0,0 +1,133 @@ +suite: Kube-OVN controller data plane deployment +templates: + - controller-deploy.yaml +tests: + - it: preserves controller replica override outside dataPlaneOnly + set: + installMode: full + MASTER_NODES: "10.0.0.1,10.0.0.2,10.0.0.3" + kube-ovn-controller.replicas: 4 + asserts: + - equal: + path: spec.replicas + value: 4 + + - it: renders TLS cipher suites as readable repeated args + set: + installMode: full + MASTER_NODES: "10.0.0.1" + networking.TLS_CIPHER_SUITES: + - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 + - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + asserts: + - contains: + path: spec.template.spec.containers[0].args + content: --tls-cipher-suites=TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 + - contains: + path: spec.template.spec.containers[0].args + content: --tls-cipher-suites=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + - notContains: + path: spec.template.spec.containers[0].args + content: --tls-cipher-suites=TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + + - it: uses one dataPlaneOnly controller replica for one node + set: + installMode: dataPlaneOnly + MASTER_NODES: "10.0.0.1" + externalOvnCentral.nbEndpoint: 10.0.0.10 + externalOvnCentral.sbEndpoint: 10.0.0.10 + kube-ovn-controller.replicas: 2 + asserts: + - equal: + path: spec.replicas + value: 1 + + - it: caps dataPlaneOnly controller replicas at two + set: + installMode: dataPlaneOnly + MASTER_NODES: "10.0.0.1,10.0.0.2,10.0.0.3" + externalOvnCentral.nbEndpoint: 10.0.0.10 + externalOvnCentral.sbEndpoint: 10.0.0.10 + kube-ovn-controller.replicas: 1 + asserts: + - equal: + path: spec.replicas + value: 2 + + - it: uses Kubernetes node count instead of master node count for dataPlaneOnly replicas + kubernetesProvider: + scheme: + "v1/Node": + gvr: + version: v1 + resource: nodes + namespaced: false + objects: + - kind: Node + apiVersion: v1 + metadata: + name: node-1 + labels: {} + - kind: Node + apiVersion: v1 + metadata: + name: node-2 + labels: {} + - kind: Node + apiVersion: v1 + metadata: + name: node-3 + labels: {} + set: + installMode: dataPlaneOnly + MASTER_NODES: "10.0.0.1" + externalOvnCentral.nbEndpoint: 10.0.0.10 + externalOvnCentral.sbEndpoint: 10.0.0.10 + asserts: + - equal: + path: spec.replicas + value: 2 + + - it: renders independent external OVN DB addresses for dataPlaneOnly + set: + installMode: dataPlaneOnly + MASTER_NODES: "10.0.0.1" + externalOvnCentral.nbEndpoint: 10.0.0.11 + externalOvnCentral.nbPort: 30641 + externalOvnCentral.sbEndpoint: 10.0.0.12 + externalOvnCentral.sbPort: 30642 + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: OVN_NB_ADDR + value: tcp:10.0.0.11:30641 + - contains: + path: spec.template.spec.containers[0].env + content: + name: OVN_SB_ADDR + value: tcp:10.0.0.12:30642 + - notContains: + path: spec.template.spec.containers[0].env + content: + name: OVN_DB_IPS + + - it: renders IPv6 external OVN DB addresses for dataPlaneOnly + set: + installMode: dataPlaneOnly + MASTER_NODES: "10.0.0.1" + externalOvnCentral.nbEndpoint: "fd00::11" + externalOvnCentral.nbPort: 30641 + externalOvnCentral.sbEndpoint: "[fd00::12]" + externalOvnCentral.sbPort: 30642 + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: OVN_NB_ADDR + value: tcp:[fd00::11]:30641 + - contains: + path: spec.template.spec.containers[0].env + content: + name: OVN_SB_ADDR + value: tcp:[fd00::12]:30642 diff --git a/packages/system/kubeovn/charts/kube-ovn/tests/controller_leader_election_test.yaml b/packages/system/kubeovn/charts/kube-ovn/tests/controller_leader_election_test.yaml new file mode 100644 index 000000000..2a913b2a6 --- /dev/null +++ b/packages/system/kubeovn/charts/kube-ovn/tests/controller_leader_election_test.yaml @@ -0,0 +1,43 @@ +suite: Kube-OVN controller leader election +templates: + - controller-deploy.yaml +tests: + - it: relies on controller defaults when leader election timings are empty + set: + MASTER_NODES: "10.0.0.1" + asserts: + - notContains: + path: spec.template.spec.containers[0].args + content: --leader-elect-lease-duration=30s + - notContains: + path: spec.template.spec.containers[0].args + content: --leader-elect-lease-duration= + - notContains: + path: spec.template.spec.containers[0].args + content: --leader-elect-renew-deadline=20s + - notContains: + path: spec.template.spec.containers[0].args + content: --leader-elect-renew-deadline= + - notContains: + path: spec.template.spec.containers[0].args + content: --leader-elect-retry-period=6s + - notContains: + path: spec.template.spec.containers[0].args + content: --leader-elect-retry-period= + + - it: renders custom leader election timings + set: + MASTER_NODES: "10.0.0.1" + kube-ovn-controller.leaderElection.leaseDuration: 1m + kube-ovn-controller.leaderElection.renewDeadline: 40s + kube-ovn-controller.leaderElection.retryPeriod: 10s + asserts: + - contains: + path: spec.template.spec.containers[0].args + content: --leader-elect-lease-duration=1m + - contains: + path: spec.template.spec.containers[0].args + content: --leader-elect-renew-deadline=40s + - contains: + path: spec.template.spec.containers[0].args + content: --leader-elect-retry-period=10s diff --git a/packages/system/kubeovn/charts/kube-ovn/values.yaml b/packages/system/kubeovn/charts/kube-ovn/values.yaml index fd3472f69..1449617f4 100644 --- a/packages/system/kubeovn/charts/kube-ovn/values.yaml +++ b/packages/system/kubeovn/charts/kube-ovn/values.yaml @@ -8,11 +8,11 @@ global: images: kubeovn: repository: kube-ovn - tag: v1.15.10 + tag: v1.15.26 natgateway: repository: vpc-nat-gateway # Falls back to the same tag as kubeovn if empty - tag: v1.15.10 + tag: v1.15.26 image: pullPolicy: IfNotPresent @@ -21,10 +21,45 @@ namespace: kube-system MASTER_NODES: "" MASTER_NODES_LABEL: "kube-ovn/role=master" +# OVN_CENTRAL_MODE controls how ovn-central is deployed. +# cluster: multi-replica raft cluster, one pod per master node (default). +# single: single-replica Deployment backed by a PVC, can drift to another +# node when the host fails. Uses ovsdb standalone mode (no raft). +OVN_CENTRAL_MODE: "cluster" + +# installMode controls which slice of the chart this Helm release renders. +# full: all components in one cluster (default, classic install). +# controlPlaneOnly: only ovn-central + ovn-nb/ovn-sb/ovn-northd Services and +# their RBAC. Use on the management cluster of a +# split-cluster deployment that hosts ovn-central. +# dataPlaneOnly: CRDs + kube-ovn-controller + kube-ovn-cni + ovs-ovn + +# pinger and their RBAC. Use on tenant data-plane +# clusters that connect back to an external ovn-central via +# externalOvnCentral below. kube-ovn-monitor is intentionally +# skipped: it reads local OVN Unix sockets / DB files and +# does not yet know how to talk to a remote ovn-central. +installMode: full + +# When installMode=dataPlaneOnly, the agents and controller cannot rely on a +# local ovn-central Service. Set nbEndpoint/sbEndpoint to the addresses that +# expose the management cluster's ovn-nb / ovn-sb Services. +externalOvnCentral: + nbEndpoint: "" + sbEndpoint: "" + nbPort: 6641 + sbPort: 6642 + networking: # NET_STACK could be dual_stack, ipv4, ipv6 NET_STACK: ipv4 ENABLE_SSL: false + # Minimum TLS version for OVN NB/SB database server and kube-ovn secure-serving endpoints. + TLS_MIN_VERSION: "" + # Maximum TLS version for OVN NB/SB database server and kube-ovn secure-serving endpoints. + TLS_MAX_VERSION: "" + # Go TLS cipher suite names. OVN DB server only supports suites mapped by dist/images/ovn-db-ssl-options.sh. + TLS_CIPHER_SUITES: [] + KUBE_OVN_TLS_ROTATION_INTERVAL: "8760h" # network type could be geneve or vlan NETWORK_TYPE: geneve # tunnel type could be geneve, vxlan or stt @@ -145,11 +180,33 @@ fullnameOverride: "" HYBRID_DPDK: false HUGEPAGE_SIZE_TYPE: hugepages-2Mi # Default HUGEPAGES: 1Gi -DPDK_IMAGE_TAG: "v1.15.0-dpdk" +DPDK_IMAGE_TAG: "v1.15.26-dpdk" DPDK_CPU: "1000m" # Default CPU configuration DPDK_MEMORY: "2Gi" # Default Memory configuration ovn-central: + tolerations: + - effect: NoSchedule + operator: Exists + - effect: NoExecute + operator: Exists + nodeSelector: + kubernetes.io/os: "linux" + hcp: + enabled: false + namespace: hcp + replicas: 3 + # OVN NB address used by workload clusters, for example tcp:ovn-nb.example.com:6641. + nbAddress: "" + # OVN SB address used by workload clusters, for example tcp:ovn-sb.example.com:6642. + sbAddress: "" + service: + type: NodePort + nbNodePort: 30641 + sbNodePort: 30642 + storage: + size: 5Gi + storageClassName: "" requests: cpu: "300m" memory: "200Mi" @@ -157,6 +214,34 @@ ovn-central: cpu: "3" memory: "4Gi" ephemeral-storage: 1Gi + # Persistent storage for the OVN DB files. Only used when OVN_CENTRAL_MODE=single. + # The StorageClass should support cross-node attach (e.g. NFS, Ceph RBD, cloud + # block storage with attach/detach) if you want ovn-central to drift between + # nodes on host failure. + storage: + storageClassName: "" + size: 10Gi + accessModes: + - ReadWriteOnce + # Set existingClaim to skip in-chart PVC creation and point the + # Deployment at a PVC the operator manages out-of-band (e.g. via a + # storage operator). The value is the name of the existing PVC; the + # Deployment's host-config-ovn volume mounts whatever you set here. + # Leaving this empty makes the chart create a PVC named + # "ovn-central-data" itself. + existingClaim: "" + # Service exposure for ovn-nb / ovn-sb / ovn-northd. Default ClusterIP is + # only reachable from inside the cluster. Switch to LoadBalancer (or + # NodePort) to expose the OVN DB to data-plane components running outside + # the management cluster — for example a split-cluster topology where + # ovn-controller / kube-ovn-cni / kube-ovn-controller run in a separate + # tenant cluster and connect back over a stable VIP. + service: + type: ClusterIP + # Optional, only honoured when type=LoadBalancer; provider-dependent. + loadBalancerIP: "" + # Optional, only honoured when type=LoadBalancer / NodePort. + externalTrafficPolicy: "" ovs-ovn: requests: cpu: "200m" @@ -166,6 +251,13 @@ ovs-ovn: memory: "1000Mi" ephemeral-storage: 1Gi kube-ovn-controller: + leaderElection: + # Duration non-leader candidates wait after observing a renewal before attempting to acquire leadership. Empty uses the controller default of 30s. + leaseDuration: "" + # Duration the acting leader retries refreshing leadership before giving up. Empty uses the controller default of 20s. + renewDeadline: "" + # Duration leader election clients wait between attempts. Empty uses the controller default of 6s. + retryPeriod: "" requests: cpu: "200m" memory: "200Mi" diff --git a/packages/system/kubeovn/images/kubeovn/Dockerfile b/packages/system/kubeovn/images/kubeovn/Dockerfile index 2907c2d93..f6531e77c 100644 --- a/packages/system/kubeovn/images/kubeovn/Dockerfile +++ b/packages/system/kubeovn/images/kubeovn/Dockerfile @@ -1,10 +1,10 @@ # syntax = docker/dockerfile:experimental -ARG VERSION="1.15.10" +ARG VERSION="1.15.26" ARG BASE_TAG=v$VERSION FROM golang:1.26-bookworm as builder -ARG TAG="v1.15.10" +ARG TAG="v1.15.26" RUN git clone --branch ${TAG} --depth 1 https://github.com/kubeovn/kube-ovn /source WORKDIR /source diff --git a/packages/system/kubeovn/images/kubeovn/patches/fix-keepvmip-portgroup.diff b/packages/system/kubeovn/images/kubeovn/patches/fix-keepvmip-portgroup.diff deleted file mode 100644 index aa5910715..000000000 --- a/packages/system/kubeovn/images/kubeovn/patches/fix-keepvmip-portgroup.diff +++ /dev/null @@ -1,83 +0,0 @@ -diff --git a/pkg/controller/pod.go b/pkg/controller/pod.go ---- a/pkg/controller/pod.go -+++ b/pkg/controller/pod.go -@@ -1061,6 +1061,7 @@ - } - } - } -+ var hasAliveVMSibling bool - isVMPod, vmName := isVMPod(pod) - if isVMPod && c.config.EnableKeepVMIP { - ports, err := c.OVNNbClient.ListNormalLogicalSwitchPorts(true, map[string]string{"pod": podKey}) -@@ -1081,6 +1082,18 @@ - if !isOwnerRefToDel { - klog.Infof("try keep ip for vm pod %s", podKey) - keepIPCR = true -+ // The VM LSP is shared across every virt-launcher pod of the VM -+ // (ExternalIDs["pod"] is keyed by VM name). Port-group memberships, -+ // however, belong to whichever virt-launcher pod is currently -+ // running the VM. If another live sibling exists (e.g. a -+ // live-migration destination while the completed source is being -+ // GC'd), its memberships must not be wiped out. -+ siblings, listErr := c.podsLister.Pods(pod.Namespace).List(labels.Everything()) -+ if listErr != nil { -+ klog.Errorf("failed to list pods in namespace %s: %v", pod.Namespace, listErr) -+ return listErr -+ } -+ hasAliveVMSibling = hasAliveSiblingVMPod(siblings, vmName, pod.Name) - } - } - if keepIPCR { -@@ -1106,12 +1119,18 @@ - return err - } - if keepIPCR { -- // always remove lsp from port groups -- for _, port := range ports { -- klog.Infof("remove lsp %s from all port groups", port.Name) -- if err = c.OVNNbClient.RemovePortFromPortGroups(port.Name); err != nil { -- klog.Errorf("failed to remove lsp %s from all port groups: %v", port.Name, err) -- return err -+ // always remove lsp from port groups, unless another live virt-launcher -+ // pod owns the memberships (e.g. live-migration destination while the -+ // completed source is being GC'd). -+ if hasAliveVMSibling { -+ klog.Infof("skip removing lsp from port groups: another alive virt-launcher pod exists for vm %s/%s", pod.Namespace, vmName) -+ } else { -+ for _, port := range ports { -+ klog.Infof("remove lsp %s from all port groups", port.Name) -+ if err = c.OVNNbClient.RemovePortFromPortGroups(port.Name); err != nil { -+ klog.Errorf("failed to remove lsp %s from all port groups: %v", port.Name, err) -+ return err -+ } - } - } - } else { -@@ -2358,6 +2377,27 @@ - return false, "" - } - -+// hasAliveSiblingVMPod reports whether pods contains any alive virt-launcher -+// pod owned by the VMI vmName, excluding the pod with name excludePodName. -+// It is used to decide whether a VM LSP's port-group memberships are still -+// owned by another running sibling (e.g. a live-migration destination) when a -+// completed/GC'd source pod is being processed. -+func hasAliveSiblingVMPod(pods []*v1.Pod, vmName, excludePodName string) bool { -+ for _, p := range pods { -+ if p == nil || p.Name == excludePodName { -+ continue -+ } -+ isVM, name := isVMPod(p) -+ if !isVM || name != vmName { -+ continue -+ } -+ if isPodAlive(p) { -+ return true -+ } -+ } -+ return false -+} -+ - func isOwnsByTheVM(vmi metav1.Object) (bool, string) { - for _, owner := range vmi.GetOwnerReferences() { - if owner.Kind == util.KindVirtualMachine && diff --git a/packages/system/kubeovn/images/kubeovn/patches/fix-vmim-scheduling-retry.diff b/packages/system/kubeovn/images/kubeovn/patches/fix-vmim-scheduling-retry.diff deleted file mode 100644 index f9dce36bc..000000000 --- a/packages/system/kubeovn/images/kubeovn/patches/fix-vmim-scheduling-retry.diff +++ /dev/null @@ -1,22 +0,0 @@ -Backport of kubeovn/kube-ovn#6834 (a229dec3d5150f55ca8344d0e296a8a02d52b726). -Remove when the image is updated to Kube-OVN v1.15.14 or later. - -diff --git a/pkg/controller/kubevirt.go b/pkg/controller/kubevirt.go ---- a/pkg/controller/kubevirt.go -+++ b/pkg/controller/kubevirt.go -@@ -186,6 +186,15 @@ func (c *Controller) handleAddOrUpdateVMIMigration(key string) error { - if sourceNode == "" || targetPod.Spec.NodeName == "" || sourceNode == targetPod.Spec.NodeName { - klog.Warningf("VM pod %s/%s migration setup skipped, source node: %s, target node: %s (migration job UID: %s)", - targetPod.Namespace, targetPod.Name, sourceNode, targetPod.Spec.NodeName, vmiMigration.UID) -+ // The source or target node may not be known yet while the migration is still -+ // in the Scheduling phase; this produces no further phase-change event, so -+ // return an error to requeue with rate limiting and retry once scheduling -+ // completes, instead of dropping the event. -+ // https://github.com/kubeovn/kube-ovn/issues/6823 -+ if sourceNode == "" || targetPod.Spec.NodeName == "" { -+ return fmt.Errorf("VM pod %s/%s migration setup deferred, source node %q, target node %q not ready yet (migration job UID %s)", -+ targetPod.Namespace, targetPod.Name, sourceNode, targetPod.Spec.NodeName, vmiMigration.UID) -+ } - return nil - } - diff --git a/packages/system/kubeovn/values.yaml b/packages/system/kubeovn/values.yaml index 5bfbdc309..4e142225a 100644 --- a/packages/system/kubeovn/values.yaml +++ b/packages/system/kubeovn/values.yaml @@ -79,4 +79,4 @@ global: images: kubeovn: repository: kubeovn - tag: v1.15.10@sha256:741299cbd0081a786a6b60c460fa3156b3a42a38141c559dd8ac031f50c5504f + tag: v1.15.26@sha256:741299cbd0081a786a6b60c460fa3156b3a42a38141c559dd8ac031f50c5504f