Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: edge-gitops-vms
description: Edge GitOps VMs
type: application
version: 0.5.3
version: 0.5.4
dependencies: [ ]
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# edge-gitops-vms

![Version: 0.5.3](https://img.shields.io/badge/Version-0.5.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
![Version: 0.5.4](https://img.shields.io/badge/Version-0.5.4-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)

Edge GitOps VMs

This chart is used to set up Edge GitOps VMs in conjunction with OpenShift Virtualization

### Notable changes

* v0.5.4: Make wait jobs drain-cancelable: SIGTERM trap exits nonzero (a cancelled run is never marked successful), podFailurePolicy ignores DisruptionTarget drain evictions so a replacement pod resumes instead of burning backoffLimit, and jobTerminationGracePeriod defaults 3600s to 60s.
* v0.5.4: Allow setting dataSource storageclass, defaulting to vmDefault or one set by the edv object.
* v0.5.3: Extend set-default-virt-storageclass job to wait until VM DataSources are Ready and their CSI driver/provisioner matches vmDefaults.storageClassName (prevents CDI host-assisted clone fallback onto the wrong StorageClass)
* v0.5.2: Add optional additionalPvcDisks with default PVC creation; set create: false to attach existing PVCs
* v0.5.1: Add optional job to set the default KubeVirt storage class from vmDefaults.storageClassName
Expand All @@ -33,7 +35,7 @@ This chart is used to set up Edge GitOps VMs in conjunction with OpenShift Virtu
| global.clusterDomain | string | `"example.com"` | |
| global.pattern | string | `"ansible-edge-gitops"` | |
| job.image | string | `"image-registry.openshift-image-registry.svc:5000/openshift/cli:latest"` | |
| jobTerminationGracePeriod | int | `3600` | |
| jobTerminationGracePeriod | int | `60` | Grace period before SIGKILL when a wait job pod is cancelled by a node drain. Keep this short: the jobs trap SIGTERM and exit promptly, and a long grace period blocks MCO drains/rollouts for its full duration. |
| rbac.roleBindings[0].createBinding | bool | `true` | |
| rbac.roleBindings[0].name | string | `"view-machine-api"` | |
| rbac.roleBindings[0].roleRef.kind | string | `"ClusterRole"` | |
Expand Down
2 changes: 2 additions & 0 deletions README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ This chart is used to set up Edge GitOps VMs in conjunction with OpenShift Virtu

### Notable changes

* v0.5.4: Make wait jobs drain-cancelable: SIGTERM trap exits nonzero (a cancelled run is never marked successful), podFailurePolicy ignores DisruptionTarget drain evictions so a replacement pod resumes instead of burning backoffLimit, and jobTerminationGracePeriod defaults 3600s to 60s.
* v0.5.4: Allow setting dataSource storageclass, defaulting to vmDefault or one set by the edv object.
* v0.5.3: Extend set-default-virt-storageclass job to wait until VM DataSources are Ready and their CSI driver/provisioner matches vmDefaults.storageClassName (prevents CDI host-assisted clone fallback onto the wrong StorageClass)
* v0.5.2: Add optional additionalPvcDisks with default PVC creation; set create: false to attach existing PVCs
* v0.5.1: Add optional job to set the default KubeVirt storage class from vmDefaults.storageClassName
Expand Down
1 change: 1 addition & 0 deletions templates/external-data-volumes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ spec:
resources:
requests:
storage: {{ $edv.size }}
storageClassName: {{ coalesce $edv.storageClassName $def.storageClassName }}
{{- end }}
---
apiVersion: cdi.kubevirt.io/v1beta1
Expand Down
18 changes: 18 additions & 0 deletions templates/job-setDefaultVirtStorageClass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ metadata:
name: job-set-default-virt-storageclass
namespace: {{ .Values.vmNamespace }}
spec:
# A drain-evicted (cancelled) pod is ignored rather than counted as a
# failure: the Job stays incomplete and a replacement pod resumes the
# wait. Only genuine failures count toward backoffLimit.
podFailurePolicy:
rules:
- action: Ignore
onExitCodes:
containerName: set-default-virt-storageclass
operator: In
values: [143]
- action: Ignore
onPodConditions:
- type: DisruptionTarget
template:
spec:
containers:
Expand All @@ -17,6 +30,11 @@ spec:
- -c
- |
set -euo pipefail
# Exit promptly with a nonzero code on SIGTERM so node drains can
# cancel this Job without it ever being marked successful. The
# poll loop only blocks for SLEEP_SECS at a time, so the trap
# fires quickly.
trap 'echo "Cancelled by SIGTERM; exiting 143 without success"; exit 143' TERM
TARGET_SC="{{ .Values.vmDefaults.storageClassName }}"
DS_NAMESPACE="{{ .Values.vmDefaults.externalDataSourceNamespace }}"
# Space-separated DataSource names derived from chart VMs (may be empty)
Expand Down
16 changes: 16 additions & 0 deletions templates/job-waitForMetalNode.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ metadata:
name: job-wait-for-metal-node
namespace: {{ .Values.vmNamespace }}
spec:
# A drain-evicted (cancelled) pod is ignored rather than counted as a
# failure: the Job stays incomplete and a replacement pod resumes the
# wait. Only genuine failures count toward backoffLimit.
podFailurePolicy:
rules:
- action: Ignore
onExitCodes:
containerName: wait-for-metal-node
operator: In
values: [143]
- action: Ignore
onPodConditions:
- type: DisruptionTarget
template:
spec:
containers:
Expand All @@ -15,6 +28,9 @@ spec:
- /bin/bash
- -c
- |
# Exit promptly with a nonzero code on SIGTERM so node drains can
# cancel this Job without it being marked successful.
trap 'echo "Cancelled by SIGTERM; exiting 143 without success"; exit 143' TERM
while [ 1 ];
do
nodes=$(oc get machinesets.machine.openshift.io -n openshift-machine-api -l 'edge-gitops-role=kubevirt-worker' -o jsonpath='{.items[*].status.availableReplicas}' | sed -e 's/ //g')
Expand Down
79 changes: 79 additions & 0 deletions tests/external-data-volumes_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
suite: external-data-volumes
templates:
- templates/external-data-volumes.yaml
release:
name: test
namespace: gitops-vms
tests:
- it: defaults the DataVolume storageClassName to vmDefaults
set:
externalDataSources:
- name: quay-windows
type: registry
url: "docker://quay.io/eduffy/win2k22-dv:thin"
size: 50G
documentSelector:
path: kind
value: DataVolume
asserts:
- equal:
path: metadata.name
value: quay-windows
- equal:
path: spec.storage.storageClassName
value: ocs-storagecluster-ceph-rbd-virtualization

- it: lets each externalDataSource override the storageClassName
set:
externalDataSources:
- name: quay-windows
type: registry
url: "docker://quay.io/eduffy/win2k22-dv:thin"
size: 50G
storageClassName: gp3-csi
documentSelector:
path: kind
value: DataVolume
asserts:
- equal:
path: spec.storage.storageClassName
value: gp3-csi

- it: uses the vmDefaults storageClassName when overridden globally
set:
vmDefaults:
storageClassName: gp3-csi
externalDataSources:
- name: ubuntu-installer
type: http
url: https://releases.ubuntu.com/24.04.4/ubuntu-24.04.4-live-server-amd64.iso
size: 10G
documentSelector:
path: kind
value: DataVolume
asserts:
- equal:
path: spec.storage.storageClassName
value: gp3-csi

- it: renders a DataSource referencing the DataVolume
set:
externalDataSources:
- name: quay-windows
type: registry
url: "docker://quay.io/eduffy/win2k22-dv:thin"
size: 50G
documentSelector:
path: kind
value: DataSource
asserts:
- equal:
path: metadata.name
value: quay-windows
- equal:
path: spec.source.pvc.name
value: quay-windows
- equal:
path: spec.source.pvc.namespace
value: openshift-virtualization-os-images
26 changes: 26 additions & 0 deletions tests/set-default-virt-storageclass_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,32 @@ tests:
path: spec.template.spec.containers[0].command[2]
pattern: openshift-virtualization-os-images

- it: is cancelable without being marked successful
asserts:
# SIGTERM trap exits 143 (nonzero) so the Job never completes on cancel
- matchRegex:
path: spec.template.spec.containers[0].command[2]
pattern: trap '.*exit 143' TERM
- equal:
path: spec.template.spec.terminationGracePeriodSeconds
value: 60
# Drain evictions are ignored, not counted as failures
- equal:
path: spec.podFailurePolicy.rules[0].action
value: Ignore
- equal:
path: spec.podFailurePolicy.rules[0].onExitCodes.operator
value: In
- equal:
path: spec.podFailurePolicy.rules[0].onExitCodes.values
value: [143]
- equal:
path: spec.podFailurePolicy.rules[1].action
value: Ignore
- equal:
path: spec.podFailurePolicy.rules[1].onPodConditions[0].type
value: DisruptionTarget

- it: embeds DataSource names from VMs
set:
setDefaultVirtStorageClass: true
Expand Down
8 changes: 7 additions & 1 deletion values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ vmNamespace: gitops-vms

waitForMetalNode: false
setDefaultVirtStorageClass: true
jobTerminationGracePeriod: 3600
# -- Grace period before SIGKILL when a wait job pod is cancelled by a node
# drain. Keep this short: the jobs trap SIGTERM and exit promptly, and a
# long grace period blocks MCO drains/rollouts for its full duration.
jobTerminationGracePeriod: 60

vmDefaults:
role: generic
Expand Down Expand Up @@ -100,13 +103,16 @@ externalDataSources: {}
# type: registry
# url: "docker://quay.io/eduffy/win2k22-dv:thin"
# size: 50G
# # storageClassName optional (defaults to vmDefaults.storageClassName)
# storageClassName: ocs-storagecluster-ceph-rbd-virtualization
# registryCredentialsSecret: quay-creds # You will need to create either manually or using registryCredentialExternalSecrets above

# Example downloaded from url
# - name: ubuntu-installer
# type: http
# url: https://releases.ubuntu.com/24.04.4/ubuntu-24.04.4-live-server-amd64.iso
# size: 10G
# storageClassName: gp3-csi


# This field will disable ExternalSecrets for fetching SSH Authorized Keys and
Expand Down
Loading