diff --git a/RabbitMQ/Dockerfile b/RabbitMQ/Dockerfile new file mode 100644 index 0000000..a19716d --- /dev/null +++ b/RabbitMQ/Dockerfile @@ -0,0 +1,2 @@ +FROM rabbitmq:management +RUN rabbitmq-plugins enable --offline rabbitmq_mqtt \ No newline at end of file diff --git a/RabbitMQ/push.sh b/RabbitMQ/push.sh new file mode 100755 index 0000000..743a7e8 --- /dev/null +++ b/RabbitMQ/push.sh @@ -0,0 +1,2 @@ +docker build -t registry.willemserruys.com/rabbitmq . +docker push registry.willemserruys.com/rabbitmq:latest \ No newline at end of file diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 98b3ae6..b43a021 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -1,2 +1,2 @@ name: homeautomation -version: 0.0.1 +version: 0.0.2 diff --git a/helm/scripts/install.sh b/helm/scripts/install.sh index 4a5f589..fabfaf5 100755 --- a/helm/scripts/install.sh +++ b/helm/scripts/install.sh @@ -1 +1 @@ -helm --kube-context homeserver install -n test test ../ \ No newline at end of file +helm --kube-context homeserver install -f ../values-homeserver.yml -n test test ../ \ No newline at end of file diff --git a/helm/scripts/registry-secret.sh b/helm/scripts/registry-secret.sh new file mode 100755 index 0000000..723ca6e --- /dev/null +++ b/helm/scripts/registry-secret.sh @@ -0,0 +1,6 @@ +kubectl create secret docker-registry regcred +--docker-server=XXX +--docker-username=XXX +--docker-password=XXX +--docker-email=XXX +-n XXX \ No newline at end of file diff --git a/helm/scripts/upgrade.sh b/helm/scripts/upgrade.sh new file mode 100755 index 0000000..6f6cfe5 --- /dev/null +++ b/helm/scripts/upgrade.sh @@ -0,0 +1 @@ +helm --kube-context homeserver upgrade -f ../values-homeserver.yml -n test test ../ \ No newline at end of file diff --git a/helm/templates/HomeAssistant/pv.yml b/helm/templates/HomeAssistant/pv.yml new file mode 100644 index 0000000..6b9430e --- /dev/null +++ b/helm/templates/HomeAssistant/pv.yml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: homeassistant-pv +spec: + capacity: + storage: 1Gi + volumeMode: Filesystem + accessModes: + - ReadWriteOnce + storageClassName: local-storage + local: + path: {{ .Values.homeassistant.config_folder }} + nodeAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - {{ .Values.general.hostname }} \ No newline at end of file diff --git a/helm/templates/MQTT/pvc.yml b/helm/templates/HomeAssistant/pvc.yml similarity index 69% rename from helm/templates/MQTT/pvc.yml rename to helm/templates/HomeAssistant/pvc.yml index 8fd0a9f..d2bbb17 100644 --- a/helm/templates/MQTT/pvc.yml +++ b/helm/templates/HomeAssistant/pvc.yml @@ -1,11 +1,11 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: - name: rabbitmq-pvc + name: homeassistant-pvc spec: accessModes: - ReadWriteOnce - storageClassName: microk8s-hostpath + storageClassName: local-storage resources: requests: storage: 1Gi diff --git a/helm/templates/HomeAssistant/service.yml b/helm/templates/HomeAssistant/service.yml new file mode 100644 index 0000000..4833bff --- /dev/null +++ b/helm/templates/HomeAssistant/service.yml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: homeassistant +spec: + type: NodePort + ports: + - port: 8123 + name: portal + targetPort: 8123 + nodePort: {{ .Values.homeassistant.portal_nodePort }} + protocol: TCP + selector: + app: homeassistant diff --git a/helm/templates/HomeAssistant/statefulset.yml b/helm/templates/HomeAssistant/statefulset.yml new file mode 100644 index 0000000..f22e04d --- /dev/null +++ b/helm/templates/HomeAssistant/statefulset.yml @@ -0,0 +1,28 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: homeassistant +spec: + serviceName: homeassistant + selector: + matchLabels: + app: homeassistant + replicas: 1 + template: + metadata: + labels: + app: homeassistant + spec: + containers: + - name: homeassistant + image: ghcr.io/home-assistant/home-assistant:stable + imagePullPolicy: "IfNotPresent" + ports: + - containerPort: 8123 + volumeMounts: + - name: homeassistant-config + mountPath: /config + volumes: + - name: homeassistant-config + persistentVolumeClaim: + claimName: homeassistant-pvc \ No newline at end of file diff --git a/helm/templates/MQTT/configmap.yml b/helm/templates/MQTT/configmap.yml deleted file mode 100644 index e69de29..0000000 diff --git a/helm/templates/MQTT/statefulset.yml b/helm/templates/MQTT/deployment.yml similarity index 50% rename from helm/templates/MQTT/statefulset.yml rename to helm/templates/MQTT/deployment.yml index 7ab86a1..fecf5c0 100644 --- a/helm/templates/MQTT/statefulset.yml +++ b/helm/templates/MQTT/deployment.yml @@ -1,9 +1,8 @@ apiVersion: apps/v1 -kind: StatefulSet +kind: Deployment metadata: name: rabbitmq spec: - serviceName: rabbitmq selector: matchLabels: app: rabbitmq @@ -15,15 +14,10 @@ spec: spec: containers: - name: rabbitmq - image: rabbitmq:management + image: registry.willemserruys.com/rabbitmq imagePullPolicy: "IfNotPresent" ports: - - containerPort: 5672 + - containerPort: 1883 - containerPort: 15672 - volumeMounts: - - name: rabbitmq-data - mountPath: /rabbitmq/data - volumes: - - name: rabbitmq-data - persistentVolumeClaim: - claimName: rabbitmq-pvc \ No newline at end of file + imagePullSecrets: + - name: regcred \ No newline at end of file diff --git a/helm/templates/MQTT/service.yml b/helm/templates/MQTT/service.yml index 611db43..a47880e 100644 --- a/helm/templates/MQTT/service.yml +++ b/helm/templates/MQTT/service.yml @@ -5,15 +5,15 @@ metadata: spec: type: NodePort ports: - - port: 5672 - name: messagebus - targetPort: 5672 - nodePort: 30001 + - port: 1883 + name: mqtt + targetPort: 1883 + nodePort: {{ .Values.rabbitmq.mqtt_nodePort }} protocol: TCP - port: 15672 name: portal targetPort: 15672 - nodePort: 30002 + nodePort: {{ .Values.rabbitmq.portal_nodePort }} protocol: TCP selector: app: rabbitmq diff --git a/helm/values-homeserver.yml b/helm/values-homeserver.yml new file mode 100644 index 0000000..a8064ae --- /dev/null +++ b/helm/values-homeserver.yml @@ -0,0 +1,11 @@ +general: +# This should be the name of your PC + hostname: willem-server + +rabbitmq: + mqtt_nodePort: 30001 + portal_nodePort: 30002 + +homeassistant: + portal_nodePort: 30003 + config_folder: /home/willem/homeassistant/config \ No newline at end of file