Skip to content

Commit 26a9e5f

Browse files
do not deploy virtualization if moduleconfig is not valid
Signed-off-by: Yaroslav Borbat <[email protected]>
1 parent 8ae1c93 commit 26a9e5f

File tree

85 files changed

+184
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+184
-6
lines changed

hooks/module_config_validator.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class ModuleConfigValidateHook(Hook):
3030
def __init__(self, module_name: str):
3131
self.module_name = module_name
3232
self.queue = f"/modules/{self.module_name}/{self.SNAPSHOT_MODULE_CONFIG}"
33+
self.path = "virtualization.internal.ready"
3334

3435
def generate_config(self) -> dict:
3536
"""executeHookOnEvent is empty because we need only execute at module start."""
@@ -86,16 +87,28 @@ def r(ctx: hook.Context):
8687
.get("filterResult", {})
8788
.get("cidrs", [])
8889
]
89-
self.check_overlaps_cidrs(cidrs)
90+
91+
try:
92+
self.check_overlaps_cidrs(cidrs)
93+
except ValueError as e:
94+
print(f"ERROR: {e}")
95+
96+
self.set_value(self.path, ctx.values, False)
9097

9198
node_addresses: list[IPv4Address] = [
9299
ip_address(addr["address"])
93100
for snap in ctx.snapshots.get(self.SNAPSHOT_NODES, [])
94101
for addr in (snap.get("filterResult", {}).get("addresses") or [])
95102
if addr.get("type") in {"InternalIP", "ExternalIP"}
96103
]
97-
self.check_node_addresses_overlap(cidrs, node_addresses)
98104

105+
try:
106+
self.check_node_addresses_overlap(cidrs, node_addresses)
107+
except ValueError as e:
108+
print(f"ERROR: {e}")
109+
self.set_value(self.path, ctx.values, False)
110+
111+
self.set_value(self.path, ctx.values, True)
99112
return r
100113

101114

openapi/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,6 @@ properties:
122122
properties:
123123
nodeCount:
124124
type: integer
125+
ready:
126+
type: boolean
127+
default: false

templates/admission-policy.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
{{- $kubeVersion := .Values.global.discovery.kubernetesVersion }}
23
{{- $apiVersion := "" }}
34
{{- if semverCompare ">=1.30.0" $kubeVersion }}
@@ -69,3 +70,4 @@ spec:
6970
namespaceSelector: {}
7071
objectSelector: {}
7172
{{- end }}
73+
{{- end }}

templates/cdi/cdi-apiserver/vpa.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
{{- if (.Values.global.enabledModules | has "vertical-pod-autoscaler-crd") }}
23
---
34
apiVersion: autoscaling.k8s.io/v1
@@ -24,3 +25,4 @@ spec:
2425
cpu: 100m
2526
memory: 150Mi
2627
{{- end }}
28+
{{- end }}

templates/cdi/cdi-deployment/rbac-for-us.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
---
23
apiVersion: rbac.authorization.k8s.io/v1
34
kind: ClusterRoleBinding
@@ -12,3 +13,4 @@ roleRef:
1213
apiGroup: rbac.authorization.k8s.io
1314
kind: ClusterRole
1415
name: d8:rbac-proxy
16+
{{- end }}

templates/cdi/cdi-deployment/vpa.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
{{- if (.Values.global.enabledModules | has "vertical-pod-autoscaler-crd") }}
23
---
34
apiVersion: autoscaling.k8s.io/v1
@@ -24,3 +25,4 @@ spec:
2425
cpu: 100m
2526
memory: 150Mi
2627
{{- end }}
28+
{{- end }}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
---
23
apiVersion: v1
34
kind: ConfigMap
45
metadata:
56
name: cdi-operator-leader-election-helper
67
namespace: d8-{{ .Chart.Name }}
78
{{- include "helm_lib_module_labels" (list .) | nindent 2 }}
9+
{{- end }}

