From c3614857351e81b1293a820985e1603eb0481d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rcio=20Fernandes?= Date: Sat, 6 Jun 2026 02:06:47 +0000 Subject: [PATCH] fluxcd: zigbee2mqtt --- .gitea/workflows/casa-services-deploy.yaml | 57 --------------- .gitea/workflows/monitoring-deploy.yaml | 69 ------------------- .../zigbee2mqtt/deploy/app/image-policy.yaml | 13 ++++ .../zigbee2mqtt/deploy/app/image-repo.yaml | 7 ++ .../deploy/app/image-update-automation.yaml | 25 +++++++ .../zigbee2mqtt/deploy/app/kustomization.yaml | 9 +++ services/zigbee2mqtt/deploy/app/pvc.yaml | 11 +++ .../statefulset.yaml} | 20 ++---- .../zigbee2mqtt/deploy/flux/app-sync.yaml | 13 ++++ .../deploy/flux/kustomization.yaml | 5 ++ .../zigbee2mqtt/ops-scripts/apply-flux.sh | 4 ++ 11 files changed, 91 insertions(+), 142 deletions(-) delete mode 100644 .gitea/workflows/casa-services-deploy.yaml delete mode 100644 .gitea/workflows/monitoring-deploy.yaml create mode 100644 services/zigbee2mqtt/deploy/app/image-policy.yaml create mode 100644 services/zigbee2mqtt/deploy/app/image-repo.yaml create mode 100644 services/zigbee2mqtt/deploy/app/image-update-automation.yaml create mode 100644 services/zigbee2mqtt/deploy/app/kustomization.yaml create mode 100644 services/zigbee2mqtt/deploy/app/pvc.yaml rename services/zigbee2mqtt/deploy/{zigbee2mqtt-deploy.yaml => app/statefulset.yaml} (82%) create mode 100644 services/zigbee2mqtt/deploy/flux/app-sync.yaml create mode 100644 services/zigbee2mqtt/deploy/flux/kustomization.yaml create mode 100755 services/zigbee2mqtt/ops-scripts/apply-flux.sh diff --git a/.gitea/workflows/casa-services-deploy.yaml b/.gitea/workflows/casa-services-deploy.yaml deleted file mode 100644 index 5d6459b..0000000 --- a/.gitea/workflows/casa-services-deploy.yaml +++ /dev/null @@ -1,57 +0,0 @@ -name: Deploy Casa services CI/CD Pipeline - -on: - push: - branches: - - fix/* - - main - - master - paths: - - 'services/**' - - '.gitea/workflows/casa-services**' - pull_request: - paths: - - 'services/**' - - '.gitea/workflows/casa-services**' - schedule: - - cron: '0 15 * * 0' # every sunday 3 pm - -jobs: - deploy: - runs-on: ["casa-vlan-cicd", "kubectl", "helm", "deploy"] - env: - GITHUB_TEMP: ${{ runner.temp }} - - steps: - - - name: Checkout code - uses: actions/checkout@v3 - - - name: Fetch limbo public actions - env: - RUNNER_TEMP: "${{ runner.temp }}" - WORKSPACE: "${{ gitea.workspace }}" - run: | - curl -fsSL https://git.limbosolutions.com/kb/gitea/raw/branch/main/cloud-scripts/setup-limbo-actions.sh | bash 2>&1 - - - name: Setup kubectl - uses: ./.gitea/limbo_actions/kubectl-setup - with: - kube_server: ${{ secrets.CASA_VLAN_KUBE_SERVER }} - kube_ca_base64: ${{ secrets.CASA_VLAN_KUBE_CA_BASE64 }} - kube_token: ${{ secrets.CASA_VLAN_KUBE_TOKEN }} - - - name: Deploy zigbee2mqtt - shell: bash - run: | - kubectl apply -f ./services/zigbee2mqtt/deploy/zigbee2mqtt-deploy.yaml - - - name: Deploy wyoming - shell: bash - run: | - kubectl apply -f ./services/wyoming/deploy/wyoming-deploy.yaml - - # - name: Deploy node-red - # shell: bash - # run: | - # ./services/node-red/ops-scripts/apply-app.sh \ No newline at end of file diff --git a/.gitea/workflows/monitoring-deploy.yaml b/.gitea/workflows/monitoring-deploy.yaml deleted file mode 100644 index c13507d..0000000 --- a/.gitea/workflows/monitoring-deploy.yaml +++ /dev/null @@ -1,69 +0,0 @@ -name: Monitoring services CI/CD Pipeline - -on: - push: - branches: - - fix/* - - main - - master - paths: - - 'monitoring/**' - - '.gitea/workflows/monitoring**' - pull_request: - paths: - - 'monitoring/**' - - '.gitea/workflows/monitoring**' - schedule: - - cron: '0 12 * * 0' # every sunday 12 am - -jobs: - deploy: - runs-on: ["casa-vlan-cicd", "kubectl", "helm", "deploy"] - env: - GITHUB_TEMP: ${{ runner.temp }} - - steps: - - - name: Checkout code - uses: actions/checkout@v3 - - - name: Fetch limbo public actions - env: - RUNNER_TEMP: "${{ runner.temp }}" - WORKSPACE: "${{ gitea.workspace }}" - run: | - curl -fsSL https://git.limbosolutions.com/kb/gitea/raw/branch/main/cloud-scripts/setup-limbo-actions.sh | bash 2>&1 - - - name: Setup kubectl - uses: ./.gitea/limbo_actions/kubectl-setup - with: - kube_server: ${{ secrets.CASA_VLAN_KUBE_SERVER }} - kube_ca_base64: ${{ secrets.CASA_VLAN_KUBE_CA_BASE64 }} - kube_token: ${{ secrets.CASA_VLAN_KUBE_TOKEN }} - - # secrets.LOKI_URL = https:///loki/api/v1/push - - name: Deploy promtail - shell: bash - env: - LOKI_URL: "${{ secrets.LOKI_URL }}" - run: | - # add repo - helm repo add grafana https://grafana.github.io/helm-charts - # Install & Upgrade - helm upgrade --install promtail grafana/promtail --namespace monitoring \ - --values=./monitoring/promtail/values.yaml --set config.clients[0].url=${LOKI_URL} - - # - name: Deploy Telegraf - # shell: bash - # run: | - # # add repo - # helm repo add prometheus-community https://prometheus-community.github.io/helm-charts - # # Install & Upgrade - # helm upgrade --install prometheus-stack prometheus-community/kube-prometheus-stack \ - # --namespace monitoring \ - # --values=./monitoring/prometheus/deploy/helm/01-only-crd-and-operator.yaml \ - # --values=./monitoring/prometheus/deploy//helm/02-kube-metrics.yaml \ - # --values=./monitoring/prometheus/deploy/helm/03-node-exporter.yaml \ - # --values=./monitoring/prometheus/deploy/helm/04-kubelet.yaml - # kubectl apply -f ./monitoring/prometheus/deploy/prometheus-agent.yaml - diff --git a/services/zigbee2mqtt/deploy/app/image-policy.yaml b/services/zigbee2mqtt/deploy/app/image-policy.yaml new file mode 100644 index 0000000..d04f237 --- /dev/null +++ b/services/zigbee2mqtt/deploy/app/image-policy.yaml @@ -0,0 +1,13 @@ +apiVersion: image.toolkit.fluxcd.io/v1 +kind: ImagePolicy +metadata: + name: zigbee2mqtt +spec: + imageRepositoryRef: + name: zigbee2mqtt + filterTags: + pattern: '^latest$' + policy: + alphabetical: {} + digestReflectionPolicy: Always + interval: 24h \ No newline at end of file diff --git a/services/zigbee2mqtt/deploy/app/image-repo.yaml b/services/zigbee2mqtt/deploy/app/image-repo.yaml new file mode 100644 index 0000000..32e90af --- /dev/null +++ b/services/zigbee2mqtt/deploy/app/image-repo.yaml @@ -0,0 +1,7 @@ +apiVersion: image.toolkit.fluxcd.io/v1 +kind: ImageRepository +metadata: + name: zigbee2mqtt +spec: + image: koenkk/zigbee2mqtt + interval: 72h \ No newline at end of file diff --git a/services/zigbee2mqtt/deploy/app/image-update-automation.yaml b/services/zigbee2mqtt/deploy/app/image-update-automation.yaml new file mode 100644 index 0000000..1260b2c --- /dev/null +++ b/services/zigbee2mqtt/deploy/app/image-update-automation.yaml @@ -0,0 +1,25 @@ +apiVersion: image.toolkit.fluxcd.io/v1 +kind: ImageUpdateAutomation +metadata: + name: zigbee2mqtt +spec: + interval: 72h + sourceRef: + kind: GitRepository + name: casa + namespace: casa-limbosolutions-com + git: + checkout: + ref: + branch: main + commit: + author: + name: FluxCD + email: flux@local + messageTemplate: | + Update zigbee2mqtt image. + push: + branch: main + update: + path: ./services/zigbee2mqtt/deploy/app/statefulset.yaml + strategy: Setters \ No newline at end of file diff --git a/services/zigbee2mqtt/deploy/app/kustomization.yaml b/services/zigbee2mqtt/deploy/app/kustomization.yaml new file mode 100644 index 0000000..10d0214 --- /dev/null +++ b/services/zigbee2mqtt/deploy/app/kustomization.yaml @@ -0,0 +1,9 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: mqtt +resources: + - pvc.yaml + - statefulset.yaml + - image-policy.yaml + - image-repo.yaml + - image-update-automation.yaml \ No newline at end of file diff --git a/services/zigbee2mqtt/deploy/app/pvc.yaml b/services/zigbee2mqtt/deploy/app/pvc.yaml new file mode 100644 index 0000000..ae95833 --- /dev/null +++ b/services/zigbee2mqtt/deploy/app/pvc.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: zigbee2mqtt-data +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi + storageClassName: local-path \ No newline at end of file diff --git a/services/zigbee2mqtt/deploy/zigbee2mqtt-deploy.yaml b/services/zigbee2mqtt/deploy/app/statefulset.yaml similarity index 82% rename from services/zigbee2mqtt/deploy/zigbee2mqtt-deploy.yaml rename to services/zigbee2mqtt/deploy/app/statefulset.yaml index 34619e6..69a5986 100644 --- a/services/zigbee2mqtt/deploy/zigbee2mqtt-deploy.yaml +++ b/services/zigbee2mqtt/deploy/app/statefulset.yaml @@ -1,23 +1,8 @@ -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: zigbee2mqtt-data - namespace: mqtt -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 1Gi - storageClassName: local-path - ---- apiVersion: apps/v1 kind: StatefulSet metadata: name: zigbee2mqtt - namespace: mqtt labels: app: zigbee2mqtt spec: @@ -35,7 +20,10 @@ spec: - name: zigbee2mqtt securityContext: privileged: true - image: koenkk/zigbee2mqtt + ### Maintained by flux - Image Update Automation + image: koenkk/zigbee2mqtt # {"$imagepolicy": "mqtt:zigbee2mqtt"} + ### + volumeMounts: - name: zigbee2mqtt-data mountPath: /app/data diff --git a/services/zigbee2mqtt/deploy/flux/app-sync.yaml b/services/zigbee2mqtt/deploy/flux/app-sync.yaml new file mode 100644 index 0000000..568d502 --- /dev/null +++ b/services/zigbee2mqtt/deploy/flux/app-sync.yaml @@ -0,0 +1,13 @@ +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: zigbee2mqtt +spec: + interval: 1m + sourceRef: + kind: GitRepository + name: casa + namespace: casa-limbosolutions-com + path: deploy/app + prune: true + \ No newline at end of file diff --git a/services/zigbee2mqtt/deploy/flux/kustomization.yaml b/services/zigbee2mqtt/deploy/flux/kustomization.yaml new file mode 100644 index 0000000..b5c759c --- /dev/null +++ b/services/zigbee2mqtt/deploy/flux/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: mqtt +resources: + - app-sync.yaml diff --git a/services/zigbee2mqtt/ops-scripts/apply-flux.sh b/services/zigbee2mqtt/ops-scripts/apply-flux.sh new file mode 100755 index 0000000..e4f8708 --- /dev/null +++ b/services/zigbee2mqtt/ops-scripts/apply-flux.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -e + +kubectl kustomize deploy/flux | kubectl apply -f - \ No newline at end of file