refactor home assistant module [ci skip]

This commit is contained in:
Viktor Barzin 2024-01-08 22:45:55 +00:00
parent eb793c3295
commit 45558f8a04
2 changed files with 202 additions and 202 deletions

View file

@ -2,237 +2,237 @@ 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_config_map" "home_assistant_config_map" { resource "kubernetes_config_map" "home_assistant_config_map" {
# metadata { metadata {
# name = "home-assistant-configmap" name = "home-assistant-configmap"
# namespace = "home-assistant" namespace = "home-assistant"
# annotations = { annotations = {
# "reloader.stakater.com/match" = "true" "reloader.stakater.com/match" = "true"
# } }
# } }
# data = { data = {
# # "db.viktorbarzin.lan" = var.db_viktorbarzin_lan # "db.viktorbarzin.lan" = var.db_viktorbarzin_lan
# # "db.viktorbarzin.me" = format("%s%s", var.db_viktorbarzin_me, file("${path.module}/extra/viktorbarzin.me")) # "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 # "db.181.191.213.in-addr.arpa" = var.db_ptr
# "configuration.yaml" = var.configuration_yaml "configuration.yaml" = var.configuration_yaml
# } }
# } }
# module "tls_secret" { module "tls_secret" {
# source = "../setup_tls_secret" source = "../setup_tls_secret"
# namespace = "home-assistant" namespace = "home-assistant"
# tls_secret_name = var.tls_secret_name tls_secret_name = var.tls_secret_name
# } }
# resource "helm_release" "home_assistant" { resource "helm_release" "home_assistant" {
# namespace = "home-assistant" namespace = "home-assistant"
# create_namespace = true create_namespace = true
# name = "home-assistant" name = "home-assistant"
# repository = "https://k8s-at-home.com/charts/" repository = "https://k8s-at-home.com/charts/"
# chart = "home-assistant" chart = "home-assistant"
# 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"
# image = "ghcr.io/home-assistant/home-assistant:2022.5.5" image = "ghcr.io/home-assistant/home-assistant:2022.5.5"
# # image = "ghcr.io/home-assistant/home-assistant" # image = "ghcr.io/home-assistant/home-assistant"
# port { port {
# name = "http" name = "http"
# container_port = 8123 container_port = 8123
# protocol = "TCP" protocol = "TCP"
# } }
# env { env {
# name = "TZ" name = "TZ"
# value = "UTC+3" 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
# } }
# } }
# } }
# } }
# } }
# } }
# } }
# } }

View file

@ -262,12 +262,12 @@ module "wireguard" {
firewall_sh = var.wireguard_firewall_sh firewall_sh = var.wireguard_firewall_sh
} }
module "home_assistant" { # module "home_assistant" {
source = "./home_assistant" # source = "./home_assistant"
tls_secret_name = var.tls_secret_name # tls_secret_name = var.tls_secret_name
client_certificate_secret_name = var.client_certificate_secret_name # client_certificate_secret_name = var.client_certificate_secret_name
configuration_yaml = var.home_assistant_configuration # configuration_yaml = var.home_assistant_configuration
} # }
module "finance_app" { module "finance_app" {
source = "./finance_app" source = "./finance_app"