templates/cdi/cdi-operator/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
{{- $priorityClassName := include "priorityClassName" . }}
23

34
{{- define "cdi_images" -}}
@@ -123,3 +124,4 @@ spec:
123124
serviceAccountName: cdi-operator
124125
volumes:
125126
{{- include "kube_api_rewriter.kubeconfig_volume" . | nindent 6 }}
127+
{{- end }}

templates/cdi/cdi-operator/rbac-for-us.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
---
23
apiVersion: rbac.authorization.k8s.io/v1
34
kind: ClusterRole
@@ -595,3 +596,4 @@ roleRef:
595596
apiGroup: rbac.authorization.k8s.io
596597
kind: ClusterRole
597598
name: d8:rbac-proxy
599+
{{- end }}

templates/cdi/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
{{- $nodeSelectorSystem := index (include "helm_lib_node_selector" (tuple . "system") | fromYaml) "nodeSelector" | default (dict) | toJson }}
23
{{- $nodeSelectorMaster := index (include "helm_lib_node_selector" (tuple . "master") | fromYaml) "nodeSelector" | default (dict) | toJson }}
34
{{- $tolerationsSystem := index (include "helm_lib_tolerations" (tuple . "system") | fromYaml) "tolerations" | default (list) | toJson }}
@@ -156,3 +157,4 @@ spec:
156157
workload:
157158
nodeSelector:
158159
kubernetes.io/os: linux
160+
{{- end }}

templates/cdi/service-monitor.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
{{- if (.Values.global.enabledModules | has "operator-prometheus-crd") }}
23
---
34
apiVersion: monitoring.coreos.com/v1
@@ -36,3 +37,4 @@ spec:
3637
matchLabels:
3738
prometheus.cdi.internal.virtualization.deckhouse.io: "true"
3839
{{- end }}
40+
{{- end }}

templates/certificate.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
{{- if eq (include "helm_lib_module_https_mode" .) "CertManager" }}
23
---
34
apiVersion: cert-manager.io/v1
@@ -15,4 +16,4 @@ spec:
1516
issuerRef:
1617
name: {{ include "helm_lib_module_https_cert_manager_cluster_issuer_name" . }}
1718
kind: ClusterIssuer
18-
{{- end }}
19+
{{- end }}{{- end }}

templates/custom-certificate.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
{{- include "helm_lib_module_https_copy_custom_certificate" (list . "d8-virtualization" "ingress-tls") -}}
3+
{{- end }}

templates/dvcr/ nodegroupconfiguration.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
{{- if ne (dig "dvcr" "serviceIP" "" .Values.virtualization.internal) "" }}
23
---
34
{{- $ca := printf "%s" .Values.virtualization.internal.dvcr.cert.ca }}
@@ -54,3 +55,4 @@ spec:
5455
endpoint = ["https://{{ $endpoint }}"]
5556
EOF
5657
{{- end }}
58+
{{- end }}

templates/dvcr/configmap.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
apiVersion: v1
23
kind: ConfigMap
34
metadata:
@@ -26,4 +27,4 @@ data:
2627
storagedriver:
2728
enabled: true
2829
interval: 10s
29-
threshold: 3
30+
threshold: 3{{- end }}

templates/dvcr/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
{{- $priorityClassName := include "priorityClassName" . }}
23
{{- define "dvcr_resources" }}
34
cpu: 50m
@@ -108,3 +109,4 @@ spec:
108109
{{- include "helm_lib_tolerations" (tuple . "system") | nindent 6 }}
109110
{{- include "helm_lib_module_pod_security_context_run_as_user_deckhouse_with_writable_fs" . | nindent 6 }}
110111
serviceAccountName: dvcr
112+
{{- end }}

templates/dvcr/pvc.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
{{- if eq .Values.virtualization.dvcr.storage.type "PersistentVolumeClaim" }}
23
{{- $storageClassName := dig "storageClassName" "" .Values.virtualization.dvcr.storage.persistentVolumeClaim }}
34
kind: PersistentVolumeClaim
@@ -16,3 +17,4 @@ spec:
1617
storageClassName: {{ $storageClassName }}
1718
{{- end }}
1819
{{- end }}
20+
{{- end }}

templates/dvcr/rbac-for-us.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
---
23
apiVersion: v1
34
kind: ServiceAccount
@@ -20,4 +21,4 @@ subjects:
2021
roleRef:
2122
apiGroup: rbac.authorization.k8s.io
2223
kind: ClusterRole
23-
name: d8:rbac-proxy
24+
name: d8:rbac-proxy{{- end }}

templates/dvcr/secret.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
{{- if ne (dig "dvcr" "serviceIP" "" .Values.virtualization.internal) "" }}
23
---
34
apiVersion: v1
@@ -54,3 +55,4 @@ data:
5455
s3SecretKey: {{ .Values.virtualization.dvcr.storage.objectStorage.s3.secretKey | quote }}
5556
{{- end }}
5657
{{- end }}
58+
{{- end }}

templates/dvcr/service-monitor.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
{{- if (.Values.global.enabledModules | has "operator-prometheus-crd") }}
23
---
34
apiVersion: monitoring.coreos.com/v1
@@ -24,3 +25,4 @@ spec:
2425
app: "dvcr"
2526

2627
{{- end }}
28+
{{- end }}

templates/dvcr/svc.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
apiVersion: v1
23
kind: Service
34
metadata:
@@ -17,4 +18,4 @@ spec:
1718
targetPort: https-metrics
1819
selector:
1920
app: dvcr
20-
21+
{{- end }}

templates/kube-api-rewriter/cm-kubeconfig-local.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
---
23
apiVersion: v1
34
kind: ConfigMap
@@ -18,3 +19,4 @@ data:
1819
cluster: kube-api-rewriter
1920
name: kube-api-rewriter
2021
current-context: kube-api-rewriter
22+
{{- end }}

templates/kubevirt/kubevirt.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
{{- $nodeSelectorSystem := index (include "helm_lib_node_selector" (tuple . "system") | fromYaml) "nodeSelector" | default (dict) | toJson }}
23
{{- $nodeSelectorMaster := index (include "helm_lib_node_selector" (tuple . "master") | fromYaml) "nodeSelector" | default (dict) | toJson }}
34
{{- $tolerationsSystem := index (include "helm_lib_tolerations" (tuple . "system") | fromYaml) "tolerations" | default (list) | toJson }}
@@ -278,3 +279,4 @@ env:
278279
workloadUpdateStrategy:
279280
workloadUpdateMethods:
280281
- LiveMigrate
282+
{{- end }}

templates/kubevirt/service-monitor.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
{{- if (.Values.global.enabledModules | has "operator-prometheus-crd") }}
23
---
34
apiVersion: monitoring.coreos.com/v1
@@ -233,3 +234,4 @@ spec:
233234
prometheus.kubevirt.internal.virtualization.deckhouse.io: "true"
234235

235236
{{- end }}
237+
{{- end }}

templates/kubevirt/virt-api/vpa.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
{{- if (.Values.global.enabledModules | has "vertical-pod-autoscaler-crd") }}
23
---
34
apiVersion: autoscaling.k8s.io/v1
@@ -24,3 +25,4 @@ spec:
2425
cpu: 20m
2526
memory: 250Mi
2627
{{- end }}
28+
{{- end }}

templates/kubevirt/virt-controller/rbac-for-us.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
---
23
apiVersion: rbac.authorization.k8s.io/v1
34
kind: ClusterRoleBinding
@@ -12,3 +13,4 @@ roleRef:
1213
apiGroup: rbac.authorization.k8s.io
1314
kind: ClusterRole
1415
name: d8:rbac-proxy
16+
{{- end }}

