From 945d73589619c4c89d600a03da9df98afb34f162 Mon Sep 17 00:00:00 2001 From: wserr Date: Mon, 20 Jun 2022 19:24:42 +0200 Subject: [PATCH] update helm chart + development machine instructions --- Development.md | 45 +++++++++++++++++++++++++++++ helm/Chart.yaml | 2 ++ helm/README.md | 3 ++ helm/templates/MQTT/configmap.yml | 0 helm/templates/MQTT/pvc.yml | 12 ++++++++ helm/templates/MQTT/service.yml | 0 helm/templates/MQTT/statefulset.yml | 28 ++++++++++++++++++ 7 files changed, 90 insertions(+) create mode 100644 Development.md create mode 100644 helm/Chart.yaml create mode 100644 helm/README.md create mode 100644 helm/templates/MQTT/configmap.yml create mode 100644 helm/templates/MQTT/pvc.yml create mode 100644 helm/templates/MQTT/service.yml create mode 100644 helm/templates/MQTT/statefulset.yml diff --git a/Development.md b/Development.md new file mode 100644 index 0000000..b4748bb --- /dev/null +++ b/Development.md @@ -0,0 +1,45 @@ +# Development setup + +## Install kubectl on client machine + +See [installation tutorial here](https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/) + +## Install helm on client machine + +See [installation tutorial here](https://helm.sh/docs/intro/install/) + +## Configure cluster with kubectl + +- Get cluster info with command `microk8s config` +- Add the cluster info to the kubectl config file on the client machine at `~/.kube/config` + +Example config file + +```bash +apiVersion: v1 +clusters: +- cluster: + certificate-authority-data: + ...... + server: https://63.250.54.81:16443 + name: homeserver +contexts: +- context: + cluster: homeserver + user: admin + name: homeserver +current-context: homeserver +kind: Config +preferences: {} +users: +- name: admin + user: + token: TnNDNURIV1I3RFdFMFora1NEaTdlNi9uNEgwR0pHRVRVajdPeFFrYWUvND0K +``` + +- In config file above, change context name +- To use this cluster with kubectl, enter `kubectl config use-context homeserver` + +## Configure cluster with helm + +- Run `helm --kube-context homeserver` diff --git a/helm/Chart.yaml b/helm/Chart.yaml new file mode 100644 index 0000000..98b3ae6 --- /dev/null +++ b/helm/Chart.yaml @@ -0,0 +1,2 @@ +name: homeautomation +version: 0.0.1 diff --git a/helm/README.md b/helm/README.md new file mode 100644 index 0000000..dc85335 --- /dev/null +++ b/helm/README.md @@ -0,0 +1,3 @@ +# Helm + +This folder contains the helm template for my home automation setup. \ No newline at end of file diff --git a/helm/templates/MQTT/configmap.yml b/helm/templates/MQTT/configmap.yml new file mode 100644 index 0000000..e69de29 diff --git a/helm/templates/MQTT/pvc.yml b/helm/templates/MQTT/pvc.yml new file mode 100644 index 0000000..323d3b9 --- /dev/null +++ b/helm/templates/MQTT/pvc.yml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: mosquitto-pvc +spec: + accessModes: + - ReadWriteOnce + storageClassName: microk8s-hostpath + resources: + requests: + storage: 1Gi + diff --git a/helm/templates/MQTT/service.yml b/helm/templates/MQTT/service.yml new file mode 100644 index 0000000..e69de29 diff --git a/helm/templates/MQTT/statefulset.yml b/helm/templates/MQTT/statefulset.yml new file mode 100644 index 0000000..413e0a8 --- /dev/null +++ b/helm/templates/MQTT/statefulset.yml @@ -0,0 +1,28 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: mosquitto +spec: + serviceName: mosquitto + selector: + matchLabels: + app: mosquitto + replicas: 1 + template: + metadata: + labels: + app: mosquitto + spec: + containers: + - name: mosquitto + image: eclipse-mosquitto + imagePullPolicy: "IfNotPresent" + ports: + - containerPort: 5432 + volumeMounts: + - name: mosquitto-data + mountPath: /mosquitto/data + volumes: + - name: mosquitto-data + persistentVolumeClaim: + claimName: mosquitto-pvc \ No newline at end of file