Compare commits

...

10 Commits

Author SHA1 Message Date
dbecd67471 modified: README.md
All checks were successful
Casa Home Assistant CI/CD Pipeline / deploy (push) Successful in 18s
modified:   deploy/README.md
renamed:    deploy/rbac.yaml -> deploy/cicd-rbac.yaml
2025-11-22 22:57:43 +00:00
2881eb1167 modified: deploy/deployment.yaml
All checks were successful
Casa Home Assistant CI/CD Pipeline / deploy (push) Successful in 16s
2025-11-22 18:51:39 +00:00
755d68a844 modified: deploy/deployment.yaml
All checks were successful
Casa Home Assistant CI/CD Pipeline / deploy (push) Successful in 18s
2025-11-22 18:36:03 +00:00
f40a899200 modified: .gitea/workflows/deploy.yaml
All checks were successful
Casa Home Assistant CI/CD Pipeline / deploy (push) Successful in 17s
2025-11-22 17:57:01 +00:00
d30aad3058 modified: .gitea/workflows/deploy.yaml
All checks were successful
Casa Home Assistant CI/CD Pipeline / deploy (push) Successful in 17s
2025-11-22 17:51:36 +00:00
6149826bc6 modified: .gitea/workflows/deploy.yaml
modified:   README.md
2025-11-22 17:50:45 +00:00
0d2b30a83a fix/cicd (#3)
Co-authored-by: Márcio Fernandes <marcio.fernandes@outlook.pt>
Reviewed-on: #3
2025-11-22 17:43:57 +00:00
001e785192 continuos deploy 2025-11-22 01:57:22 +00:00
726f3c5bb3 deleted: .gitea/workflows/deploy.yml 2025-11-16 11:59:50 +00:00
8a9c6760d5 fix: set dnsPolicy to ClusterFirstWithHostNet
Some checks failed
/ deploy-to-homesrv01 (push) Has been cancelled
2025-11-16 10:15:51 +00:00
16 changed files with 205 additions and 76 deletions

View File

@@ -0,0 +1,48 @@
name: Casa Home Assistant CI/CD Pipeline
on:
push:
branches:
- fix/*
- main
- master
pull_request:
schedule:
- cron: '0 16 * * 0' # every sunday 4 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 Home Assistant
shell: bash
env:
ENDPOINT_IP: "${{ secrets.CASA_HOMEASSISTANT_ENDPOINT_IP }}"
SERVICE_PORT: "${{ secrets.CASA_HOMEASSISTANT_ENDPOINT_SERVICE_PORT }}"
INGRESS_ROUTES_MATCH: "${{ secrets.CASA_HOMEASSISTANT_INGRESS_ROUTES_MATCH }}"
INGRESS_TLS_SECRET_NAME: "${{ secrets.CASA_HOMEASSISTANT_INGRESS_TLS_SECRET_NAME }}"
run: |
kubectl apply -f ./deploy/deployment.yaml \
&& envsubst < ./deploy/service.template.yaml | kubectl apply -f -

View File

@@ -1,13 +0,0 @@
on:
push:
schedule:
- cron: '0 7 * * SUN' # Every Sunday at 07:00
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

View File

@@ -2,10 +2,9 @@
Welcome to my Home Assistant setup repository. Welcome to my Home Assistant setup repository.
This repository documents and maintains the Home Assistant instance running in my home, hosted on casa server k3s cluster. This repository documents and maintains the Home Assistant instance running in my home, hosted on casa server k3s cluster.
All essential containers, such as MQTT and speech recognition, are hosted on the same server for seamless integration. Related containers, such as MQTT and speech recognition, are hosted on same cluster.
<!-- omit in toc --> **Table of Contents:**
## Table of Contents
- [Devices](#devices) - [Devices](#devices)
- [Broadlink - RM4 Pro](#broadlink---rm4-pro) - [Broadlink - RM4 Pro](#broadlink---rm4-pro)
@@ -37,7 +36,7 @@ All essential containers, such as MQTT and speech recognition, are hosted on the
Using as Ir blaster for living room devices and temperature meter. Using as Ir blaster for living room devices and temperature meter.
![ZigBee Smart Plugs](doc/images/broadlink-universal-remote-irwifi-rm4-mini.jpg) ![ZigBee Smart Plugs](./docs/images/broadlink-universal-remote-irwifi-rm4-mini.jpg)
**Integrations:** **Integrations:**
@@ -51,7 +50,7 @@ Currently controlling:
- dining table lights - dining table lights
- office room lights - office room lights
![ZigBee Smart Plugs](doc/images/51ojy7qoMmL._SL1500_.jpg) ![ZigBee Smart Plugs](./docs/images/51ojy7qoMmL._SL1500_.jpg)
**Integrations:** **Integrations:**
@@ -68,7 +67,7 @@ Currently controlling:
- shellyplug-s-80646F80FB14.dev.lan - shellyplug-s-80646F80FB14.dev.lan
- gaia.dev.lan (proxmox server) - gaia.dev.lan (proxmox server)
![Shelly - Smart Plug](doc/images/shellysmartplug.png) ![Shelly - Smart Plug](./docs/images/shellysmartplug.png)
Devices connected to IOT lan. Devices connected to IOT lan.
@@ -102,7 +101,7 @@ Using SONOFF Universal Zigbee 3.0 USB Dongle Plus.
The [broadlink integration](https://www.home-assistant.io/integrations/broadlink) allows you to control and monitor Broadlink universal remotes, smart plugs, power strips, switches and sensors. The [broadlink integration](https://www.home-assistant.io/integrations/broadlink) allows you to control and monitor Broadlink universal remotes, smart plugs, power strips, switches and sensors.
![broadlink integration](./doc/images/integrations-broadlink.png). ![broadlink integration](./docs/images/integrations-broadlink.png).
Devices: Devices:
@@ -255,5 +254,4 @@ Home Assistant authenticates with Xbox Live through OAuth2 using the Home Assist
## Setup ## Setup
[Check folder setup](./setup). [Deploy documentation](./deploy/README.md).

51
deploy/README.md Normal file
View File

@@ -0,0 +1,51 @@
# Home Assistant Deploy
## Namespace
```bash { cwd=../ terminalRows=15 }
# from repo root folder
kubectl create namespace home-assistant
```
## Deployment
### Environments requirements
``` bash
#./deploy/.env
export ENDPOINT_IP="xxx.xxx.xxx.xxxx"
export SERVICE_PORT=xxxx
export INGRESS_ROUTES_MATCH="Host(`xxxx`)"
export INGRESS_TLS_SECRET_NAME=xxxxxx
```
## Test Templates
```bash { cwd=../ terminalRows=15 }
# from repo root folder
source ./deploy/.env \
&& cat ./deploy/deployment.yaml \
&& envsubst < ./deploy/service.template.yaml
```
## Deploy
```bash { cwd=../ terminalRows=15 }
# from repo root folder
source ./deploy/.env \
&& kubectl apply -f ./deploy/deployment.yaml \
&& envsubst < ./deploy/service.template.yaml | kubectl apply -f -
```
## Continuos Deploy
All Environment variables requirements as set as secrets.
[gitea workflow](../.gitea/workflows/deploy.yaml)
## cicd RBAC
```bash { cwd=../ }
kubectl apply -f ./deploy/cicd-rbac.yaml
```

34
deploy/cicd-rbac.yaml Normal file
View File

@@ -0,0 +1,34 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: home-assistant
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: home-assistant
subjects:
- kind: ServiceAccount
name: casa-ci-cd
namespace: home-assistant
roleRef:
kind: Role
name: ci-cd
apiGroup: rbac.authorization.k8s.io

View File

@@ -1,7 +1,3 @@
apiVersion: v1
kind: Namespace
metadata:
name: home-assistant
--- ---
apiVersion: v1 apiVersion: v1
@@ -35,15 +31,20 @@ spec:
labels: labels:
app: home-assistant app: home-assistant
spec: spec:
dnsPolicy: ClusterFirstWithHostNet # ensures pod uses cluster DNS (CoreDNS) for service discovery even with host networking
hostNetwork: true hostNetwork: true
# delays start so host have time to start on low memory resources nodeName: casa # force deploy to master node cluster
initContainers: tolerations:
- name: delay-start - key: "node-role.kubernetes.io/control-plane" # allow installation on control-plane
image: busybox:latest operator: "Exists"
command: ["sh", "-c", "sleep 60"] effect: "NoSchedule"
containers: containers:
- name: home-assistant - name: home-assistant
image: "homeassistant/home-assistant" image: "homeassistant/home-assistant"
imagePullPolicy: Always
env:
- name: TZ
value: Europe/Lisbon # set timezone
volumeMounts: volumeMounts:
- name: home-assistant-config - name: home-assistant-config
mountPath: /config mountPath: /config

View File

@@ -1,23 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: home-assistant-external
namespace: home-assistant
spec:
clusterIP: None
ports:
- port: 8123
protocol: TCP
---
apiVersion: v1
kind: Endpoints
metadata:
name: home-assistant-external
namespace: home-assistant
subsets:
- addresses:
- ip: 192.168.14.9 # Replace with your actual external IP
ports:
- port: 8123

View File

@@ -1,22 +0,0 @@
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: home-assistant
namespace: home-assistant
spec:
entryPoints:
- websecure
routes:
- match: Host(`casa.limbosolutions.com`)
kind: Rule
services:
- name: home-assistant-external
port: 8123
- match: Host(`has.casa.limbosolutions.com`)
kind: Rule
services:
- name: home-assistant-external
port: 8123
tls:
secretName: casa-limbosolutions-com-tls

View File

@@ -0,0 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: casa-ci-cd
annotations:
kubernetes.io/service-account.name: casa-ci-cd
type: kubernetes.io/service-account-token

View File

@@ -0,0 +1,6 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: casa-ci-cd
namespace: home-assistant

View File

@@ -0,0 +1,42 @@
apiVersion: v1
kind: Service
metadata:
name: home-assistant
namespace: home-assistant
spec:
clusterIP: None
ports:
- port: ${SERVICE_PORT}
protocol: TCP
---
apiVersion: v1
kind: Endpoints
metadata:
name: home-assistant
namespace: home-assistant
subsets:
- addresses:
- ip: ${ENDPOINT_IP}
ports:
- port: ${SERVICE_PORT}
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: home-assistant
namespace: home-assistant
spec:
entryPoints:
- websecure
routes:
- match: ${INGRESS_ROUTES_MATCH}
kind: Rule
services:
- name: home-assistant
port: ${SERVICE_PORT}
tls:
secretName: ${INGRESS_TLS_SECRET_NAME}

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

View File

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 47 KiB

View File

Before

Width:  |  Height:  |  Size: 128 KiB

After

Width:  |  Height:  |  Size: 128 KiB

View File

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 47 KiB