Split CloudNativePG from Postgres Cluster
This commit is contained in:
@@ -4,7 +4,7 @@ metadata:
|
||||
name: linking
|
||||
namespace: linkding
|
||||
resources:
|
||||
- srv.yaml
|
||||
- pvc.yaml
|
||||
- deployment.yaml
|
||||
- namespace.yaml
|
||||
- srv.yaml
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"danicos.dev/daniel/homelab/pkg/linkding"
|
||||
"danicos.dev/daniel/homelab/pkg/longhorn"
|
||||
"danicos.dev/daniel/homelab/pkg/monitoring"
|
||||
"danicos.dev/daniel/homelab/pkg/postgres"
|
||||
"danicos.dev/daniel/homelab/pkg/root"
|
||||
"danicos.dev/daniel/homelab/pkg/truenas"
|
||||
/*
|
||||
@@ -29,6 +30,7 @@ func main() {
|
||||
"longhorn": longhorn.Stack(),
|
||||
"truenas-csi": truenas.Stack(),
|
||||
"cloud-native-pg": cnpg.Stack(),
|
||||
"postgres": postgres.Stack(),
|
||||
}
|
||||
for name, s := range hydra_infrastructure {
|
||||
fmt.Printf("STACK: %s\n", name)
|
||||
|
||||
@@ -5,8 +5,5 @@ metadata:
|
||||
namespace: cnpg-system
|
||||
resources:
|
||||
- namespace.yaml
|
||||
- cluster-namespace.yaml
|
||||
- helm-repository-source.yaml
|
||||
- helm-release.yaml
|
||||
- pg-cluster.yaml
|
||||
- immich-db.yaml
|
||||
|
||||
@@ -6,4 +6,4 @@ resources:
|
||||
- truenas-csi-driver.yaml
|
||||
- monitoring/
|
||||
- longhorn/
|
||||
# - cloud-native-pg/
|
||||
- cloud-native-pg/
|
||||
|
||||
@@ -4,6 +4,6 @@ metadata:
|
||||
name: longhorn
|
||||
namespace: longhorn-system
|
||||
resources:
|
||||
- namespace.yaml
|
||||
- longhorn-stack.yaml
|
||||
- release.yaml
|
||||
- namespace.yaml
|
||||
|
||||
@@ -4,6 +4,6 @@ metadata:
|
||||
name: monitoring
|
||||
namespace: monitoring
|
||||
resources:
|
||||
- namespace.yaml
|
||||
- kube-prometheus-stack.yaml
|
||||
- release.yaml
|
||||
- namespace.yaml
|
||||
|
||||
9
infrastructure/hydra/postgres/kustomization.yaml
Normal file
9
infrastructure/hydra/postgres/kustomization.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
metadata:
|
||||
name: cnpg-cluster
|
||||
namespace: cnpg-cluster
|
||||
resources:
|
||||
- pg-cluster.yaml
|
||||
- immich-db.yaml
|
||||
- cluster-namespace.yaml
|
||||
@@ -4,7 +4,7 @@ metadata:
|
||||
name: truenas-csi
|
||||
namespace: truenas-csi
|
||||
resources:
|
||||
- namespace.yaml
|
||||
- config.yaml
|
||||
- nfs-storage-class.yaml
|
||||
- iscsi-storage-class.yaml
|
||||
- namespace.yaml
|
||||
|
||||
@@ -1,38 +1 @@
|
||||
package cnpg
|
||||
|
||||
import (
|
||||
"danicos.dev/daniel/go-kube/pkg/kube"
|
||||
"danicos.dev/daniel/homelab/pkg/root"
|
||||
|
||||
kube_cnpg "danicos.dev/daniel/go-kube/pkg/cnpg"
|
||||
pg "github.com/cloudnative-pg/api/pkg/api/v1"
|
||||
core "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
var cluster_meta = kube.NewMetadata(root.CloudNativePG+"-cluster", root.PGClusterNamespace)
|
||||
|
||||
func Cluster() pg.Cluster {
|
||||
spec := pg.ClusterSpec{
|
||||
Instances: 3,
|
||||
StorageConfiguration: pg.StorageConfiguration{
|
||||
StorageClass: new(root.KUBE_LOCAL_STORAGE_CLASS),
|
||||
Size: "10Gi",
|
||||
ResizeInUseVolumes: new(true),
|
||||
PersistentVolumeClaimTemplate: &core.PersistentVolumeClaimSpec{
|
||||
StorageClassName: new(root.KUBE_LOCAL_STORAGE_CLASS),
|
||||
},
|
||||
},
|
||||
Managed: &pg.ManagedConfiguration{
|
||||
Roles: []pg.RoleConfiguration{
|
||||
{
|
||||
Name: root.Immich.Name,
|
||||
Login: true,
|
||||
PasswordSecret: &pg.LocalObjectReference{
|
||||
Name: ImmichPGSecret.Name,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
return kube_cnpg.NewCluster(cluster_meta, spec)
|
||||
}
|
||||
|
||||
@@ -18,11 +18,8 @@ func Stack() stack.Stack {
|
||||
meta_system,
|
||||
map[string]any{
|
||||
"namespace": SystemNamespace,
|
||||
"cluster-namespace": root.PGClusterNamespace,
|
||||
"helm-repository-source": HelmSource(),
|
||||
"helm-release": HelmRelease(),
|
||||
"pg-cluster": Cluster(),
|
||||
"immich-db": ImmichDatabase(),
|
||||
},
|
||||
)
|
||||
return kz.Stack("cloud-native-pg")
|
||||
|
||||
@@ -1,23 +1 @@
|
||||
package cnpg
|
||||
|
||||
import (
|
||||
kube_cnpg "danicos.dev/daniel/go-kube/pkg/cnpg"
|
||||
"danicos.dev/daniel/go-kube/pkg/kube"
|
||||
"danicos.dev/daniel/homelab/pkg/root"
|
||||
pg "github.com/cloudnative-pg/api/pkg/api/v1"
|
||||
core "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
var ImmichPGSecret = kube_cnpg.NewPGSecret(root.Immich.Name, root.PGClusterNamespace)
|
||||
|
||||
func ImmichDatabase() pg.Database {
|
||||
meta := kube.NewMetadata(root.Immich.Name+"-db", root.PGClusterNamespace)
|
||||
spec := pg.DatabaseSpec{
|
||||
Name: root.Immich.Name,
|
||||
Owner: root.Immich.Name,
|
||||
ClusterRef: core.LocalObjectReference{
|
||||
Name: cluster_meta.Meta().Name,
|
||||
},
|
||||
}
|
||||
return kube_cnpg.NewDatabase(meta, spec)
|
||||
}
|
||||
|
||||
65
pkg/postgres/postgres.go
Normal file
65
pkg/postgres/postgres.go
Normal file
@@ -0,0 +1,65 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"danicos.dev/daniel/go-kube/pkg/kube"
|
||||
"danicos.dev/daniel/go-kube/pkg/stack"
|
||||
"danicos.dev/daniel/homelab/pkg/root"
|
||||
|
||||
kube_cnpg "danicos.dev/daniel/go-kube/pkg/cnpg"
|
||||
pg "github.com/cloudnative-pg/api/pkg/api/v1"
|
||||
core "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
var cluster_meta = kube.NewMetadata(root.CloudNativePG+"-cluster", root.PGClusterNamespace)
|
||||
|
||||
func Stack() stack.Stack {
|
||||
kz := kube.NewKuztomizedStack(
|
||||
cluster_meta,
|
||||
map[string]any{
|
||||
"cluster-namespace": root.PGClusterNamespace,
|
||||
"pg-cluster": Cluster(),
|
||||
"immich-db": ImmichDatabase(),
|
||||
},
|
||||
)
|
||||
return kz.Stack("postgres")
|
||||
}
|
||||
|
||||
func Cluster() pg.Cluster {
|
||||
spec := pg.ClusterSpec{
|
||||
Instances: 3,
|
||||
StorageConfiguration: pg.StorageConfiguration{
|
||||
StorageClass: new(root.KUBE_LOCAL_STORAGE_CLASS),
|
||||
Size: "10Gi",
|
||||
ResizeInUseVolumes: new(true),
|
||||
PersistentVolumeClaimTemplate: &core.PersistentVolumeClaimSpec{
|
||||
StorageClassName: new(root.KUBE_LOCAL_STORAGE_CLASS),
|
||||
},
|
||||
},
|
||||
Managed: &pg.ManagedConfiguration{
|
||||
Roles: []pg.RoleConfiguration{
|
||||
{
|
||||
Name: root.Immich.Name,
|
||||
Login: true,
|
||||
PasswordSecret: &pg.LocalObjectReference{
|
||||
Name: ImmichPGSecret.Name,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
return kube_cnpg.NewCluster(cluster_meta, spec)
|
||||
}
|
||||
|
||||
var ImmichPGSecret = kube_cnpg.NewPGSecret(root.Immich.Name, root.PGClusterNamespace)
|
||||
|
||||
func ImmichDatabase() pg.Database {
|
||||
meta := kube.NewMetadata(root.Immich.Name+"-db", root.PGClusterNamespace)
|
||||
spec := pg.DatabaseSpec{
|
||||
Name: root.Immich.Name,
|
||||
Owner: root.Immich.Name,
|
||||
ClusterRef: core.LocalObjectReference{
|
||||
Name: cluster_meta.Meta().Name,
|
||||
},
|
||||
}
|
||||
return kube_cnpg.NewDatabase(meta, spec)
|
||||
}
|
||||
Reference in New Issue
Block a user