diff --git a/remodel/k8s/apps/media/arr/kustomization.yaml b/remodel/k8s/apps/media/arr/kustomization.yaml new file mode 100644 index 0000000..4eecca6 --- /dev/null +++ b/remodel/k8s/apps/media/arr/kustomization.yaml @@ -0,0 +1,12 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +configMapGenerator: + - name: common-env + namespace: arr + literals: + - TZ="Europe/Oslo" + +resources: + - pvc.yaml + - deployment.yaml diff --git a/remodel/k8s/apps/media/arr/sonarr/deployment.yaml b/remodel/k8s/apps/media/arr/sonarr/deployment.yaml new file mode 100644 index 0000000..25ff6b9 --- /dev/null +++ b/remodel/k8s/apps/media/arr/sonarr/deployment.yaml @@ -0,0 +1,71 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sonarr + namespace: arr + labels: + app: sonarr +spec: + replicas: 1 + selector: + matchLabels: + app: sonarr + strategy: + type: Recreate + template: + metadata: + namespace: sonarr + labels: + app: sonarr + spec: + nodeSelector: + kubernetes.io/hostname: ctrl-02 + #topology.kubernetes.io/zone: cantor + securityContext: + runAsNonRoot: true + runAsUser: 65534 + runAsGroup: 65534 + fsGroup: 65534 + fsGroupChangePolicy: OnRootMismatch + seccompProfile: + type: RuntimeDefault + containers: + - name: sonarr + image: ghcr.io/onedr0p/sonarr:4.0.6 + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + capabilities: + drop: [ "ALL" ] + ports: + - name: http + containerPort: 8989 + envFrom: + - configMapRef: + name: common-env + volumeMounts: + - name: sonarr-config + mountPath: /config + - name: backup + mountPath: /backup + - name: data + mountPath: /app/data + resources: + requests: + cpu: 100m + memory: 384Mi + limits: + cpu: 1000m + memory: 512Mi + volumes: + - name: sonarr-config + persistentVolumeClaim: + claimName: sonarr-config + - name: data + nfs: + server: 192.168.1.55 + path: /mnt/pool-0/data + - name: backup + nfs: + server: 192.168.1.55 + path: /mnt/pool-0/backup diff --git a/remodel/k8s/apps/media/arr/sonarr/pvc.yaml b/remodel/k8s/apps/media/arr/sonarr/pvc.yaml new file mode 100644 index 0000000..b545263 --- /dev/null +++ b/remodel/k8s/apps/media/arr/sonarr/pvc.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: sonarr-config + namespace: arr +spec: + storageClassName: proxmox-csi + volumeName: pv-sonarr-config + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 4G diff --git a/remodel/k8s/infra/controllers/argocd/kustomization.yaml b/remodel/k8s/infra/controllers/argocd/kustomization.yaml index ff5ff97..3aec093 100644 --- a/remodel/k8s/infra/controllers/argocd/kustomization.yaml +++ b/remodel/k8s/infra/controllers/argocd/kustomization.yaml @@ -3,7 +3,7 @@ kind: Kustomization resources: - ns.yaml -# - http-route.yaml + - http-route.yaml helmCharts: - name: argo-cd diff --git a/remodel/k8s/infra/network/cloudflared/cloudflared-config.yaml b/remodel/k8s/infra/network/cloudflared/cloudflared-config.yaml new file mode 100644 index 0000000..1e79484 --- /dev/null +++ b/remodel/k8s/infra/network/cloudflared/cloudflared-config.yaml @@ -0,0 +1,24 @@ +tunnel: gauss-k8s +credentials-file: /etc/cloudflared/creds/credentials.json +metrics: 0.0.0.0:2000 +no-autoupdate: true + +warp-routing: + enabled: true + +ingress: + - hostname: hello.euclid.stonegarden.dev + service: hello_world + - hostname: haos.stonegarden.dev + service: https://cilium-gateway-stonegarden.gateway.svc.cluster.local:443 + originRequest: + originServerName: "*.stonegarden.dev" + - hostname: "*.euclid.stonegarden.dev" + service: https://cilium-gateway-euclid.gateway.svc.cluster.local:443 + originRequest: + originServerName: "*.euclid.stonegarden.dev" + - hostname: "*.stonegarden.dev" + service: https://cilium-gateway-stonegarden.gateway.svc.cluster.local:443 + originRequest: + originServerName: "*.stonegarden.dev" + - service: http_status:404 diff --git a/remodel/k8s/infra/network/cloudflared/daemon-set.yaml b/remodel/k8s/infra/network/cloudflared/daemon-set.yaml new file mode 100644 index 0000000..50161f6 --- /dev/null +++ b/remodel/k8s/infra/network/cloudflared/daemon-set.yaml @@ -0,0 +1,55 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: cloudflared + name: cloudflared + namespace: cloudflared +spec: + replicas: 1 + selector: + matchLabels: + app: cloudflared + template: + metadata: + labels: + app: cloudflared + spec: + containers: + - name: cloudflared + image: cloudflare/cloudflared:2024.2.1 + imagePullPolicy: Always + args: + - tunnel + - --config + - /etc/cloudflared/config/config.yaml + - run + livenessProbe: + httpGet: + path: /ready + port: 2000 + initialDelaySeconds: 60 + failureThreshold: 5 + periodSeconds: 10 + resources: + limits: + cpu: 100m + memory: 64Mi + requests: + cpu: 20m + memory: 32Mi + volumeMounts: + - name: cloudflared-config + mountPath: /etc/cloudflared/config/config.yaml + subPath: cloudflared-config.yaml + - name: tunnel-credentials + mountPath: /etc/cloudflared/creds + readOnly: true + restartPolicy: Always + volumes: + - name: cloudflared-config + configMap: + name: cloudflared-config + - name: tunnel-credentials + secret: + secretName: tunnel-credentials diff --git a/remodel/k8s/infra/network/cloudflared/kustomization.yaml b/remodel/k8s/infra/network/cloudflared/kustomization.yaml new file mode 100644 index 0000000..148e41f --- /dev/null +++ b/remodel/k8s/infra/network/cloudflared/kustomization.yaml @@ -0,0 +1,13 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +configMapGenerator: + - name: cloudflared-config + namespace: cloudflared + files: + - cloudflared-config.yaml + +resources: + - ns.yaml + - tunnel-credentials.yaml + - deployment.yaml \ No newline at end of file diff --git a/remodel/k8s/infra/network/cloudflared/ns.yaml b/remodel/k8s/infra/network/cloudflared/ns.yaml new file mode 100644 index 0000000..620b8ae --- /dev/null +++ b/remodel/k8s/infra/network/cloudflared/ns.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: cloudflared diff --git a/remodel/k8s/infra/network/cloudflared/tunnel-credentials.yaml b/remodel/k8s/infra/network/cloudflared/tunnel-credentials.yaml new file mode 100644 index 0000000..beabb9c --- /dev/null +++ b/remodel/k8s/infra/network/cloudflared/tunnel-credentials.yaml @@ -0,0 +1,15 @@ +--- +apiVersion: bitnami.com/v1alpha1 +kind: SealedSecret +metadata: + creationTimestamp: null + name: tunnel-credentials + namespace: cloudflared +spec: + encryptedData: + credentials.json: AgDa8Wgyu4nbMyc55U6kOOvDTpL6LT7wPM1T+JKgjBtO+IRplYpIW5wwaWGqQF8tj47CHLhDyEiNyk9Srk9IgDTNKOYOjyCUFj/vt/s5hiKFsFQdGiKrqXQB4WwH2P02pPUacJOzOhbtOltCRTYtUlmvikSM4XzeYOoS1i1ikb9TvFPeKQ6o8LqViDUv+s4xAr/TX6j+7DJge5/BgKNI6ntR93sN1aTerSUl1opNVhMOsfPz5WvAjuhNh1c4V1xTzk/xc9nq0uJ9MHD2O9o68vwBDwNystp4vOz4l/X1pi1ZsM4QQkmdX7LIH4fDdzPSf1f5SfDd5ssHmAGXkzGQtJfFCwAcFl0vm/0f2a3Ema6+jCibkuL0DKGh3ca+wjAJFxH7T1mqSP84djC54CqyR5cPXBzM29vWqSJG802YXf0J0pT78/3NW6chD9cQNiqQh4cslqc11Ye7VOkt4b5FWXLczcl9qqtpBmBIdmKmokO81vEGtt/P2rMeX02cQg500pW/WO+MrLq8LanKiJZuJfy1YSNO7hzeSLbN6O/Tkvl7GKV7h08sCDUJFwlFc8DrX8YfYdFSzL8rRzg5pMg434ECPxNnYN2EKAF0re4PeY3RvKiRkZxZ3KZMMX3EpiR+5joLBUeDGMbCfTFt8gVhaHZDBO69b+WrDtAYuIgM74qCPz3j30ToYAI1H0vprAI0NghnDb/IgF0m/ASlvQ0dqR/Y+OHZggLJI0hvu/MVYnwvJmUHK4NUl3V4BPg9SZp4bCZM0NF5QIZZBmG+DfSlrAMBWBbYZRfRSIoo/vfxblk8E9YKa2RMusiVep0Gs4FKDF4kG1YBK+u3XV/8ot7lih/EHKMk2DgczoQnqlCMbZzY4vKfaSVpmv66lbcVk7PXZIDrTdPef89C3VcJxA5kjmVW5w== + template: + metadata: + creationTimestamp: null + name: tunnel-credentials + namespace: cloudflared diff --git a/remodel/k8s/infra/storage/proxmox-csi/kustomization.yaml b/remodel/k8s/infra/storage/proxmox-csi/kustomization.yaml index b0b6e9a..9c765f7 100644 --- a/remodel/k8s/infra/storage/proxmox-csi/kustomization.yaml +++ b/remodel/k8s/infra/storage/proxmox-csi/kustomization.yaml @@ -1,10 +1,10 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization -#resources: +resources: # - ns.yaml -## - https://raw.githubusercontent.com/sergelogvinov/proxmox-csi-plugin/v0.7.0/docs/deploy/proxmox-csi-plugin-release.yml -# - storage-class.yaml + - https://raw.githubusercontent.com/sergelogvinov/proxmox-csi-plugin/v0.7.0/docs/deploy/proxmox-csi-plugin-release.yml + - storage-class.yaml #images: # - name: ghcr.io/sergelogvinov/proxmox-csi-node @@ -12,14 +12,14 @@ kind: Kustomization # - name: ghcr.io/sergelogvinov/proxmox-csi-controller # newTag: edge -helmCharts: - - name: proxmox-csi-plugin - repo: oci://ghcr.io/sergelogvinov/charts - version: 0.2.5 - releaseName: proxmox-csi-plugin - includeCRDs: true - namespace: csi-proxmox - valuesFile: values.yaml +#helmCharts: +# - name: proxmox-csi-plugin +# repo: oci://ghcr.io/sergelogvinov/charts +# version: 0.2.5 +# releaseName: proxmox-csi-plugin +# includeCRDs: true +# namespace: csi-proxmox +# valuesFile: values.yaml #helmCharts: # - name: proxmox-csi-plugin diff --git a/remodel/tofu/kubernetes/bootstrap/volumes/main.tf b/remodel/tofu/kubernetes/bootstrap/volumes/main.tf index 8a36894..9414654 100644 --- a/remodel/tofu/kubernetes/bootstrap/volumes/main.tf +++ b/remodel/tofu/kubernetes/bootstrap/volumes/main.tf @@ -1,6 +1,6 @@ module "proxmox-volume" { for_each = var.volumes - source = "./proxmox-volume" + source = "./proxmox-volume" providers = { restapi = restapi @@ -8,15 +8,18 @@ module "proxmox-volume" { proxmox_api = var.proxmox_api volume = { - name = each.key - node = each.value.node - size = each.value.size + name = each.key + node = each.value.node + size = each.value.size + storage = each.value.storage + vmid = each.value.vmid + format = each.value.format } } module "persistent-volume" { for_each = var.volumes - source = "./persistent-volume" + source = "./persistent-volume" providers = { kubernetes = kubernetes @@ -26,5 +29,6 @@ module "persistent-volume" { name = each.key capacity = each.value.size volume_handle = "${var.proxmox_api.cluster_name}/${module.proxmox-volume[each.key].node}/${module.proxmox-volume[each.key].storage}/${module.proxmox-volume[each.key].filename}" + storage = each.value.storage } } diff --git a/remodel/tofu/kubernetes/bootstrap/volumes/persistent-volume/persistent-volume.tf b/remodel/tofu/kubernetes/bootstrap/volumes/persistent-volume/persistent-volume.tf index bf59625..ae35e80 100644 --- a/remodel/tofu/kubernetes/bootstrap/volumes/persistent-volume/persistent-volume.tf +++ b/remodel/tofu/kubernetes/bootstrap/volumes/persistent-volume/persistent-volume.tf @@ -12,10 +12,14 @@ resource "kubernetes_persistent_volume" "pv" { volume_mode = var.volume.volume_mode persistent_volume_source { csi { - driver = var.volume.driver - fs_type = var.volume.fs_type - volume_handle = var.volume.volume_handle - volume_attributes = var.volume.volume_attributes + driver = var.volume.driver + fs_type = var.volume.fs_type + volume_handle = var.volume.volume_handle + volume_attributes = { + cache = var.volume.cache + ssd = var.volume.ssd == true ? "true" : "false" + storage = var.volume.storage + } } } } diff --git a/remodel/tofu/kubernetes/bootstrap/volumes/persistent-volume/variables.tf b/remodel/tofu/kubernetes/bootstrap/volumes/persistent-volume/variables.tf index 60a2680..8ae5e10 100644 --- a/remodel/tofu/kubernetes/bootstrap/volumes/persistent-volume/variables.tf +++ b/remodel/tofu/kubernetes/bootstrap/volumes/persistent-volume/variables.tf @@ -5,15 +5,13 @@ variable "volume" { capacity = string volume_handle = string access_modes = optional(list(string), ["ReadWriteOnce"]) - storage_class_name = optional(string, "porxmox-csi") + storage_class_name = optional(string, "proxmox-csi") fs_type = optional(string, "ext4") driver = optional(string, "csi.proxmox.sinextra.dev") volume_mode = optional(string, "Filesystem") mount_options = optional(list(string), ["noatime"]) - volume_attributes = optional(object({}), { - cache = "writethrough" - ssd = "true" - storage = "local-zfs" - }) + cache = optional(string, "writethrough") + ssd = optional(bool, true) + storage = optional(string, "local-zfs") }) } diff --git a/remodel/tofu/kubernetes/bootstrap/volumes/proxmox-volume/variables.tf b/remodel/tofu/kubernetes/bootstrap/volumes/proxmox-volume/variables.tf index 5f2e115..37c2904 100644 --- a/remodel/tofu/kubernetes/bootstrap/volumes/proxmox-volume/variables.tf +++ b/remodel/tofu/kubernetes/bootstrap/volumes/proxmox-volume/variables.tf @@ -9,8 +9,8 @@ variable "proxmox_api" { variable "volume" { type = object({ - node = string name = string + node = string size = string storage = optional(string, "local-zfs") vmid = optional(number, 9999)