mirror of
https://github.com/optim-enterprises-bv/homelab.git
synced 2025-11-02 19:08:03 +00:00
feat(apps): Added Home Assistant application
This commit is contained in:
@@ -62,12 +62,4 @@ traefik-cert-pv `PersistentVolume` for persistent storage of certificates using
|
||||
terraform init
|
||||
terraform plan
|
||||
terraform apply
|
||||
```
|
||||
|
||||
## Test application
|
||||
|
||||
If not already created with Terraform run
|
||||
|
||||
```shell
|
||||
kubectl apply -f apps/whoami/00-whoami.yml
|
||||
```
|
||||
@@ -143,13 +143,7 @@ IP can be found with `kubectl get svc`.
|
||||
|
||||
# Test-application
|
||||
|
||||
Create a test-application (if not already created with Terraform) with
|
||||
|
||||
```shell
|
||||
kubectl apply -f apps/whoami/00-whoami.yml
|
||||
```
|
||||
|
||||
`whoami` should now be available at `https://whoami.${DOMAIN}`.
|
||||
A test-application `whoami` should be available at `https://whoami.${DOMAIN}`.
|
||||
|
||||
# Cleanup
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ commonLabels:
|
||||
app: traefik-forward-auth
|
||||
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
- deployment.yaml
|
||||
- middleware.yaml
|
||||
|
||||
configMapGenerator:
|
||||
|
||||
24
apps/home-assistant/home-assistant/deployment.yaml
Normal file
24
apps/home-assistant/home-assistant/deployment.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: home-assistant
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: home-assistant
|
||||
template:
|
||||
spec:
|
||||
volumes:
|
||||
- name: home-assistant-config
|
||||
hostPath:
|
||||
path: "/mnt/sdb1/config/home-assistant"
|
||||
containers:
|
||||
- image: homeassistant/home-assistant
|
||||
name: home-assistant
|
||||
volumeMounts:
|
||||
- mountPath: "/config"
|
||||
name: home-assistant-config
|
||||
ports:
|
||||
- name: web
|
||||
containerPort: 8123
|
||||
@@ -1,9 +1,8 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
commonLabels:
|
||||
app: whoami
|
||||
app: home-assistant
|
||||
|
||||
resources:
|
||||
- service.yaml
|
||||
- deployment.yaml
|
||||
- ingress.yaml
|
||||
4
apps/home-assistant/home-assistant/namespace.yaml
Normal file
4
apps/home-assistant/home-assistant/namespace.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: home-assistant
|
||||
10
apps/home-assistant/home-assistant/service.yaml
Normal file
10
apps/home-assistant/home-assistant/service.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: home-assistant
|
||||
spec:
|
||||
ports:
|
||||
- name: web
|
||||
port: 8123
|
||||
selector:
|
||||
app: home-assistant
|
||||
24
apps/home-assistant/ingress.yaml
Normal file
24
apps/home-assistant/ingress.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
apiVersion: traefik.containo.us/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata:
|
||||
name: ingressroute-arr
|
||||
spec:
|
||||
entryPoints:
|
||||
- websecure
|
||||
routes:
|
||||
- match: Host(`auth-hass.stonegarden.dev`)
|
||||
kind: Rule
|
||||
services:
|
||||
- name: traefik-forward-auth
|
||||
port: 4181
|
||||
middlewares:
|
||||
- name: traefik-forward-auth
|
||||
- match: Host(`hass.stonegarden.dev`)
|
||||
kind: Rule
|
||||
services:
|
||||
- name: home-assistant
|
||||
port: 8123
|
||||
middlewares:
|
||||
- name: traefik-forward-auth
|
||||
tls:
|
||||
certResolver: letsencrypt
|
||||
9
apps/home-assistant/kustomization.yaml
Normal file
9
apps/home-assistant/kustomization.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: home-assistant
|
||||
|
||||
resources:
|
||||
- namespace.yaml
|
||||
- ingress.yaml
|
||||
- traefik-forward-auth
|
||||
- home-assistant
|
||||
4
apps/home-assistant/namespace.yaml
Normal file
4
apps/home-assistant/namespace.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: home-assistant
|
||||
@@ -0,0 +1,5 @@
|
||||
cookie-name = "_hass_auth"
|
||||
log-level = "error"
|
||||
cookie-domain = "stonegarden.dev"
|
||||
auth-host = "auth-hass.stonegarden.dev"
|
||||
whitelist = "veghag@gmail.com, nina.m.smorsgard@gmail.com"
|
||||
50
apps/home-assistant/traefik-forward-auth/deployment.yaml
Normal file
50
apps/home-assistant/traefik-forward-auth/deployment.yaml
Normal file
@@ -0,0 +1,50 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: traefik-forward-auth
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: traefik-forward-auth
|
||||
strategy:
|
||||
type: Recreate
|
||||
template:
|
||||
spec:
|
||||
terminationGracePeriodSeconds: 60
|
||||
containers:
|
||||
- image: thomseddon/traefik-forward-auth:2
|
||||
name: traefik-forward-auth
|
||||
ports:
|
||||
- containerPort: 4181
|
||||
protocol: TCP
|
||||
env:
|
||||
- name: CONFIG
|
||||
value: "/config"
|
||||
- name: PROVIDERS_GOOGLE_CLIENT_ID
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: traefik-forward-auth-secrets
|
||||
key: google-client-id
|
||||
- name: PROVIDERS_GOOGLE_CLIENT_SECRET
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: traefik-forward-auth-secrets
|
||||
key: google-client-secret
|
||||
- name: SECRET
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: traefik-forward-auth-secrets
|
||||
key: secret
|
||||
volumeMounts:
|
||||
- name: configs
|
||||
mountPath: /config
|
||||
subPath: traefik-forward-auth.ini
|
||||
|
||||
volumes:
|
||||
- name: configs
|
||||
configMap:
|
||||
name: configs
|
||||
- name: traefik-forward-auth-secrets
|
||||
secret:
|
||||
secretName: traefik-forward-auth-secrets
|
||||
@@ -4,9 +4,8 @@ commonLabels:
|
||||
app: traefik-forward-auth
|
||||
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
- ingress.yaml
|
||||
- deployment.yaml
|
||||
- middleware.yaml
|
||||
|
||||
configMapGenerator:
|
||||
10
apps/home-assistant/traefik-forward-auth/middleware.yaml
Normal file
10
apps/home-assistant/traefik-forward-auth/middleware.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
apiVersion: traefik.containo.us/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: traefik-forward-auth
|
||||
spec:
|
||||
forwardAuth:
|
||||
address: http://traefik-forward-auth.home-assistant.svc.cluster.local:4181
|
||||
authResponseHeaders:
|
||||
- X-Forwarded-User
|
||||
trustForwardHeader: true
|
||||
11
apps/home-assistant/traefik-forward-auth/service.yaml
Normal file
11
apps/home-assistant/traefik-forward-auth/service.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: traefik-forward-auth
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: traefik-forward-auth
|
||||
ports:
|
||||
- name: auth-http
|
||||
port: 4181
|
||||
8
apps/kustomization.yaml
Normal file
8
apps/kustomization.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- arr
|
||||
- plex
|
||||
- home-assistant
|
||||
- whoami
|
||||
@@ -1,17 +0,0 @@
|
||||
apiVersion: traefik.containo.us/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata:
|
||||
name: whoami
|
||||
spec:
|
||||
entryPoints:
|
||||
- websecure
|
||||
routes:
|
||||
- match: Host(`whoami.stonegarden.dev`)
|
||||
kind: Rule
|
||||
services:
|
||||
- name: whoami
|
||||
port: 80
|
||||
middlewares:
|
||||
- name: traefik-forward-auth
|
||||
tls:
|
||||
certResolver: letsencrypt
|
||||
@@ -1,66 +0,0 @@
|
||||
# Namespace for whoami
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: whoami
|
||||
|
||||
---
|
||||
# Service for exposing deployment of whoami
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
namespace: whoami
|
||||
name: whoami
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: whoami
|
||||
ports:
|
||||
- protocol: TCP
|
||||
name: web
|
||||
port: 80
|
||||
|
||||
---
|
||||
# Deployment of whoami
|
||||
kind: Deployment
|
||||
apiVersion: apps/v1
|
||||
metadata:
|
||||
namespace: whoami
|
||||
name: whoami
|
||||
labels:
|
||||
app: whoami
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: whoami
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: whoami
|
||||
spec:
|
||||
containers:
|
||||
- name: whoami
|
||||
image: traefik/whoami
|
||||
ports:
|
||||
- name: web
|
||||
containerPort: 80
|
||||
|
||||
---
|
||||
# IngressRoute for secure whoami address
|
||||
apiVersion: traefik.containo.us/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata:
|
||||
name: ingressroute-whoami
|
||||
namespace: whoami
|
||||
spec:
|
||||
entryPoints:
|
||||
- websecure
|
||||
routes:
|
||||
- match: Host(`whoami.stonegarden.dev`)
|
||||
kind: Rule
|
||||
services:
|
||||
- name: whoami
|
||||
port: 80
|
||||
tls:
|
||||
certResolver: letsencrypt
|
||||
@@ -11,12 +11,19 @@ spec:
|
||||
entryPoints:
|
||||
- websecure
|
||||
routes:
|
||||
- match: Host(`auth.stonegarden.dev`)
|
||||
- match: Host(`auth-whoami.stonegarden.dev`)
|
||||
kind: Rule
|
||||
services:
|
||||
- name: traefik-forward-auth
|
||||
port: 4181
|
||||
middlewares:
|
||||
- name: traefik-forward-auth
|
||||
- match: Host(`whoami.stonegarden.dev`)
|
||||
kind: Rule
|
||||
services:
|
||||
- name: whoami
|
||||
port: 80
|
||||
middlewares:
|
||||
- name: traefik-forward-auth
|
||||
tls:
|
||||
certResolver: letsencrypt
|
||||
@@ -4,5 +4,6 @@ namespace: whoami
|
||||
|
||||
resources:
|
||||
- namespace.yaml
|
||||
- ingress.yaml
|
||||
- traefik-forward-auth
|
||||
- whoami
|
||||
@@ -1,5 +1,5 @@
|
||||
cookie-name = "_whoami_auth"
|
||||
log-level = "error"
|
||||
cookie-domain = "stonegarden.dev"
|
||||
auth-host = "auth.stonegarden.dev"
|
||||
whitelist = "veghag@gmail.com"
|
||||
auth-host = "auth-whoami.stonegarden.dev"
|
||||
domain = "gmail.com"
|
||||
19
apps/whoami/traefik-forward-auth/kustomization.yaml
Normal file
19
apps/whoami/traefik-forward-auth/kustomization.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
commonLabels:
|
||||
app: traefik-forward-auth
|
||||
|
||||
resources:
|
||||
- service.yaml
|
||||
- deployment.yaml
|
||||
- middleware.yaml
|
||||
|
||||
configMapGenerator:
|
||||
- name: configs
|
||||
files:
|
||||
- configs/traefik-forward-auth.ini
|
||||
|
||||
secretGenerator:
|
||||
- name: traefik-forward-auth-secrets
|
||||
envs:
|
||||
- secrets/traefik-forward-auth.env
|
||||
8
apps/whoami/whoami/kustomization.yaml
Normal file
8
apps/whoami/whoami/kustomization.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
commonLabels:
|
||||
app: whoami
|
||||
|
||||
resources:
|
||||
- service.yaml
|
||||
- deployment.yaml
|
||||
174
main.tf
174
main.tf
@@ -90,64 +90,63 @@ resource "helm_release" "traefik" {
|
||||
values = [file("helm/traefik-values.yaml")]
|
||||
}
|
||||
|
||||
# --- whoami
|
||||
#resource "kubernetes_namespace" "whoami" {
|
||||
# metadata {
|
||||
# name = "whoami"
|
||||
# }
|
||||
#}
|
||||
#
|
||||
#resource "kubernetes_service" "whoami" {
|
||||
# metadata {
|
||||
# name = "whoami"
|
||||
# namespace = kubernetes_namespace.whoami.metadata.0.name
|
||||
# }
|
||||
# spec {
|
||||
# selector = {
|
||||
# app = kubernetes_deployment.whoami.spec.0.template.0.metadata.0.labels.app
|
||||
# }
|
||||
#
|
||||
# type = "LoadBalancer"
|
||||
# port {
|
||||
# protocol = "TCP"
|
||||
# name = "web"
|
||||
# port = 80
|
||||
# }
|
||||
# }
|
||||
#}
|
||||
#
|
||||
#resource "kubernetes_deployment" "whoami" {
|
||||
# metadata {
|
||||
# name = "whoami"
|
||||
# namespace = kubernetes_namespace.whoami.metadata.0.name
|
||||
# }
|
||||
# spec {
|
||||
# replicas = "2"
|
||||
# selector {
|
||||
# match_labels = {
|
||||
# app = "whoami"
|
||||
# }
|
||||
# }
|
||||
# template {
|
||||
# metadata {
|
||||
# labels = {
|
||||
# app = "whoami"
|
||||
# }
|
||||
# }
|
||||
# spec {
|
||||
# container {
|
||||
# name = "whoami"
|
||||
# image = "traefik/whoami"
|
||||
# port {
|
||||
# name = "web"
|
||||
# container_port = 80
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
#}
|
||||
#
|
||||
resource "kubernetes_namespace" "whoami" {
|
||||
metadata {
|
||||
name = "whoami"
|
||||
}
|
||||
}
|
||||
|
||||
resource "kubernetes_service" "whoami" {
|
||||
metadata {
|
||||
name = "whoami"
|
||||
namespace = kubernetes_namespace.whoami.metadata.0.name
|
||||
}
|
||||
spec {
|
||||
selector = {
|
||||
app = kubernetes_deployment.whoami.spec.0.template.0.metadata.0.labels.app
|
||||
}
|
||||
|
||||
type = "LoadBalancer"
|
||||
port {
|
||||
protocol = "TCP"
|
||||
name = "web"
|
||||
port = 80
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "kubernetes_deployment" "whoami" {
|
||||
metadata {
|
||||
name = "whoami"
|
||||
namespace = kubernetes_namespace.whoami.metadata.0.name
|
||||
}
|
||||
spec {
|
||||
replicas = "2"
|
||||
selector {
|
||||
match_labels = {
|
||||
app = "whoami"
|
||||
}
|
||||
}
|
||||
template {
|
||||
metadata {
|
||||
labels = {
|
||||
app = "whoami"
|
||||
}
|
||||
}
|
||||
spec {
|
||||
container {
|
||||
name = "whoami"
|
||||
image = "traefik/whoami"
|
||||
port {
|
||||
name = "web"
|
||||
container_port = 80
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#resource "helm_release" "whoami" {
|
||||
# name = "whoami"
|
||||
# repository = "https://charts.itscontained.io"
|
||||
@@ -155,61 +154,4 @@ resource "helm_release" "traefik" {
|
||||
# version = "0.2.5"
|
||||
#
|
||||
# values = [file("helm/whoami-values.yaml")]
|
||||
#}
|
||||
|
||||
//resource "kubernetes_namespace" "test" {
|
||||
// metadata {
|
||||
// name = "nginx"
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//resource "kubernetes_service" "test" {
|
||||
// metadata {
|
||||
// name = "nginx"
|
||||
// namespace = kubernetes_namespace.test.metadata.0.name
|
||||
// }
|
||||
// spec {
|
||||
// selector = {
|
||||
// app = kubernetes_deployment.test.spec.0.template.0.metadata.0.labels.app
|
||||
// }
|
||||
//
|
||||
// type = "LoadBalancer"
|
||||
// port {
|
||||
// protocol = "TCP"
|
||||
// port = 80
|
||||
// target_port = 80
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//resource "kubernetes_deployment" "test" {
|
||||
// metadata {
|
||||
// name = "nginx"
|
||||
// namespace = kubernetes_namespace.test.metadata.0.name
|
||||
// }
|
||||
// spec {
|
||||
// replicas = 2
|
||||
// selector {
|
||||
// match_labels = {
|
||||
// app = "MyTestApp"
|
||||
// }
|
||||
// }
|
||||
// template {
|
||||
// metadata {
|
||||
// labels = {
|
||||
// app = "MyTestApp"
|
||||
// }
|
||||
// }
|
||||
// spec {
|
||||
// container {
|
||||
// image = "nginx"
|
||||
// name = "nginx-container"
|
||||
// port {
|
||||
// container_port = 80
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
#}
|
||||
Reference in New Issue
Block a user