From ff4f8a3a6c033c8b9fcc683fed53be32ed5c94f5 Mon Sep 17 00:00:00 2001 From: Junwei Zhao Date: Mon, 19 Sep 2022 15:52:44 +1000 Subject: [PATCH] add home assisstant --- es/es.yaml | 18 +++++- home-apps/home-assistance.yaml | 105 +++++++++++++++++++++++++++++++++ home-apps/ipsec-vpn.yaml | 90 ++++++++++++++++++++++++++++ 3 files changed, 212 insertions(+), 1 deletion(-) create mode 100644 home-apps/home-assistance.yaml create mode 100644 home-apps/ipsec-vpn.yaml diff --git a/es/es.yaml b/es/es.yaml index 42e7f04..0e422c1 100644 --- a/es/es.yaml +++ b/es/es.yaml @@ -228,7 +228,6 @@ spec: --- - apiVersion: v1 kind: ConfigMap metadata: @@ -251,3 +250,20 @@ data: # xpack.security.enabled: false # logging.silent: false # logging.quiet: false + +--- + +apiVersion: v1 +kind: ConfigMap +metadata: + name: elasticsearch-config + namespace: es +data: + elasticsearch.yml: | + s3: + client: + default: + endpoint: minio.db.svc.cluster.local:9000 + protocol: http + region: ap-southeast-2 + diff --git a/home-apps/home-assistance.yaml b/home-apps/home-assistance.yaml new file mode 100644 index 0000000..22e4489 --- /dev/null +++ b/home-apps/home-assistance.yaml @@ -0,0 +1,105 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + namespace: home-apps + name: ha-pvc +spec: + accessModes: + - ReadWriteOnce + storageClassName: nfs-client + resources: + requests: + storage: 10Gi +--- + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ha + namespace: home-apps + labels: + app: ha +spec: + replicas: 1 + revisionHistoryLimit: 2 + selector: + matchLabels: + app: ha + template: + metadata: + labels: + app: ha + name: ha + spec: + containers: + - name: ha + image: ghcr.io/home-assistant/home-assistant:stable + imagePullPolicy: Always + ports: + - containerPort: 5678 + name: web + protocol: TCP + env: + - name: TZ + value: "Australia/Melbourne" + volumeMounts: + - name: config + mountPath: /config + resources: + requests: + cpu: 200m + memory: 256Mi + limits: + cpu: 300m + memory: 526Mi + volumes: + - name: config + persistentVolumeClaim: + claimName: ha-pvc + +--- + +apiVersion: v1 +kind: Service +metadata: + name: ha + labels: + name: ha +spec: + type: ClusterIP + selector: + app: ha + ports: + - name: ha + targetPort: web + port: 8123 + protocol: TCP + +--- + +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: ha-ingress + annotations: + kubernetes.io/ingress.class: "nginx" + kubernetes.io/tls-acme: "true" + cert-manager.io/cluster-issuer: "letsencrypt-prod" + nginx.ingress.kubernetes.io/auth-url: "https://id.junv.me/oauth2/auth" + nginx.ingress.kubernetes.io/auth-signin: "https://id.junv.me/oauth2/start?rd=https%3A%2F%2F$host$request_uri" +spec: + tls: + - hosts: + - home.junv.me + secretName: ha-tls-new + rules: + - host: home.junv.me + http: + paths: + - backend: + service: + name: ha + port: + number: 80 + path: / + pathType: Prefix diff --git a/home-apps/ipsec-vpn.yaml b/home-apps/ipsec-vpn.yaml new file mode 100644 index 0000000..c60c8f3 --- /dev/null +++ b/home-apps/ipsec-vpn.yaml @@ -0,0 +1,90 @@ +apiVersion: v1 +kind: Service +metadata: + name: ipsec-vpn + namespace: home-apps +spec: + type: NodePort + ports: + - port: 500 + # nodePort: 500 + protocol: UDP + targetPort: 500 + name: ipsec-udp-1 + - port: 4500 + # nodePort: 4500 + protocol: UDP + targetPort: 4500 + name: ipsec-udp-2 + selector: + app: ipsec-vpn + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ipsec-vpn +spec: + revisionHistoryLimit: 2 + selector: + matchLabels: + app: ipsec-vpn + replicas: 1 + template: + metadata: + labels: + app: ipsec-vpn + spec: + containers: + - name: ipsec-vpn + image: hwdsl2/ipsec-vpn-server + env: + - name: VPN_USER + value: happy + - name: VPN_IPSEC_PSK + value: hellovpn!! + - name: VPN_PASSWORD + value: AlwaysHappy!! + resources: + requests: + cpu: 200m + memory: 512Mi + limits: + cpu: 200m + memory: 512Mi + securityContext: + runAsUser: 0 + privileged: true + capabilities: + add: ["NET_ADMIN"] + volumeMounts: + - name: config + mountPath: /etc/ipsec.d + - name: host-volumes + mountPath: /lib/modules + ports: + - containerPort: 500 + protocol: UDP + - containerPort: 4500 + protocol: UDP + volumes: + - name: config + persistentVolumeClaim: + claimName: ipsec-pvc + - name: host-volumes + hostPath: + path: /lib/modules + type: Directory +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + namespace: home-apps + name: ipsec-pvc +spec: + accessModes: + - ReadWriteOnce + storageClassName: nfs-client + resources: + requests: + storage: 1Gi