Skip to content

Commit

Permalink
feat(kyverno): volsync policy
Browse files Browse the repository at this point in the history
  • Loading branch information
buroa committed Jan 2, 2025
1 parent e817ff5 commit 6dc85a2
Show file tree
Hide file tree
Showing 33 changed files with 280 additions and 810 deletions.
6 changes: 3 additions & 3 deletions .taskfiles/volsync/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,20 @@ tasks:
ns: Namespace the PVC is in (default: default)
app: Application to snapshot (required)
cmds:
- kubectl patch clusterpolicy volsync --type merge -p '{"spec":{"useServerSideApply":true}}'
- kubectl -n {{.ns}} patch replicationsources {{.app}} --type merge -p '{"spec":{"trigger":{"manual":"{{.now}}"}}}'
- bash {{.VOLSYNC_RESOURCES_DIR}}/wait-for-job.sh {{.job}} {{.ns}}
- kubectl -n {{.ns}} wait job/{{.job}} --for condition=complete --timeout=120m
- kubectl -n {{.ns}} patch replicationsources {{.app}} --type merge -p '{"spec":{"trigger":{"manual":null}}}'
- kubectl patch clusterpolicy volsync --type merge -p '{"spec":{"useServerSideApply":null}}'
env: *env-vars
requires:
vars: ["app"]
vars:
now: '{{now | date "150405"}}'
ns: '{{.ns | default "default"}}'
job: volsync-src-{{.app}}
controller:
sh: true && {{.VOLSYNC_RESOURCES_DIR}}/which-controller.sh {{.app}} {{.ns}}
preconditions:
- test -f {{.VOLSYNC_RESOURCES_DIR}}/which-controller.sh
- test -f {{.VOLSYNC_RESOURCES_DIR}}/wait-for-job.sh
- kubectl -n {{.ns}} get replicationsources {{.app}}

Expand Down
2 changes: 1 addition & 1 deletion kubernetes/apps/home/home-assistant/app/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ kind: Kustomization
resources:
- ./externalsecret.yaml
- ./helmrelease.yaml
- ./volsync.yaml
- ./pvc.yaml
13 changes: 13 additions & 0 deletions kubernetes/apps/home/home-assistant/app/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: home-assistant
annotations:
volsync.io/enabled: "true"
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 5Gi
storageClassName: ceph-block
86 changes: 0 additions & 86 deletions kubernetes/apps/home/home-assistant/app/volsync.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion kubernetes/apps/home/zigbee2mqtt/app/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: Kustomization
resources:
- ./externalsecret.yaml
- ./helmrelease.yaml
- ./volsync.yaml
- ./pvc.yaml
configMapGenerator:
- name: zigbee2mqtt-loki-rules
files:
Expand Down
13 changes: 13 additions & 0 deletions kubernetes/apps/home/zigbee2mqtt/app/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: zigbee2mqtt
annotations:
volsync.io/enabled: "true"
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
storageClassName: ceph-block
86 changes: 0 additions & 86 deletions kubernetes/apps/home/zigbee2mqtt/app/volsync.yaml

This file was deleted.

37 changes: 18 additions & 19 deletions kubernetes/apps/kyverno/kyverno/app/helmrelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,30 @@ spec:
rbac:
clusterRole:
extraResources:
- apiGroups:
- ""
resources:
- pods
verbs:
- create
- update
- delete
- apiGroups: [""]
resources: ["pods"]
verbs: ["create", "update", "delete"]
- apiGroups: ["external-secrets.io"]
resources: ["externalsecrets"]
verbs: ["create", "update", "patch", "delete", "get", "list"]
- apiGroups: ["volsync.backube"]
resources: ["replicationsources", "replicationdestinations"]
verbs: ["create", "update", "patch", "delete", "get", "list"]
serviceMonitor:
enabled: true
backgroundController:
rbac:
clusterRole:
extraResources:
- apiGroups:
- ""
resources:
- pods
verbs:
- create
- update
- patch
- delete
- get
- list
- apiGroups: [""]
resources: ["pods"]
verbs: ["create", "update", "patch", "delete", "get", "list"]
- apiGroups: ["external-secrets.io"]
resources: ["externalsecrets"]
verbs: ["create", "update", "patch", "delete", "get", "list"]
- apiGroups: ["volsync.backube"]
resources: ["replicationsources", "replicationdestinations"]
verbs: ["create", "update", "patch", "delete", "get", "list"]
resources:
requests:
cpu: 100m
Expand Down
10 changes: 5 additions & 5 deletions kubernetes/apps/kyverno/kyverno/policies/gatus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ metadata:
all Ingresses with the ingressClassName set to external.
pod-policies.kyverno.io/autogen-controllers: none
spec:
generateExisting: true
rules:
- name: *name
match:
Expand All @@ -36,21 +35,22 @@ spec:
context:
- name: GATUS_HOST
variable:
value: '{{ request.object.metadata.annotations."gatus.io/host" || request.object.spec.rules[0].host }}'
value: "{{ request.object.metadata.annotations.\"gatus.io/host\" || request.object.spec.rules[0].host }}"
jmesPath: "to_string(@)"
- name: GATUS_NAME
variable:
value: '{{ request.object.metadata.annotations."gatus.io/name" || request.object.metadata.name }}'
value: "{{ request.object.metadata.annotations.\"gatus.io/name\" || request.object.metadata.name }}"
jmesPath: "to_string(@)"
- name: GATUS_PATH
variable:
value: '{{ request.object.metadata.annotations."gatus.io/path" || request.object.spec.rules[0].http.paths[0].path }}'
value: "{{ request.object.metadata.annotations.\"gatus.io/path\" || request.object.spec.rules[0].http.paths[0].path }}"
jmesPath: "to_string(@)"
- name: GATUS_STATUS_CODE
variable:
value: '{{ request.object.metadata.annotations."gatus.io/status-code" || `200` }}'
value: "{{ request.object.metadata.annotations.\"gatus.io/status-code\" || '200' }}"
jmesPath: "to_string(@)"
generate:
generateExisting: true
apiVersion: v1
kind: ConfigMap
name: "{{ request.object.metadata.name }}-gatus-ep"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ resources:
- ./gatus.yaml
- ./limits.yaml
- ./ndots.yaml
- ./volsync.yaml
Loading

0 comments on commit 6dc85a2

Please sign in to comment.