add home assistant A record; add wg user[ci skip]
This commit is contained in:
parent
bf10de9255
commit
6609920550
1 changed files with 188 additions and 203 deletions
|
|
@ -2,52 +2,35 @@ variable "tls_secret_name" {}
|
||||||
variable "client_certificate_secret_name" {}
|
variable "client_certificate_secret_name" {}
|
||||||
variable "configuration_yaml" {}
|
variable "configuration_yaml" {}
|
||||||
|
|
||||||
resource "kubernetes_namespace" "home_assistant" {
|
# resource "kubernetes_namespace" "home_assistant" {
|
||||||
metadata {
|
# metadata {
|
||||||
name = "home-assistant"
|
# name = "home-assistant"
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
|
||||||
resource "kubernetes_persistent_volume" "home_assistant_pv" {
|
# resource "kubernetes_config_map" "home_assistant_config_map" {
|
||||||
metadata {
|
# metadata {
|
||||||
name = "home-assistant-pv"
|
# name = "home-assistant-configmap"
|
||||||
}
|
# namespace = "home-assistant"
|
||||||
spec {
|
|
||||||
capacity = {
|
|
||||||
storage = "2Gi"
|
|
||||||
}
|
|
||||||
access_modes = ["ReadWriteMany"]
|
|
||||||
persistent_volume_source {
|
|
||||||
vsphere_volume {
|
|
||||||
volume_path = "/config"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "kubernetes_config_map" "home_assistant_config_map" {
|
# annotations = {
|
||||||
metadata {
|
# "reloader.stakater.com/match" = "true"
|
||||||
name = "home-assistant-configmap"
|
# }
|
||||||
namespace = "home-assistant"
|
# }
|
||||||
|
|
||||||
annotations = {
|
# data = {
|
||||||
"reloader.stakater.com/match" = "true"
|
# # "db.viktorbarzin.lan" = var.db_viktorbarzin_lan
|
||||||
}
|
# # "db.viktorbarzin.me" = format("%s%s", var.db_viktorbarzin_me, file("${path.module}/extra/viktorbarzin.me"))
|
||||||
}
|
# # "db.181.191.213.in-addr.arpa" = var.db_ptr
|
||||||
|
# "configuration.yaml" = var.configuration_yaml
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
|
||||||
data = {
|
# module "tls_secret" {
|
||||||
# "db.viktorbarzin.lan" = var.db_viktorbarzin_lan
|
# source = "../setup_tls_secret"
|
||||||
# "db.viktorbarzin.me" = format("%s%s", var.db_viktorbarzin_me, file("${path.module}/extra/viktorbarzin.me"))
|
# namespace = "home-assistant"
|
||||||
# "db.181.191.213.in-addr.arpa" = var.db_ptr
|
# tls_secret_name = var.tls_secret_name
|
||||||
"configuration.yaml" = var.configuration_yaml
|
# }
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module "tls_secret" {
|
|
||||||
source = "../setup_tls_secret"
|
|
||||||
namespace = "home-assistant"
|
|
||||||
tls_secret_name = var.tls_secret_name
|
|
||||||
}
|
|
||||||
|
|
||||||
# resource "helm_release" "home_assistant" {
|
# resource "helm_release" "home_assistant" {
|
||||||
# namespace = "home-assistant"
|
# namespace = "home-assistant"
|
||||||
|
|
@ -60,194 +43,196 @@ module "tls_secret" {
|
||||||
# values = [templatefile("${path.module}/home_assistant_chart_values.tpl", { tls_secret_name = var.tls_secret_name, client_certificate_secret_name = var.client_certificate_secret_name })]
|
# values = [templatefile("${path.module}/home_assistant_chart_values.tpl", { tls_secret_name = var.tls_secret_name, client_certificate_secret_name = var.client_certificate_secret_name })]
|
||||||
# }
|
# }
|
||||||
|
|
||||||
resource "kubernetes_deployment" "home_assistant" {
|
# resource "kubernetes_deployment" "home_assistant" {
|
||||||
metadata {
|
# metadata {
|
||||||
name = "home-assistant"
|
# name = "home-assistant"
|
||||||
namespace = "home-assistant"
|
# namespace = "home-assistant"
|
||||||
|
|
||||||
labels = {
|
# labels = {
|
||||||
"app.kubernetes.io/instance" = "home-assistant"
|
# "app.kubernetes.io/instance" = "home-assistant"
|
||||||
"app.kubernetes.io/name" = "home-assistant"
|
# "app.kubernetes.io/name" = "home-assistant"
|
||||||
"app.kubernetes.io/version" = "2022.5.4"
|
# "app.kubernetes.io/version" = "2022.5.4"
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
|
||||||
spec {
|
# spec {
|
||||||
replicas = 1
|
# replicas = 1
|
||||||
|
|
||||||
selector {
|
# selector {
|
||||||
match_labels = {
|
# match_labels = {
|
||||||
"app.kubernetes.io/instance" = "home-assistant"
|
# "app.kubernetes.io/instance" = "home-assistant"
|
||||||
"app.kubernetes.io/name" = "home-assistant"
|
# "app.kubernetes.io/name" = "home-assistant"
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
|
||||||
template {
|
# template {
|
||||||
metadata {
|
# metadata {
|
||||||
labels = {
|
# labels = {
|
||||||
"app.kubernetes.io/instance" = "home-assistant"
|
# "app.kubernetes.io/instance" = "home-assistant"
|
||||||
|
|
||||||
"app.kubernetes.io/name" = "home-assistant"
|
# "app.kubernetes.io/name" = "home-assistant"
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
|
||||||
spec {
|
# spec {
|
||||||
container {
|
# container {
|
||||||
name = "home-assistant"
|
# name = "home-assistant"
|
||||||
image = "ghcr.io/home-assistant/home-assistant:2022.5.4"
|
# # image = "ghcr.io/home-assistant/home-assistant:2022.5.4"
|
||||||
port {
|
# image = "ghcr.io/home-assistant/home-assistant:2022.5.5"
|
||||||
name = "http"
|
# # image = "ghcr.io/home-assistant/home-assistant"
|
||||||
container_port = 8123
|
# port {
|
||||||
protocol = "TCP"
|
# name = "http"
|
||||||
}
|
# container_port = 8123
|
||||||
env {
|
# protocol = "TCP"
|
||||||
name = "TZ"
|
# }
|
||||||
value = "UTC+3"
|
# env {
|
||||||
}
|
# name = "TZ"
|
||||||
|
# value = "UTC+3"
|
||||||
|
# }
|
||||||
|
|
||||||
volume_mount {
|
# volume_mount {
|
||||||
name = "configuration"
|
# name = "configuration"
|
||||||
mount_path = "/config"
|
# mount_path = "/config"
|
||||||
# sub_path = "hackmd"
|
# # sub_path = "hackmd"
|
||||||
}
|
# }
|
||||||
liveness_probe {
|
# liveness_probe {
|
||||||
tcp_socket {
|
# tcp_socket {
|
||||||
port = "8123"
|
# port = "8123"
|
||||||
}
|
# }
|
||||||
timeout_seconds = 1
|
# timeout_seconds = 1
|
||||||
period_seconds = 10
|
# period_seconds = 10
|
||||||
success_threshold = 1
|
# success_threshold = 1
|
||||||
failure_threshold = 3
|
# failure_threshold = 3
|
||||||
}
|
# }
|
||||||
|
|
||||||
readiness_probe {
|
# readiness_probe {
|
||||||
tcp_socket {
|
# tcp_socket {
|
||||||
port = "8123"
|
# port = "8123"
|
||||||
}
|
# }
|
||||||
|
|
||||||
timeout_seconds = 1
|
# timeout_seconds = 1
|
||||||
period_seconds = 10
|
# period_seconds = 10
|
||||||
success_threshold = 1
|
# success_threshold = 1
|
||||||
failure_threshold = 3
|
# failure_threshold = 3
|
||||||
}
|
# }
|
||||||
|
|
||||||
startup_probe {
|
# startup_probe {
|
||||||
tcp_socket {
|
# tcp_socket {
|
||||||
port = "8123"
|
# port = "8123"
|
||||||
}
|
# }
|
||||||
|
|
||||||
timeout_seconds = 1
|
# timeout_seconds = 1
|
||||||
period_seconds = 5
|
# period_seconds = 5
|
||||||
success_threshold = 1
|
# success_threshold = 1
|
||||||
failure_threshold = 30
|
# failure_threshold = 30
|
||||||
}
|
# }
|
||||||
|
|
||||||
termination_message_path = "/dev/termination-log"
|
# termination_message_path = "/dev/termination-log"
|
||||||
image_pull_policy = "IfNotPresent"
|
# image_pull_policy = "IfNotPresent"
|
||||||
}
|
# }
|
||||||
|
|
||||||
volume {
|
# volume {
|
||||||
name = "configuration"
|
# name = "configuration"
|
||||||
iscsi {
|
# iscsi {
|
||||||
target_portal = "iscsi.viktorbarzin.lan:3260"
|
# target_portal = "iscsi.viktorbarzin.lan:3260"
|
||||||
fs_type = "ext4"
|
# fs_type = "ext4"
|
||||||
iqn = "iqn.2020-12.lan.viktorbarzin:storage:home-assistant"
|
# iqn = "iqn.2020-12.lan.viktorbarzin:storage:home-assistant"
|
||||||
lun = 0
|
# lun = 0
|
||||||
read_only = false
|
# read_only = false
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
|
||||||
restart_policy = "Always"
|
# restart_policy = "Always"
|
||||||
termination_grace_period_seconds = 30
|
# termination_grace_period_seconds = 30
|
||||||
dns_policy = "ClusterFirst"
|
# dns_policy = "ClusterFirst"
|
||||||
service_account_name = "default"
|
# service_account_name = "default"
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
|
||||||
strategy {
|
# strategy {
|
||||||
type = "Recreate"
|
# type = "Recreate"
|
||||||
}
|
# }
|
||||||
revision_history_limit = 3
|
# revision_history_limit = 3
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
resource "kubernetes_service" "home_assistant" {
|
# resource "kubernetes_service" "home_assistant" {
|
||||||
metadata {
|
# metadata {
|
||||||
name = "home-assistant"
|
# name = "home-assistant"
|
||||||
namespace = "home-assistant"
|
# namespace = "home-assistant"
|
||||||
|
|
||||||
labels = {
|
# labels = {
|
||||||
"app.kubernetes.io/instance" = "home-assistant"
|
# "app.kubernetes.io/instance" = "home-assistant"
|
||||||
|
|
||||||
"app.kubernetes.io/managed-by" = "Helm"
|
# "app.kubernetes.io/managed-by" = "Helm"
|
||||||
|
|
||||||
"app.kubernetes.io/name" = "home-assistant"
|
# "app.kubernetes.io/name" = "home-assistant"
|
||||||
|
|
||||||
"app.kubernetes.io/version" = "2022.5.4"
|
# "app.kubernetes.io/version" = "2022.5.4"
|
||||||
|
|
||||||
"helm.sh/chart" = "home-assistant-13.2.0"
|
# "helm.sh/chart" = "home-assistant-13.2.0"
|
||||||
}
|
# }
|
||||||
|
|
||||||
annotations = {
|
# annotations = {
|
||||||
"meta.helm.sh/release-name" = "home-assistant"
|
# "meta.helm.sh/release-name" = "home-assistant"
|
||||||
|
|
||||||
"meta.helm.sh/release-namespace" = "home-assistant"
|
# "meta.helm.sh/release-namespace" = "home-assistant"
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
|
||||||
spec {
|
# spec {
|
||||||
port {
|
# port {
|
||||||
name = "http"
|
# name = "http"
|
||||||
protocol = "TCP"
|
# protocol = "TCP"
|
||||||
port = 8123
|
# port = 8123
|
||||||
target_port = "http"
|
# target_port = "http"
|
||||||
}
|
# }
|
||||||
|
|
||||||
selector = {
|
# selector = {
|
||||||
"app.kubernetes.io/instance" = "home-assistant"
|
# "app.kubernetes.io/instance" = "home-assistant"
|
||||||
|
|
||||||
"app.kubernetes.io/name" = "home-assistant"
|
# "app.kubernetes.io/name" = "home-assistant"
|
||||||
}
|
# }
|
||||||
|
|
||||||
# cluster_ip = "10.102.20.150"
|
# # cluster_ip = "10.102.20.150"
|
||||||
type = "ClusterIP"
|
# type = "ClusterIP"
|
||||||
session_affinity = "None"
|
# session_affinity = "None"
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resource "kubernetes_ingress_v1" "home-assistant-ui" {
|
# resource "kubernetes_ingress_v1" "home-assistant-ui" {
|
||||||
metadata {
|
# metadata {
|
||||||
name = "home-assistant-ui-ingress"
|
# name = "home-assistant-ui-ingress"
|
||||||
namespace = "home-assistant"
|
# namespace = "home-assistant"
|
||||||
annotations = {
|
# annotations = {
|
||||||
"kubernetes.io/ingress.class" = "nginx"
|
# "kubernetes.io/ingress.class" = "nginx"
|
||||||
"nginx.ingress.kubernetes.io/force-ssl-redirect" = "true"
|
# "nginx.ingress.kubernetes.io/force-ssl-redirect" = "true"
|
||||||
"nginx.ingress.kubernetes.io/auth-tls-verify-client" = "on"
|
# "nginx.ingress.kubernetes.io/auth-tls-verify-client" = "on"
|
||||||
"nginx.ingress.kubernetes.io/auth-tls-secret" = var.client_certificate_secret_name
|
# "nginx.ingress.kubernetes.io/auth-tls-secret" = var.client_certificate_secret_name
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
|
||||||
spec {
|
# spec {
|
||||||
tls {
|
# tls {
|
||||||
hosts = ["home-assistant.viktorbarzin.me"]
|
# hosts = ["home-assistant.viktorbarzin.me"]
|
||||||
secret_name = var.tls_secret_name
|
# secret_name = var.tls_secret_name
|
||||||
}
|
# }
|
||||||
rule {
|
# rule {
|
||||||
host = "home-assistant.viktorbarzin.me"
|
# host = "home-assistant.viktorbarzin.me"
|
||||||
http {
|
# http {
|
||||||
path {
|
# path {
|
||||||
path = "/"
|
# path = "/"
|
||||||
backend {
|
# backend {
|
||||||
service {
|
# service {
|
||||||
name = "home-assistant"
|
# name = "home-assistant"
|
||||||
port {
|
# port {
|
||||||
number = 8123
|
# number = 8123
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue