latest work
This commit is contained in:
1 parent
12b240adf4
commit
1951c4c9a0
15 files changed
+172
-87
No files matched your search
@@ -3,8 +3,3 @@ name: cluster
|
||||
description: An infrastructure collection of manifests for homelab
|
||||
type: application
|
||||
version: 0.1.0
|
||||
dependencies:
|
||||
- name: metallb
|
||||
version: 0.14.8
|
||||
repository: https://metallb.github.io/metallb
|
||||
|
||||
+3
-3
@@ -3,13 +3,13 @@ apiVersion: metallb.io/v1beta1
|
||||
kind: IPAddressPool
|
||||
metadata:
|
||||
name: homelab-pool
|
||||
namespace: "{{ .Release.Namespace }}"
|
||||
namespace: "{{ .Values.ns.metallb }}"
|
||||
spec:
|
||||
addresses:
|
||||
{{- .Values.homelab.addresses | toYaml | nindent 4 }}
|
||||
- 10.0.100.1-10.0.100.255
|
||||
---
|
||||
apiVersion: metallb.io/v1beta1
|
||||
kind: L2Advertisement
|
||||
metadata:
|
||||
name: l2ad
|
||||
namespace: "{{ .Release.Namespace }}"
|
||||
namespace: "{{ .Values.ns.metallb }}"
|
||||
@@ -1,9 +1,19 @@
|
||||
data "http" "myip" {
|
||||
url = "https://api.myip.com/"
|
||||
}
|
||||
data "cloudflare_zone" "this" {
|
||||
for_each = var.domain_mappings
|
||||
filter = {
|
||||
name = each.key
|
||||
account = {
|
||||
id = var.cloudflare.account_id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
locals {
|
||||
myip = jsondecode(data.http.myip.response_body)["ip"]
|
||||
records = flatten([
|
||||
for zone, records in var.domain_mappings : [
|
||||
for r, def in records :
|
||||
@@ -11,8 +21,8 @@ locals {
|
||||
"zone" : zone,
|
||||
"record" : r,
|
||||
"type" : def.type != null ? def.type : "A",
|
||||
"ip" : def.ip != null ? def.ip : var.myip,
|
||||
"zone_id" : data.cloudflare_zone.this[zone].id,
|
||||
"ip" : def.ip != null ? def.ip : local.myip,
|
||||
"zone_id" : data.cloudflare_zone.this[zone].zone_id,
|
||||
}
|
||||
]
|
||||
])
|
||||
@@ -20,15 +30,20 @@ locals {
|
||||
record_comment = "Updated by Terraform at ${local.current_date}"
|
||||
}
|
||||
|
||||
resource "cloudflare_record" "this" {
|
||||
output "myip" {
|
||||
value = local.myip
|
||||
}
|
||||
|
||||
resource "cloudflare_dns_record" "this" {
|
||||
for_each = {
|
||||
for d in local.records :
|
||||
"${d.record}.${d.zone}" => d
|
||||
}
|
||||
zone_id = each.value.zone_id
|
||||
name = each.value.record
|
||||
value = each.value.ip
|
||||
comment = local.record_comment
|
||||
content = each.value.ip
|
||||
name = each.value.record
|
||||
type = each.value.type
|
||||
proxied = false
|
||||
ttl = 1
|
||||
}
|
||||
Generated
+61
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"nodes": {
|
||||
"futils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1735563628,
|
||||
"narHash": "sha256-OnSAY7XDSx7CtDoqNh8jwVwh4xNL/2HaJxGjryLWzX8=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "b134951a4c9f3c995fd7be05f3243f8ecd65d798",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-24.05",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"futils": "futils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
@@ -25,7 +25,7 @@
|
||||
helm-diff
|
||||
];
|
||||
})
|
||||
helmfile-wrapped
|
||||
terraform
|
||||
argocd
|
||||
yq
|
||||
jq
|
||||
@@ -34,6 +34,7 @@
|
||||
echo "$(pwd)"
|
||||
export PATH="$(pwd)/bin:$PATH"
|
||||
export PROMPT="🏠> $PROMPT"
|
||||
export KUBE_CONFIG_PATH=~/.kube/config
|
||||
echo "Welcome to HomeLab!"
|
||||
'';
|
||||
};
|
||||
|
||||
+15
-10
@@ -5,21 +5,26 @@ repositories:
|
||||
url: https://grafana.github.io/helm-charts
|
||||
- name: external-secrets
|
||||
url: https://charts.external-secrets.io
|
||||
- name: kubernetes-dashboard
|
||||
url: https://kubernetes.github.io/dashboard/
|
||||
|
||||
- name: metallb
|
||||
url: https://metallb.github.io/metallb
|
||||
# helm install metallb
|
||||
releases:
|
||||
- name: external-secrets
|
||||
namespace: plugin-external-secrets
|
||||
chart: external-secrets/external-secrets
|
||||
version: "0.11.0"
|
||||
- name: kubernetes-dashboard
|
||||
namespace: kubernetes-dashboard
|
||||
chart: kubernetes-dashboard/kubernetes-dashboard
|
||||
# - name: prometheus-operator-crds
|
||||
# namespace: plugin-monitoring
|
||||
# chart: prometheus-community/prometheus-operator-crds
|
||||
# version: "17.0.2"
|
||||
# - name: metallb
|
||||
# namespace: plugin-metallb
|
||||
# chart: metallb/metallb
|
||||
# version: "0.14.9"
|
||||
# - name: plugin-infrastructure
|
||||
# namespace: metallb
|
||||
# chart: ./k8s/infrastructure
|
||||
# values:
|
||||
# - ./k8s/infrastructure/values.yaml
|
||||
# needs:
|
||||
# - plugin-metallb/metallb
|
||||
# - plugin-external-secrets/external-secrets
|
||||
# - name: loki
|
||||
# namespace: plugin-monitoring
|
||||
# chart: grafana/loki-stack
|
||||
|
||||
Whitespace-only changes.
Whitespace-only changes.
@@ -1,4 +0,0 @@
|
||||
|
||||
homelab:
|
||||
addresses:
|
||||
- 10.0.100.1-10.0.100.255
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
resource "helm_release" "plugin-external-secrets" {
|
||||
name = "external-secrets"
|
||||
chart = "external-secrets"
|
||||
repository = "https://charts.external-secrets.io"
|
||||
version = "0.14.2"
|
||||
atomic = true
|
||||
namespace = "plugin-external-secrets"
|
||||
create_namespace = true
|
||||
}
|
||||
|
||||
|
||||
resource "helm_release" "plugin-metallb" {
|
||||
name = "metallb"
|
||||
chart = "metallb"
|
||||
repository = "https://metallb.github.io/metallb"
|
||||
version = "0.14.9"
|
||||
atomic = true
|
||||
namespace = "plugin-metallb"
|
||||
create_namespace = true
|
||||
}
|
||||
|
||||
resource "helm_release" "local-chart-infrastructure" {
|
||||
name = "infrastructure"
|
||||
chart = "charts/infrastructure"
|
||||
namespace = "default"
|
||||
set = [{
|
||||
name = "ns.metallb"
|
||||
value = helm_release.plugin-metallb.namespace
|
||||
}]
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
terraform {
|
||||
backend "kubernetes" {
|
||||
secret_suffix = "homelab"
|
||||
namespace = "default"
|
||||
}
|
||||
}
|
||||
|
||||
terraform {
|
||||
required_providers {
|
||||
helm = {
|
||||
source = "hashicorp/helm"
|
||||
version = "3.0.0-pre1"
|
||||
}
|
||||
kubernetes = {
|
||||
source = "hashicorp/kubernetes"
|
||||
version = "2.35.1"
|
||||
}
|
||||
http = {
|
||||
source = "hashicorp/http"
|
||||
version = "3.4.5"
|
||||
}
|
||||
cloudflare = {
|
||||
source = "cloudflare/cloudflare"
|
||||
version = "5.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "helm" {}
|
||||
provider "kubernetes" {}
|
||||
provider "http" {}
|
||||
provider "cloudflare" {
|
||||
api_token = var.cloudflare.api_token
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
cloudflare = {
|
||||
source = "cloudflare/cloudflare"
|
||||
version = "~> 4.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "cloudflare" {
|
||||
api_token = var.cloudflare_api_token
|
||||
}
|
||||
|
||||
terraform {
|
||||
backend "kubernetes" {
|
||||
secret_suffix = "homelab"
|
||||
namespace = "terraforms"
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
import httpx
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
MYIP_URL = os.environ.get("MYIP_URL", "https://api.myip.com/")
|
||||
MYIP_KEY = os.environ.get("MYIP_KEY", "myip")
|
||||
|
||||
def get_auto_vars_file():
|
||||
if p := os.environ.get("AUTO_TFVARS", None):
|
||||
return Path(p)
|
||||
return Path(__file__).parent / "var.auto.tfvars.json"
|
||||
|
||||
auto_tfvars = get_auto_vars_file()
|
||||
|
||||
print("Starting ip-update with")
|
||||
print(f" > auto_tfvars = {auto_tfvars}")
|
||||
print(f" > MYIP_URL = {MYIP_URL}")
|
||||
print(f" > MYIP_KEY = {MYIP_KEY}")
|
||||
|
||||
resp = httpx.get(MYIP_URL)
|
||||
|
||||
if resp.status_code != 200:
|
||||
raise AssertionError(f"{MYIP_URL} returned {resp}")
|
||||
|
||||
data = resp.json()
|
||||
print(f"myip response = {data}")
|
||||
|
||||
myip = data['ip']
|
||||
|
||||
if not auto_tfvars.exists():
|
||||
raise AssertionError(f"{auto_tfvars} does not exists!")
|
||||
|
||||
auto_tfvars_data = json.loads(auto_tfvars.read_text())
|
||||
auto_tfvars_data[MYIP_KEY] = myip
|
||||
auto_tfvars.write_text(json.dumps(auto_tfvars_data, indent=4))
|
||||
|
||||
print("DONE")
|
||||
@@ -1,5 +1,9 @@
|
||||
variable "myip" {}
|
||||
variable "cloudflare_api_token" {}
|
||||
variable "cloudflare" {
|
||||
type = object({
|
||||
api_token = string
|
||||
account_id = string
|
||||
})
|
||||
}
|
||||
variable "main_domain" {
|
||||
default = "sosnovsky.ca"
|
||||
}
|
||||
Reference in new issue
Block a user