diff --git a/.gitea/workflows/ deploy-to-homesrv.yml b/.gitea/workflows/ deploy-to-homesrv.yml deleted file mode 100644 index d287d4f..0000000 --- a/.gitea/workflows/ deploy-to-homesrv.yml +++ /dev/null @@ -1,13 +0,0 @@ -# on: -# push: -# schedule: -# - cron: '30 7 * * SUN' # Every Sunday at deploy -# jobs: -# deploy-to-homesrv01: -# runs-on: "myLimbo-casa-gitea-act-runner" -# steps: -# - name: Checkout code -# uses: actions/checkout@v2 - -# - name: docker compose up -# run: docker compose up -d --pull always \ No newline at end of file diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..a1a7c6c --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,42 @@ +name: Mosquitto CI/CD Pipeline + +on: + push: + branches: + - fix/* + - main + - master + pull_request: + schedule: + - cron: '0 15 * * 0' # every sunday 3 pm + +jobs: + deploy: + runs-on: casa-vlan-cicd + 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 Mosquitto + shell: bash + run: | + kubectl apply -f ./deploy/mosquitto-deploy + \ No newline at end of file diff --git a/README.md b/README.md index b663427..19fd862 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,20 @@ # mosquitto -## Hosting +Currently hosted on [kubernetes cluster - casa](https://git.limbosolutions.com/myLimbo/casa). -Hosted on [casa.dev.lan](/marcio.fernandes/homesrv01.dev.lan). \ No newline at end of file +## Namespace + +```bash { cwd=../ terminalRows=15 } +kubectl create namespace mosquitto +``` + +## Deploy + +- [deployment](./deploy/cicd-rbac.yaml) +- [cicd-rbac](./deploy/cicd-rbac.yaml) + +## Continuous Deploy + +Weekly cron update. + +[Gitea Workflow](./.gitea/workflows/%20deploy.yml) diff --git a/deploy/cicd-rbac.yaml b/deploy/cicd-rbac.yaml new file mode 100644 index 0000000..dd84d29 --- /dev/null +++ b/deploy/cicd-rbac.yaml @@ -0,0 +1,32 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + namespace: mosquitto + name: ci-cd +rules: +- apiGroups: [""] + resources: ["pods", "services", "secrets", "configmaps", "persistentvolumeclaims", "endpoints"] + verbs: ["get", "watch", "list", "create", "update", "patch", "delete"] +- apiGroups: ["apps"] + resources: ["deployments", "statefulsets"] + verbs: ["get", "watch", "list", "create", "update", "patch", "delete"] +- apiGroups: ["networking.k8s.io"] + resources: ["ingresses"] + verbs: ["get", "watch", "list", "create", "update", "patch", "delete"] +- apiGroups: ["traefik.io"] + resources: ["ingressroutes"] + verbs: ["get", "watch", "list", "create", "update", "patch", "delete"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: ci-cd + namespace: mosquitto +subjects: +- kind: ServiceAccount + name: casa-ci-cd + namespace: home-assistant +roleRef: + kind: Role + name: ci-cd + apiGroup: rbac.authorization.k8s.io