feat: deploy start using kustomization
All checks were successful
Casa Home Assistant CI/CD Pipeline / deploy (push) Successful in 17s
All checks were successful
Casa Home Assistant CI/CD Pipeline / deploy (push) Successful in 17s
This commit is contained in:
51
deploy/infra/README.md
Normal file
51
deploy/infra/README.md
Normal 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/infra/cicd-rbac.yaml
Normal file
34
deploy/infra/cicd-rbac.yaml
Normal 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
|
||||
7
deploy/infra/service-account-secret.yaml
Normal file
7
deploy/infra/service-account-secret.yaml
Normal 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
|
||||
6
deploy/infra/service-account.yaml
Normal file
6
deploy/infra/service-account.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: casa-ci-cd
|
||||
namespace: home-assistant
|
||||
42
deploy/infra/service.template.yaml
Normal file
42
deploy/infra/service.template.yaml
Normal 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}
|
||||
Reference in New Issue
Block a user