templates/kubevirt/virt-controller/vpa.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
{{- if (.Values.global.enabledModules | has "vertical-pod-autoscaler-crd") }}
23
---
34
apiVersion: autoscaling.k8s.io/v1
@@ -24,3 +25,4 @@ spec:
2425
cpu: 20m
2526
memory: 400Mi
2627
{{- end }}
28+
{{- end }}

templates/kubevirt/virt-handler/rbac-for-us.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
---
23
apiVersion: rbac.authorization.k8s.io/v1
34
kind: ClusterRoleBinding
@@ -12,3 +13,4 @@ roleRef:
1213
apiGroup: rbac.authorization.k8s.io
1314
kind: ClusterRole
1415
name: d8:rbac-proxy
16+
{{- end }}

templates/kubevirt/virt-handler/vpa.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
{{- if (.Values.global.enabledModules | has "vertical-pod-autoscaler-crd") }}
23
---
34
apiVersion: autoscaling.k8s.io/v1
@@ -24,3 +25,4 @@ spec:
2425
cpu: 20m
2526
memory: 400Mi
2627
{{- end }}
28+
{{- end }}

templates/kubevirt/virt-operator/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
{{- $priorityClassName := include "priorityClassName" . }}
23
{{- define "kubevirt_images" -}}
34
- name: VIRT_OPERATOR_IMAGE
@@ -163,3 +164,4 @@ spec:
163164
name: profile-data
164165
{{- include "kube_api_rewriter.kubeconfig_volume" . | nindent 6 }}
165166

167+
{{- end }}

templates/kubevirt/virt-operator/rbac-for-us.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
---
23
apiVersion: v1
34
kind: ServiceAccount
@@ -1228,3 +1229,4 @@ subjects:
12281229
- kind: ServiceAccount
12291230
name: kubevirt-operator
12301231
namespace: d8-{{ .Chart.Name }}
1232+
{{- end }}

templates/monitoring.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
{{- include "helm_lib_grafana_dashboard_definitions" . }}
23
{{- include "helm_lib_prometheus_rules" (list . "d8-virtualization") }}
4+
{{- end }}

templates/namespace.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
---
23
apiVersion: v1
34
kind: Namespace
@@ -6,3 +7,4 @@ metadata:
67
name: d8-{{ .Chart.Name }}
78
---
89
{{- include "helm_lib_kube_rbac_proxy_ca_certificate" (list . (printf "d8-%s" .Chart.Name)) }}
10+
{{- end }}

templates/nodegroupconfiguration-aio-max-nr.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
apiVersion: deckhouse.io/v1alpha1
23
kind: NodeGroupConfiguration
34
metadata:
@@ -54,3 +55,4 @@ spec:
5455
else
5556
exit 0
5657
fi
58+
{{- end }}

templates/nodegroupconfiguration-redos.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
apiVersion: deckhouse.io/v1alpha1
23
kind: NodeGroupConfiguration
34
metadata:
@@ -72,3 +73,4 @@ spec:
7273
else
7374
exit 0
7475
fi
76+
{{- end }}

templates/pre-delete-hook/job.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
apiVersion: batch/v1
23
kind: Job
34
metadata:
@@ -51,3 +52,4 @@ spec:
5152
memory: 150Mi
5253
{{- include "helm_lib_tolerations" (tuple . "any-node") | nindent 6 }}
5354
{{- include "helm_lib_module_pod_security_context_run_as_user_deckhouse" . | nindent 6 }}
55+
{{- end }}

templates/pre-delete-hook/rbac-for-us.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.virtualization.internal.ready }}
12
---
23
apiVersion: v1
34
kind: ServiceAccount
@@ -42,3 +43,4 @@ subjects:
4243
- kind: ServiceAccount
4344
name: virtualization-pre-delete-hook
4445
namespace: d8-{{ .Chart.Name }}
46+
{{- end }}

0 commit comments

Comments
 (0)