automating kubevirt upgrade and managing through flux

This commit is contained in:
Joseph Hanson 2024-07-02 23:40:52 -05:00
parent 4ca0e0d706
commit b3ef046820
Signed by: jahanson
SSH key fingerprint: SHA256:vy6dKBECV522aPAwklFM3ReKAVB086rT3oWwiuiFG7o
13 changed files with 233 additions and 0 deletions

View file

@ -0,0 +1,9 @@
---
# yaml-language-server: $schema=https://json.schemastore.org/kustomization.json
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
# Flux-Kustomizations
- ./ingress.yaml
- ./nixosdv.yaml
- ./storageprofile.yaml

View file

@ -0,0 +1,17 @@
---
# yaml-language-server: $schema=https://ks.hsn.dev/cdi.kubevirt.io/datavolume_v1beta1.json
apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
name: "nixos-minimal"
spec:
storage:
resources:
requests:
storage: 2Gi
storageClassName: "openebs-zfs"
accessModes:
- "ReadWriteOnce"
source:
http:
url: "https://channels.nixos.org/nixos-24.05/latest-nixos-minimal-x86_64-linux.iso"

View file

@ -0,0 +1,26 @@
---
# yaml-language-server: $schema=https://ks.hsn.dev/cdi.kubevirt.io/storageprofile_v1beta1.json
apiVersion: cdi.kubevirt.io/v1beta1
kind: StorageProfile
metadata:
labels:
app: containerized-data-importer
app.kubernetes.io/component: storage
app.kubernetes.io/managed-by: cdi-controller
cdi.kubevirt.io: ""
name: openebs-zfs
spec:
claimPropertySets:
- accessModes:
- ReadWriteOnce
volumeMode: Block
status:
claimPropertySets:
- accessModes:
- ReadWriteOnce
volumeMode: Block
cloneStrategy: snapshot
dataImportCronSourceFormat: pvc
provisioner: zfs.csi.openebs.io
snapshotClass: openebs-zfs
storageClass: openebs-zfs

View file

@ -0,0 +1,73 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/fluxcd-community/flux2-schemas/main/kustomization-kustomize-v1.json
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: &app kubevirt-cdi
namespace: flux-system
spec:
targetNamespace: cdi
dependsOn:
- name: kubevirt
- name: openebs-cluster
path: ./deploy
prune: true
sourceRef:
kind: GitRepository
name: kubevirt-cdi
wait: true
interval: 30m
retryInterval: 1m
timeout: 5m
patches:
- patch: |
$patch: delete
apiVersion: v1
kind: Namespace
metadata:
name: cdi
target:
kind: Namespace
name: cdi
- patch: |
apiVersion: cdi.kubevirt.io/v1beta1
kind: CDI
metadata:
name: not-used
spec:
cloneStrategyOverride: snapshot
config:
featureGates:
- HonorWaitForFirstConsumer
customizeComponents: {}
imagePullPolicy: IfNotPresent
infra:
nodeSelector:
kubernetes.io/os: linux
tolerations:
- key: CriticalAddonsOnly
operator: Exists
workload:
nodeSelector:
kubernetes.io/os: linux
target:
group: cdi.kubevirt.io
kind: CDI
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/fluxcd-community/flux2-schemas/main/kustomization-kustomize-v1.json
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: &app kubevirt-cdi-addl
namespace: flux-system
spec:
targetNamespace: cdi
dependsOn:
- name: kubevirt-cdi
interval: 10m
path: "./kubernetes/apps/cdi/cdi/app/"
prune: true
sourceRef:
kind: GitRepository
name: homelab
wait: false

View file

@ -0,0 +1,9 @@
---
# yaml-language-server: $schema=https://json.schemastore.org/kustomization.json
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
# Pre Flux-Kustomizations
- ./namespace.yaml
# Flux-Kustomizations
- ./app/ks.yaml

View file

@ -0,0 +1,9 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: cdi
labels:
kustomize.toolkit.fluxcd.io/prune: disabled
volsync.backube/privileged-movers: "true"
cdi.kubevirt.io: ""

View file

@ -0,0 +1,46 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/fluxcd-community/flux2-schemas/main/kustomization-kustomize-v1.json
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: &app kubevirt
namespace: flux-system
spec:
targetNamespace: kubevirt
dependsOn:
- name: openebs-cluster
path: ./deploy
prune: true
sourceRef:
kind: GitRepository
name: kubevirt
wait: true
interval: 30m
retryInterval: 1m
timeout: 5m
patches:
# namespace is managed separately by main ks, no need for this ks to also manage it, KubeVirt bundles namespace into kubevirt-operator.yaml
- patch: |
$patch: delete
apiVersion: v1
kind: Namespace
metadata:
name: kubevirt
target:
kind: Namespace
name: kubevirt
- patch: |
apiVersion: kubevirt.io/v1
kind: KubeVirt
metadata:
name: not-used
spec:
configuration:
developerConfiguration:
featureGates:
- CPUNodeDiscovery
- ExpandDisks
vmStateStorageClass: openebs-zfs
target:
group: kubevirt.io
kind: KubeVirt

View file

@ -7,3 +7,5 @@ resources:
- ./namespace.yaml
# Flux-Kustomizations
- ./manager/ks.yaml
- ./app/ks.yaml
- ./cdi/ks.yaml

View file

@ -0,0 +1,17 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/fluxcd-community/flux2-schemas/main/gitrepository-source-v1.json
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
name: kubevirt-cdi
namespace: flux-system
spec:
interval: 30m
url: https://git.hsn.dev/jahanson/kubevirt-flux.git
ref:
branch: cdi-v1.59.0
ignore: |
# exclude all
/*
# include files
!/deploy

View file

@ -0,0 +1,17 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/fluxcd-community/flux2-schemas/main/gitrepository-source-v1.json
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
name: kubevirt
namespace: flux-system
spec:
interval: 30m
url: https://git.hsn.dev/jahanson/kubevirt-flux.git
ref:
branch: v1.2.2
ignore: |
# exclude all
/*
# include files
!/deploy

View file

@ -0,0 +1,7 @@
---
# yaml-language-server: $schema=https://json.schemastore.org/kustomization.json
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- kubevirt.yaml
- kubevirt-cdi.yaml

View file

@ -5,3 +5,4 @@ kind: Kustomization
namespace: flux-system
resources:
- ./helm
- ./git