diff --git a/.zed/settings.json b/.zed/settings.json index 1d072f7..433d9e0 100644 --- a/.zed/settings.json +++ b/.zed/settings.json @@ -1,12 +1,12 @@ { "file_types": { "Helm": [ - "charts/**/templates/**/*.tpl", - "charts/**/templates/**/*.yaml", - "charts/**/templates/**/*.yml", - "charts/**/helmfile.d/**/*.yaml", - "charts/**/helmfile.d/**/*.yml", - "charts/**/values*.yaml", + "charts/**/*/templates/**/*.tpl", + "charts/**/*/templates/**/*.yaml", + "charts/**/*/templates/**/*.yml", + "charts/**/*/helmfile.d/**/*.yaml", + "charts/**/*/helmfile.d/**/*.yml", + "charts/**/*/values*.yaml", ], }, } diff --git a/charts/infrastructure/templates/_helpers/git-repos.tpl b/charts/infrastructure/templates/_helpers/git-repos.tpl index 01e7f4b..f6c1f73 100644 --- a/charts/infrastructure/templates/_helpers/git-repos.tpl +++ b/charts/infrastructure/templates/_helpers/git-repos.tpl @@ -5,13 +5,15 @@ kind: Secret metadata: labels: argocd.argoproj.io/secret-type: repository - name: {{ .name }} + name: argocd-repo-{{ .name }} namespace: "{{ .namespace }}" type: Opaque -stringData: - name: {{ .name }} - type: {{ .type | default "git" }} - url: {{ .url }} data: - sshPrivateKey: "{{ .sshkey | b64enc }}" -{{ end }} \ No newline at end of file + "name": "{{ .name | b64enc }}" + "type": "{{ .type | default "git" | b64enc }}" + "url": "{{ .url | b64enc }}" + {{ range $k, $v := .data }} + "{{ $k }}": |- + {{ $v | b64enc }} + {{ end }} +{{ end }} diff --git a/charts/infrastructure/templates/argocd-appset.yml b/charts/infrastructure/templates/argocd-appset.yml index 0383887..8a18b37 100644 --- a/charts/infrastructure/templates/argocd-appset.yml +++ b/charts/infrastructure/templates/argocd-appset.yml @@ -9,7 +9,7 @@ spec: - git: directories: - path: charts/apps/* - repoURL: {{ .Values.gitops.repo }} + repoURL: {{ .Values.gitops.url }} revision: "{{ .Values.gitops.revision }}" template: metadata: {} @@ -30,7 +30,7 @@ spec: revisionHistoryLimit: 4 source: path: '{{`{{path}}`}}' - repoURL: {{ .Values.gitops.repo }} + repoURL: {{ .Values.gitops.url }} targetRevision: "{{ .Values.gitops.revision }}" helm: valueFiles: diff --git a/charts/infrastructure/templates/argocd-repo-additionals.yaml b/charts/infrastructure/templates/argocd-repo-additionals.yaml new file mode 100644 index 0000000..ba554fc --- /dev/null +++ b/charts/infrastructure/templates/argocd-repo-additionals.yaml @@ -0,0 +1,6 @@ +{{- range $name, $val := .Values.repos }} +{{ include "git-repo" (merge $val (dict + "name" $name + "namespace" $.Values.ns.argocd +))}} +{{ end -}} diff --git a/charts/infrastructure/templates/argocd-repo-gitops.yaml b/charts/infrastructure/templates/argocd-repo-gitops.yaml new file mode 100644 index 0000000..410453c --- /dev/null +++ b/charts/infrastructure/templates/argocd-repo-gitops.yaml @@ -0,0 +1,5 @@ + +{{ include "git-repo" (merge $.Values.gitops (dict + "name" "gitops" + "namespace" $.Values.ns.argocd +))}} diff --git a/charts/infrastructure/templates/argocd-repo.yaml b/charts/infrastructure/templates/argocd-repo.yaml deleted file mode 100644 index f022523..0000000 --- a/charts/infrastructure/templates/argocd-repo.yaml +++ /dev/null @@ -1,15 +0,0 @@ -{{ include "git-repo" (dict - "name" "homelab" - "namespace" $.Values.ns.argocd - "sshkey" $.Values.gitops.sshkey - "url" $.Values.gitops.repo -)}} - - - -{{- range $name, $val := .Values.additionalRepos }} -{{ include "git-repo" (merge $val (dict - "name" $name - "namespace" $.Values.ns.argocd -))}} -{{ end -}} \ No newline at end of file diff --git a/charts/infrastructure/values.yaml b/charts/infrastructure/values.yaml index f41336f..fe56906 100644 --- a/charts/infrastructure/values.yaml +++ b/charts/infrastructure/values.yaml @@ -1,28 +1,31 @@ global: {} registry: - ip: 10.0.100.101 - image: registry:2 + ip: 10.0.100.101 + image: registry:2 ns: - metallb: "change-me" - argocd: "change-me" + metallb: "change-me" + argocd: "change-me" gitops: - revision: "main" - repo: "ssh://gitea@minipc1.lab.internal/ari/homelab.git" - sshkey: "" + type: git + url: http://minipc1.lab.internal:3000/ari/homelab.git + revision: main + data: + username: argocd + password: "change-me" -additionalRepos: +repos: github-helm-charts: type: git - username: git - url: git@github.com:asosnovsky/helm-charts.git - sshkey: "" + url: git@github.com:asosnovsky/helm-charts.git + data: + sshPrivateKey: "change-me" metallb: - addresses: - - 10.0.100.1-10.0.100.255 + addresses: + - 10.0.100.1-10.0.100.255 enabledClusterSecretStores: - - secrets \ No newline at end of file + - secrets diff --git a/flake.nix b/flake.nix index 48ac8ed..5ce0a91 100644 --- a/flake.nix +++ b/flake.nix @@ -42,7 +42,7 @@ shellHook = '' echo "$(pwd)" export PATH="$(pwd)/bin:$PATH" - export PROMPT="🏠| \$(kubectx -c)@\$(kubens -c):📁$(pwd)> $PROMPT" + export PROMPT="🏠| \$(kubectx -c)@\$(kubens -c):📁\$(pwd)> $PROMPT" export KUBE_CONFIG_PATH=~/.kube/config echo "Welcome to HomeLab!" ''; diff --git a/tf-modules.tf b/tf-modules.tf index 3603a8f..5b5b55e 100644 --- a/tf-modules.tf +++ b/tf-modules.tf @@ -13,11 +13,15 @@ resource "helm_release" "local-chart-infrastructure" { value = module.k8s-helm-charts.namespaces.plugins.argo-cd }, { - name = "gitops.sshkey" - value = var.ssh_key + name = "gitops.data.username" + value = var.gitea.user }, { - name = "additionalRepos.github-helm-charts.sshkey" + name = "gitops.data.password" + value = var.gitea.password + }, + { + name = "repos.github-helm-charts.data.sshPrivateKey" value = var.github_ssh_key } ] diff --git a/tf-variables.tf b/tf-variables.tf index a5d871d..d47e0c1 100644 --- a/tf-variables.tf +++ b/tf-variables.tf @@ -21,7 +21,11 @@ variable "domain_mappings" { type = optional(string, "A"), }))) } -variable "ssh_key" { +variable "gitea" { + type = object({ + user = string + password = string + }) sensitive = true } variable "github_ssh_key" {