mirror of
https://github.com/optim-enterprises-bv/homelab.git
synced 2025-10-30 01:22:31 +00:00
feat(database): add cnpg for database management
This commit is contained in:
37
k8s/infra/database/application-set.yaml
Normal file
37
k8s/infra/database/application-set.yaml
Normal file
@@ -0,0 +1,37 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: ApplicationSet
|
||||
metadata:
|
||||
name: database
|
||||
namespace: argocd
|
||||
labels:
|
||||
dev.stonegarden: database
|
||||
spec:
|
||||
generators:
|
||||
- git:
|
||||
repoURL: https://github.com/vehagn/homelab
|
||||
revision: HEAD
|
||||
directories:
|
||||
- path: k8s/infra/database/*
|
||||
template:
|
||||
metadata:
|
||||
name: '{{ path.basename }}'
|
||||
labels:
|
||||
dev.stonegarden: controllers
|
||||
spec:
|
||||
project: database
|
||||
source:
|
||||
plugin:
|
||||
name: kustomize-build-with-helm
|
||||
repoURL: https://github.com/vehagn/homelab
|
||||
targetRevision: HEAD
|
||||
path: '{{ path }}'
|
||||
destination:
|
||||
name: in-cluster
|
||||
namespace: argocd
|
||||
syncPolicy:
|
||||
automated:
|
||||
selfHeal: true
|
||||
prune: true
|
||||
syncOptions:
|
||||
- ApplyOutOfSyncOnly=true
|
||||
- ServerSideApply=true
|
||||
15
k8s/infra/database/cnpg/kustomization.yaml
Normal file
15
k8s/infra/database/cnpg/kustomization.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: cnpg-system
|
||||
|
||||
resources:
|
||||
- ns.yaml
|
||||
|
||||
helmCharts:
|
||||
- name: cloudnative-pg
|
||||
repo: https://cloudnative-pg.github.io/charts
|
||||
releaseName: cnpg
|
||||
namespace: cnpg-system
|
||||
includeCRDs: true
|
||||
version: 0.22.0
|
||||
valuesFile: values.yaml
|
||||
4
k8s/infra/database/cnpg/ns.yaml
Normal file
4
k8s/infra/database/cnpg/ns.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: cnpg-system
|
||||
0
k8s/infra/database/cnpg/values.yaml
Normal file
0
k8s/infra/database/cnpg/values.yaml
Normal file
10
k8s/infra/database/kustomization.yaml
Normal file
10
k8s/infra/database/kustomization.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
commonLabels:
|
||||
dev.stonegarden: auth
|
||||
app.kubernetes.io/managed-by: argocd
|
||||
|
||||
resources:
|
||||
- ns.yaml
|
||||
- project.yaml
|
||||
- application-set.yaml
|
||||
4
k8s/infra/database/ns.yaml
Normal file
4
k8s/infra/database/ns.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: cnpg-database
|
||||
10
k8s/infra/database/pg-cluster/cnpg-cluster.yaml
Normal file
10
k8s/infra/database/pg-cluster/cnpg-cluster.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
apiVersion: postgresql.cnpg.io/v1
|
||||
kind: Cluster
|
||||
metadata:
|
||||
name: cluster-example
|
||||
namespace: cnpg-database
|
||||
spec:
|
||||
instances: 3
|
||||
storage:
|
||||
storageClass: proxmox-csi
|
||||
size: 4G
|
||||
6
k8s/infra/database/pg-cluster/kustomization.yaml
Normal file
6
k8s/infra/database/pg-cluster/kustomization.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: cnpg-database
|
||||
|
||||
resources:
|
||||
- cnpg-cluster.yaml
|
||||
17
k8s/infra/database/pg-single/cnpg-single.yaml
Normal file
17
k8s/infra/database/pg-single/cnpg-single.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
apiVersion: postgresql.cnpg.io/v1
|
||||
kind: Cluster
|
||||
metadata:
|
||||
name: single-example
|
||||
namespace: cnpg-database
|
||||
spec:
|
||||
instances: 1
|
||||
affinity:
|
||||
nodeSelector:
|
||||
topology.kubernetes.io/zone: euclid
|
||||
storage:
|
||||
size: 4G
|
||||
pvcTemplate:
|
||||
storageClassName: proxmox-csi
|
||||
volumeName: pv-single-database
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
6
k8s/infra/database/pg-single/kustomization.yaml
Normal file
6
k8s/infra/database/pg-single/kustomization.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: cnpg-database
|
||||
|
||||
resources:
|
||||
- cnpg-single.yaml
|
||||
18
k8s/infra/database/project.yaml
Normal file
18
k8s/infra/database/project.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: AppProject
|
||||
metadata:
|
||||
name: database
|
||||
namespace: argocd
|
||||
spec:
|
||||
sourceRepos:
|
||||
- 'https://github.com/vehagn/homelab'
|
||||
destinations:
|
||||
- namespace: 'argocd'
|
||||
server: '*'
|
||||
- namespace: 'cnpg-database'
|
||||
server: '*'
|
||||
- namespace: 'cnpg-system'
|
||||
server: '*'
|
||||
clusterResourceWhitelist:
|
||||
- group: '*'
|
||||
kind: '*'
|
||||
@@ -32,3 +32,6 @@ spec:
|
||||
automated:
|
||||
selfHeal: true
|
||||
prune: true
|
||||
syncOptions:
|
||||
- ApplyOutOfSyncOnly=true
|
||||
- ServerSideApply=true
|
||||
|
||||
@@ -26,4 +26,4 @@ spec:
|
||||
prune: true
|
||||
syncOptions:
|
||||
- ApplyOutOfSyncOnly=true
|
||||
- ServerSideApply=true
|
||||
- ServerSideApply=true
|
||||
|
||||
@@ -29,6 +29,7 @@ tofu state rm "module.volumes.module.proxmox-volume[\"pv-qbittorrent-config\"].r
|
||||
tofu state rm 'module.volumes.module.proxmox-volume["pv-keycloak"].restapi_object.proxmox-volume'
|
||||
tofu state rm 'module.volumes.module.proxmox-volume["pv-netbird-management"].restapi_object.proxmox-volume'
|
||||
tofu state rm 'module.volumes.module.proxmox-volume["pv-netbird-signal"].restapi_object.proxmox-volume'
|
||||
tofu state rm 'module.volumes.module.proxmox-volume["pv-database"].restapi_object.proxmox-volume'
|
||||
```
|
||||
|
||||
## import proxmox volume
|
||||
@@ -46,6 +47,7 @@ tofu import 'module.volumes.module.proxmox-volume["pv-radarr-config"].restapi_ob
|
||||
tofu import 'module.volumes.module.proxmox-volume["pv-remark42"].restapi_object.proxmox-volume' /api2/json/nodes/euclid/storage/local-zfs/content/local-zfs:vm-9999-pv-remark42
|
||||
tofu import 'module.volumes.module.proxmox-volume["pv-sonarr-config"].restapi_object.proxmox-volume' /api2/json/nodes/cantor/storage/local-zfs/content/local-zfs:vm-9999-pv-sonarr-config
|
||||
tofu import 'module.volumes.module.proxmox-volume["pv-torrent-config"].restapi_object.proxmox-volume' /api2/json/nodes/euclid/storage/local-zfs/content/local-zfs:vm-9999-pv-torrent-config
|
||||
tofu import 'module.volumes.module.proxmox-volume["pv-database"].restapi_object.proxmox-volume' /api2/json/nodes/euclid/storage/local-zfs/content/local-zfs:vm-9999-pv-database
|
||||
```
|
||||
|
||||
## import persistent volume
|
||||
|
||||
@@ -17,7 +17,7 @@ resource "restapi_object" "proxmox-volume" {
|
||||
})
|
||||
|
||||
lifecycle {
|
||||
prevent_destroy = true
|
||||
prevent_destroy = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -152,5 +152,9 @@ module "volumes" {
|
||||
node = "abel"
|
||||
size = "10G"
|
||||
}
|
||||
pv-single-database = {
|
||||
node = "euclid"
|
||||
size = "4G"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user