This commit is contained in:
ari committed 2025-04-12 16:29:31 -04:00
1 parent 95c52f768d
commit bfaeee9bf4
32 files changed
+215 -426

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
apiVersion: v2
name: ingress
description: A Helm chart for Kubernetes
type: application
version: 0.1.0
appVersion: "1.16.0"
@@ -0,0 +1,38 @@
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: dummy-app
namespace: "{{ .Release.Namespace }}"
spec:
replicas: 1
selector:
matchLabels:
app: dummy
template:
metadata:
labels:
app: dummy
spec:
containers:
- name: name
image: nginxdemos/hello
resources:
limits:
memory: 1Gi
ports:
- containerPort: 80
---
kind: Service
apiVersion: v1
metadata:
name: dummy-app
spec:
selector:
app: dummy
release: "{{ .Release.Name }}"
type: ClusterIP
ports:
- name: http
port: 80
targetPort: 80
File renamed without changes.
+1 -1
View File
@@ -2,4 +2,4 @@ apiVersion: v2
name: cluster
description: An infrastructure collection of manifests for homelab
type: application
version: 0.1.2
version: 0.1.4
@@ -0,0 +1,14 @@
---
apiVersion: v1
kind: Secret
metadata:
name: argo-repo-main
namespace: "{{ .Values.ns.argocd }}"
labels:
argocd.argoproj.io/secret-type: repository
annotations:
link.argocd.argoproj.io/external-link: "https://github.com/{{ .Values.gitops.repo }}"
stringData:
type: git
url: "git@github.com:{{ .Values.gitops.repo }}.git"
sshPrivateKey: {{ .Values.gitops.sshkey | quote }}
+1 -2
View File
@@ -5,8 +5,7 @@ metadata:
name: homelab-pool
namespace: "{{ .Values.ns.metallb }}"
spec:
addresses:
- 10.0.100.1-10.0.100.255
addresses: {{ .Values.metallb.addresses }}
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
+20 -1
View File
@@ -1,3 +1,22 @@
global:
timezone: America/Toronto
nfs:
server: 10.0.10.1
rootPath: /mnt/EightTerra/k3s-cluster/direct-mounts
registry:
ip: 10.0.100.101
image: registry:2
image: registry:2
ns:
metallb: "change-me"
argocd: "change-me"
gitops:
commit: "v2"
repo: "asosnovsky/homelab"
sshkey: ""
metallb:
addresses:
- 10.0.100.1-10.0.100.255
-6
View File
@@ -1,6 +0,0 @@
apiVersion: v2
name: argoapps
description: An k8s service for homelab
type: application
version: 0.1.0
dependencies: []
@@ -1,29 +0,0 @@
{{ define "homelab.argo.applicaton" }}
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: "{{ .name }}"
spec:
project: {{ .project }}
source:
repoURL: "git@github.com:{{ .Values.gitops.repo }}.git"
targetRevision: "{{ .Values.gitops.commit }}"
path: '{{ .rootFolder }}/{{ .name }}'
helm:
valueFiles:
- values.yaml
- values-{{.Values.global.deployment}}.yaml
values: |-
global:
{{- .Values.global | toYaml | nindent 12 }}
releaseName: {{ .name }}
destination:
server: https://kubernetes.default.svc
namespace: {{ .namespace }}
{{- if .syncPolicy }}
syncPolicy:
{{- .syncPolicy | toYaml | nindent 4 }}
{{ end }}
{{ end }}
@@ -1,22 +0,0 @@
{{ define "homelab.argo.project" }}
---
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
name: {{ .name }}
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
description: {{ .description }}
orphanedResources:
warn: false
sourceRepos:
- "*"
destinations:
- server: "*"
namespace: '*'
name: '*'
clusterResourceWhitelist:
- group: "*"
kind: "*"
{{ end }}
@@ -1,54 +0,0 @@
{{- $argoappsetApps := "apps" -}}
{{ include "homelab.argo.project" (dict "name" $argoappsetApps "description" "common applications")}}
{{ range $appName, $appProps := .Values.apps }}
{{ if (not $appProps.disabled) }}
{{- $genNamespace := (printf "apps-%s" $appName) -}}
{{ if (not $appProps.namespace) }}
---
apiVersion: v1
kind: Namespace
metadata:
name: "{{ $genNamespace }}"
{{ end }}
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: app-{{ $appName }}
spec:
project: {{ $argoappsetApps }}
source:
repoURL: "git@github.com:{{ $.Values.gitops.repo }}.git"
targetRevision: "{{ $.Values.gitops.commit }}"
path: 'k8s/apps/{{ $appName }}'
helm:
valueFiles:
- values.yaml
- values-{{$.Values.global.deployment}}.yaml
values: |-
{{- $values := ($appProps.values| default "") -}}
{{ if $appProps.valuesFile }}
{{- $valuesFilePath := (printf "apps-values/%s" $appProps.valuesFile) -}}
{{- $values := $.Files.Get $valuesFilePath -}}
{{- tpl $values $ | nindent 10 -}}
{{- else -}}
{{- tpl $values $ | nindent 10 -}}
{{- end }}
global:
{{- $.Values.global | toYaml | nindent 12 }}
releaseName: {{ $appName }}
destination:
server: https://kubernetes.default.svc
namespace: {{ $appProps.namespace | default $genNamespace }}
{{ if $appProps.syncPolicy }}
syncPolicy:
{{$appProps.syncPolicy | toYaml | nindent 4 }}
{{ end }}
{{ end }}
{{ end }}
@@ -1,26 +0,0 @@
{{- $argoappsetInfra := "infrastructure" -}}
{{- include "homelab.argo.project" (dict "name" $argoappsetInfra "description" "Infrastructure related charts") -}}
{{- range $appName, $appProps := .Values.infrastructure -}}
{{- $_ := set $appProps "Values" $.Values -}}
{{- $_ := set $appProps "name" (default $appProps.name $appName) -}}
{{- $_ := set $appProps "project" (default $appProps.project $argoappsetInfra) -}}
{{- $_ := set $appProps "namespace" (default $appProps.namespace $appName) -}}
{{- $_ := set $appProps "rootFolder" "k8s/infrastructure" -}}
{{- if (not $appProps.disabled) -}}
{{- if $appProps.createNamespace -}}
---
apiVersion: v1
kind: Namespace
metadata:
name: "{{ $appProps.namespace }}"
{{ end }}
{{- include "homelab.argo.applicaton" $appProps -}}
{{- end -}}
{{- end -}}
-49
View File
@@ -1,49 +0,0 @@
---
{{- $infraChartProjectName := "infrastructure-charts" -}}
{{ include "homelab.argo.project" (dict "name" $infraChartProjectName "description" "infrastructure helm charts")}}
{{ range $chartName, $chartProps := .Values.infrastructureCharts }}
{{- $namespace := $chartProps.namespace | default (printf "chart-%s" $chartName) -}}
{{ if (not $chartProps.namespace) }}
---
apiVersion: v1
kind: Namespace
metadata:
name: "{{ $namespace }}"
{{ end }}
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: chart-{{ $chartName }}
spec:
project: {{ $infraChartProjectName }}
source:
chart: {{ $chartProps.chart | default $chartName }}
repoURL: {{ $chartProps.repoURL }}
targetRevision: {{ $chartProps.targetRevision }}
helm:
values: |-
{{- $values := ($chartProps.values | default "") -}}
{{ if $chartProps.valuesFile }}
{{- $valuesFilePath := (printf "chart-values/%s" $chartProps.valuesFile) -}}
{{- $values := $.Files.Get $valuesFilePath -}}
{{- tpl $values $ | nindent 8 }}
{{ else }}
{{- tpl $values $ | nindent 8 }}
{{ end }}
releaseName: {{ $chartName }}
destination:
server: https://kubernetes.default.svc
namespace: {{ $namespace }}
syncPolicy:
automated:
selfHeal: true
{{ if $chartProps.enableServerSideApply}}
syncOptions:
- ServerSideApply=true
{{ end }}
{{ end }}
@@ -1,22 +0,0 @@
---
apiVersion: v1
kind: LimitRange
metadata:
name: cpu-limit-range
spec:
limits:
- defaultRequest:
cpu: 10m
type: Container
---
apiVersion: v1
kind: LimitRange
metadata:
name: mem-limit-range
spec:
limits:
- default:
memory: 50Mi
defaultRequest:
memory: 25Mi
type: Container
-2
View File
@@ -1,2 +0,0 @@
global:
deployment: dev
-2
View File
@@ -1,2 +0,0 @@
global:
deployment: prod
-15
View File
@@ -1,15 +0,0 @@
gitops:
repo: ""
commit: ""
global:
email: "ariel@sosnovsky.ca"
timezone: America/Toronto
infrastructureCharts: {}
apps: {}
infrastructure:
metallb:
createNamespace: true
namespace: metallb-system
-23
View File
@@ -1,23 +0,0 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
-9
View File
@@ -1,9 +0,0 @@
apiVersion: v2
name: argocd
description: Homelab Infra
type: application
version: 0.1.0
dependencies:
- name: argo-cd
version: 7.6.12
repository: https://argoproj.github.io/argo-helm
-91
View File
@@ -1,91 +0,0 @@
---
apiVersion: v1
kind: Secret
metadata:
name: argo-repo-main
namespace: "{{ .Release.Namespace }}"
labels:
argocd.argoproj.io/secret-type: repository
annotations:
link.argocd.argoproj.io/external-link: "https://github.com/{{ .Values.gitops.repo }}"
stringData:
type: git
url: "git@github.com:{{ .Values.gitops.repo }}.git"
sshPrivateKey: {{ .Values.selfapp.sshkey | quote }}
{{ if .Values.selfapp.enabled }}
---
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
name: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
description: common applications
orphanedResources:
warn: false
sourceRepos:
- "*"
destinations:
- server: "*"
namespace: '*'
name: '*'
clusterResourceWhitelist:
- group: "*"
kind: "*"
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: "{{ .Release.Name }}"
namespace: "{{ .Release.Namespace }}"
spec:
project: argocd
source:
repoURL: "git@github.com:{{ .Values.gitops.repo }}.git"
targetRevision: "{{ .Values.gitops.commit }}"
path: k8s/argocd
helm:
valueFiles:
- values.yaml
- values-{{ .Values.selfapp.deployment }}.yaml
parameters:
- name: "selfapp.deployment"
value: {{ .Values.selfapp.deployment | quote }}
- name: "selfapp.enabled"
value: "true"
- name: "selfapp.sshkey"
value: {{ .Values.selfapp.sshkey | quote }}
destination:
server: https://kubernetes.default.svc
namespace: "{{ .Release.Namespace }}"
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: "argoapps"
namespace: "{{ .Release.Namespace }}"
spec:
project: argocd
source:
repoURL: "git@github.com:{{ .Values.gitops.repo }}.git"
targetRevision: "{{ .Values.gitops.commit }}"
path: k8s/argoapps
helm:
valueFiles:
- values.yaml
- values-{{ .Values.selfapp.deployment }}.yaml
parameters:
- name: "gitops.repo"
value: {{ .Values.gitops.repo | quote }}
- name: "gitops.commit"
value: {{ .Values.gitops.commit | quote }}
destination:
server: https://kubernetes.default.svc
namespace: "{{ .Release.Namespace }}"
syncPolicy:
automated: {}
{{- end -}}
-2
View File
@@ -1,2 +0,0 @@
global:
domain: argocd.home.internal
-2
View File
@@ -1,2 +0,0 @@
global:
domain: argocd.core.home.sosnovsky.ca
-25
View File
@@ -1,25 +0,0 @@
argo-cd:
configs:
cm:
exec.enabled: true
params:
server.insecure: true
server.basehref: /
server.rootpath: ""
redis.server: "argocd-redis.argocd.svc.cluster.local:6379"
repo.server: "argocd-repo-server.argocd.svc.cluster.local:8081"
server.dex.server: "http://argocd-dex-server.argocd.svc.cluster.local:5556"
crds:
install: true
keep: false
server:
ingress:
enabled: false
ingressGrpc:
enabled: false
selfapp:
deployment: ""
sshkey: ""
gitops:
commit: "v2"
repo: "asosnovsky/homelab"
-28
View File
@@ -1,28 +0,0 @@
resource "helm_release" "local-chart-infrastructure" {
name = "infrastructure"
chart = "charts/infrastructure"
namespace = "default"
set = [{
name = "ns.metallb"
value = module.k8s-helm-charts.namespaces.plugins.metallb
}]
values = [file("./values.yaml")]
timeout = 120
force_update = true
}
module "k8s-helm-charts" {
source = "./tf-modules/k8s-helm-charts"
}
output "ns" {
value = module.k8s-helm-charts.namespaces
}
resource "kubernetes_namespace" "test" {
metadata {
name = "test"
}
}
View File
File renamed without changes.
+96
View File
@@ -0,0 +1,96 @@
resource "helm_release" "local-chart-infrastructure" {
name = "infrastructure"
chart = "charts/infrastructure"
namespace = "default"
set = [
{
name = "ns.metallb"
value = module.k8s-helm-charts.namespaces.plugins.metallb
},
{
name = "ns.argocd"
value = module.k8s-helm-charts.namespaces.plugins.argo-cd
},
{
name = "gitops.sshkey"
value = var.ssh_key
}
]
timeout = 120
force_update = true
}
module "k8s-helm-charts" {
source = "./tf-modules/k8s-helm-charts"
plugins = {
"external-secrets" : {
repository = "https://charts.external-secrets.io"
version = "0.14.2"
},
"metallb" : {
repository = "https://metallb.github.io/metallb"
version = "0.14.9"
},
"cert-manager" : {
repository = "https://charts.jetstack.io"
version = "1.17.1"
values : [yamlencode({
installCRDs : true
})]
},
"argo-cd" : {
"repository" : "https://argoproj.github.io/argo-helm"
"version" : "7.8.7"
"values" : [
yamlencode({
configs = {
cm = {
"exec.enabled" : true
}
params = {
"server.insecure" = true
"server.basehref" = "/"
"server.rootpath" = ""
}
}
crds = {
install = true
keep = false
}
server = {
ingress = {
enabled = false
}
ingressGrpc = {
enabled = false
}
}
})
]
},
"tailscale-operator" : {
repository = "https://pkgs.tailscale.com/helmcharts"
version = "1.82.0"
values : [
yamlencode({
oauth = {
clientId = var.tailscale.client_id
clientSecret = var.tailscale.client_secret
}
})
]
}
}
}
output "ns" {
value = module.k8s-helm-charts.namespaces
}
resource "kubernetes_namespace" "test" {
metadata {
name = "test"
}
}
+1
View File
@@ -7,6 +7,7 @@ resource "helm_release" "plugins" {
atomic = true
namespace = "plugin-${each.key}"
create_namespace = true
values = each.value.values
}
resource "helm_release" "infra" {
+1 -10
View File
@@ -4,16 +4,7 @@ variable "plugins" {
version = string
values = optional(list(string), [])
}))
default = {
"external-secrets" : {
repository = "https://charts.external-secrets.io"
version = "0.14.2"
},
"metallb" : {
repository = "https://metallb.github.io/metallb"
version = "0.14.9"
}
}
default = {}
}
View File
File renamed without changes.
+26
View File
@@ -0,0 +1,26 @@
resource "kubernetes_service_v1" "argocd-metallb" {
metadata {
name = "argo-cd-server"
namespace = module.k8s-helm-charts.namespaces.plugins.argo-cd
annotations = {
"metallb.universe.tf/loadBalancerIPs" : "10.0.100.2"
}
}
spec {
type = "LoadBalancer"
port {
port = 80
target_port = 8080
name = "http"
}
port {
port = 443
target_port = 8080
name = "https"
}
selector = {
"app.kubernetes.io/instance" : "argo-cd"
"app.kubernetes.io/name" : "argocd-server"
}
}
}
+11
View File
@@ -1,4 +1,5 @@
variable "cloudflare" {
sensitive = true
type = object({
api_token = string
account_id = string
@@ -16,3 +17,13 @@ variable "domain_mappings" {
type = optional(string, "A"),
})))
}
variable "ssh_key" {
sensitive = true
}
variable "tailscale" {
type = object({
client_id = string,
client_secret = string,
})
sensitive = true
}
-5
View File
@@ -1,5 +0,0 @@
global:
timezone: America/Toronto
nfs:
server: 10.0.10.1
rootPath: /mnt/EightTerra/k3s-cluster/direct-mounts