Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Use homelab molecules to setup a Dev Kubernetes Environment #46

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tcp:
53: "homelab/pihole-dns-tcp:53"
udp:
53: "homelab/pihole-dns-udp:53"
# tcp:
# 53: "homelab/pihole-dns-tcp:53"
# udp:
# 53: "homelab/pihole-dns-udp:53"
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
flags:
rewrite: false

service:
name: kafka
port:
number: 9092

annotations:
hajimari.io/enable: "true"
hajimari.io/appName: "kafka"

ingress:
subdomain: kafka
routePath: /

hosts:
%{ for host in hosts ~}
- name: ${host}
%{ endfor ~}
18 changes: 18 additions & 0 deletions molecules/cluster-resources/config/externals/keycloak/values.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
postgresql:
enabled: false

extraEnv: |
- name: DB_VENDOR
value:
- name: DB_ADDR
value:
- name: DB_PORT
value:
- name: DB_DATABASE
value:
- name: DB_USER
value:
- name: DB_PASSWORD
value:
- name: KEYCLOAK_USER
value:
- name: KEYCLOAK_PASSWORD
value:
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@ config:
include: [/var/log/*.log]

processors:
batch: {}
attributes:
actions:
- action: insert
key: log_file_name
from_attribute: log.file.name
- action: insert
key: loki.attribute.labels
value: log_file_name

exporters:
logging:
loglevel: debug

loki:
endpoint: "http://loki.homelab.svc.cluster.local:3100/loki/api/v1/push"
labels:
attributes:
log.file.name: "filename"

service:
pipelines:
logs:
receivers: [filelog]
processors: [batch]
processors: [attributes]
exporters: [loki]
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
mode: "deployment"

config:
receivers:
filelog:
include: [/var/log/*.log]

processors:
batch: {}

exporters:
logging:
loglevel: debug

loki:
endpoint: "http://loki:3100/loki/api/v1/push"
labels:
attributes:
log.file.name: "filename"

service:
pipelines:
logs:
receivers: [filelog]
processors: [batch]
exporters: [loki]
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
mode: "deployment"

config:
receivers:
filelog:
include: [/var/log/*.log]

processors:
batch: {}

exporters:
logging:
loglevel: debug

loki:
endpoint: "http://loki:3100/loki/api/v1/push"
labels:
attributes:
log.file.name: "filename"

service:
pipelines:
logs:
receivers: [filelog]
processors: [batch]
exporters: [loki]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
nodeExporter:
# hostRootfs: false
hostRootFsMount:
enabled: false
mountPropagation: HostToContainer
2 changes: 1 addition & 1 deletion molecules/cluster-resources/externals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ resource "helm_release" "external_apps" {
for_each = { for external in var.externals : external.name => external }
repository = each.value.repo
name = each.value.name
chart = each.value.name
chart = coalesce(each.value.chart_name, each.value.name)
namespace = each.value.namespace != null ? each.value.namespace : each.value.name
create_namespace = true
values = fileexists("./config/externals/${each.value.name}/values.yaml") == true ? ["${file("./config/externals/${each.value.name}/values.yaml")}"] : []
Expand Down
101 changes: 101 additions & 0 deletions molecules/cluster-resources/homelab.inputs.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
cluster = {
name = "colima"
config_path = "~/.kube/config"
host = "https://127.0.0.1:6443"
hosts = [
"127.0.0.1.nip.io"
]
}

externals = [
{
name = "ingress-nginx"
repo = "https://kubernetes.github.io/ingress-nginx"
version = "4.4.0"
},
#{
# name = "hajimari"
# repo = "https://hajimari.io"
# version = "1.2.0"
# namespace = "homelab"
#},
#{
# name = "postgresql"
# repo = "https://cetic.github.io/helm-charts"
# version = "0.2.3"
# namespace = "homelab"
#},
// TODO: nextcloud fails due to slow startup, need to figure this out
# {
# name = "nextcloud"
# repo = "https://nextcloud.github.io/helm"
# version = "3.3.6"
# namespace = "homelab"
# },
# {
# name = "coredns",
# repo = "https://coredns.github.io/helm",
# version = "1.19.7",
# namespace = "homelab"
# }
# {
# name = "pihole",
# repo = "https://mojo2600.github.io/pihole-kubernetes/",
# version = "2.11.0",
# namespace = "homelab"
# },
# {
# name = "keycloak",
# repo = "https://codecentric.github.io/helm-charts",
# version = "20.0.3",
# namespace = "homelab"
# },
{
name = "prometheus",
repo = "https://prometheus-community.github.io/helm-charts",
version = "19.3.1",
namespace = "homelab"
},
{
name = "grafana",
repo = "https://grafana.github.io/helm-charts",
version = "0.2.3",
namespace = "homelab"
},
{
name = "loki",
repo = "https://grafana.github.io/loki/charts",
version = "2.1.1",
namespace = "homelab"
},
# https://grafana.com/blog/2022/06/23/how-to-send-logs-to-grafana-loki-with-the-opentelemetry-collector-using-fluent-forward-and-filelog-receivers
{
name = "opentelemetry-collector",
repo = "https://open-telemetry.github.io/opentelemetry-helm-charts"
version = "v0.72.0",
namespace = "payobills-dev"
},
#{
# name = "opentelemetry-collector",
# repo = "https://open-telemetry.github.io/opentelemetry-helm-charts"
# version = "v0.72.0",
# namespace = "homelab"
# },
#{
# name = "kafka",
# repo = "https://charts.bitnami.com/bitnami",
# version = "21.3.0"
#},
# {
# name = "zeebe-full-helm",
# repo = "https://helm.camunda.io"
# version = "1.3.5",
# namespace = "homelab"
# },
#{
# name = "dapr",
# repo = "https://dapr.github.io/helm-charts/",
# version = "1.10.5",
# namespace = "dapr-system"
#}
]
69 changes: 30 additions & 39 deletions molecules/cluster-resources/inputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ variable "externals" {
description = "Details about external apps to install"
type = list(object({
name = string
chart_name = optional(string)
repo = string
version = string
namespace = optional(string)
Expand All @@ -38,71 +39,61 @@ variable "externals" {
version = "1.2.0"
namespace = "homelab"
},
{
name = "postgresql"
repo = "https://cetic.github.io/helm-charts"
version = "0.2.3"
namespace = "homelab"
},

{
name = "pihole",
repo = "https://mojo2600.github.io/pihole-kubernetes/",
version = "2.11.0",
namespace = "homelab"
},
{
name = "prometheus",
repo = "https://prometheus-community.github.io/helm-charts",
version = "19.3.1",
namespace = "homelab"
},
{
name = "grafana",
repo = "https://grafana.github.io/helm-charts",
version = "0.2.3",
namespace = "homelab"
},
{
name = "loki",
repo = "https://grafana.github.io/loki/charts",
version = "2.1.1",
namespace = "homelab"
},
# https://grafana.com/blog/2022/06/23/how-to-send-logs-to-grafana-loki-with-the-opentelemetry-collector-using-fluent-forward-and-filelog-receivers
{
name = "opentelemetry-collector",
repo = "https://open-telemetry.github.io/opentelemetry-helm-charts"
version = "v0.72.0",
name = "postgresql"
repo = "https://cetic.github.io/helm-charts"
version = "0.2.3"
namespace = "homelab"
},
# TODO: I don't think this is needed, need to check
# {
# name = "grafana-agent-operator",
# repo = "https://grafana.github.io/helm-charts",
# version = "9.3.1",
# namespace = "homelab"
# },
# TODO: nextcloud fails due to slow startup, need to figure this out
// TODO: nextcloud fails due to slow startup, need to figure this out
# {
# name = "nextcloud"
# repo = "https://nextcloud.github.io/helm"
# version = "3.3.6"
# namespace = "homelab"
# },
# TODO: Use coredns for DNS. Still not sure about this
# {
# name = "coredns",
# repo = "https://coredns.github.io/helm",
# version = "1.19.7",
# namespace = "homelab"
# },
# TODO: Add configuration for this
# {
# name = "keycloak",
# repo = "https://codecentric.github.io/helm-charts",
# version = "20.0.3",
# namespace = "homelab"
# },
{
name = "prometheus",
repo = "https://prometheus-community.github.io/helm-charts",
version = "19.3.1",
namespace = "homelab"
},
{
name = "grafana",
repo = "https://grafana.github.io/helm-charts",
version = "0.2.3",
namespace = "homelab"
},
{
name = "loki",
repo = "https://grafana.github.io/loki/charts",
version = "2.1.1",
namespace = "homelab"
},
# https://grafana.com/blog/2022/06/23/how-to-send-logs-to-grafana-loki-with-the-opentelemetry-collector-using-fluent-forward-and-filelog-receivers
#{
# name = "opentelemetry-collector",
# repo = "https://open-telemetry.github.io/opentelemetry-helm-charts"
# version = "v0.72.0",
# namespace = "homelab"
#},
]
}
2 changes: 1 addition & 1 deletion molecules/cluster-resources/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ terraform {
}
}

backend "http" { }
# backend "http" { }
}

provider "helm" {
Expand Down
Loading