Add Immich Database
This commit is contained in:
@@ -2,7 +2,6 @@ package cnpg
|
||||
|
||||
import (
|
||||
"danicos.dev/daniel/go-kube/pkg/kube"
|
||||
"danicos.dev/daniel/homelab/pkg/immich"
|
||||
"danicos.dev/daniel/homelab/pkg/root"
|
||||
|
||||
kube_cnpg "danicos.dev/daniel/go-kube/pkg/cnpg"
|
||||
@@ -10,8 +9,9 @@ import (
|
||||
core "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
var cluster_meta = kube.NewMetadata(root.CloudNativePG+"-cluster", root.PGClusterNamespace)
|
||||
|
||||
func Cluster() pg.Cluster {
|
||||
meta := kube.NewMetadata(root.CloudNativePG+"-cluster", PGClusterNamespace)
|
||||
spec := pg.ClusterSpec{
|
||||
Instances: 3,
|
||||
StorageConfiguration: pg.StorageConfiguration{
|
||||
@@ -28,17 +28,11 @@ func Cluster() pg.Cluster {
|
||||
Name: root.Immich.Name,
|
||||
Login: true,
|
||||
PasswordSecret: &pg.LocalObjectReference{
|
||||
Name: immich.Secret.Name,
|
||||
Name: ImmichPGSecret.Name,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
return kube_cnpg.NewCluster(meta, spec)
|
||||
return kube_cnpg.NewCluster(cluster_meta, spec)
|
||||
}
|
||||
|
||||
/*
|
||||
PG expects username, password
|
||||
|
||||
PG Secret
|
||||
*/
|
||||
|
||||
@@ -6,21 +6,21 @@ import (
|
||||
"danicos.dev/daniel/homelab/pkg/root"
|
||||
)
|
||||
|
||||
var meta kube.Metadata
|
||||
var Namespace = kube.Namespace(root.CloudNativePG + "-system")
|
||||
var PGClusterNamespace = kube.Namespace(root.CloudNativePG + "-cluster")
|
||||
var meta_system kube.Metadata
|
||||
var SystemNamespace = kube.Namespace(root.CloudNativePG + "-system")
|
||||
|
||||
func init() {
|
||||
meta = kube.NewMetadata(root.CloudNativePG, Namespace)
|
||||
meta_system = kube.NewMetadata(root.CloudNativePG, SystemNamespace)
|
||||
}
|
||||
|
||||
func Stack() stack.Stack {
|
||||
s := stack.NewStack("cloud-native-pg", map[string]any{
|
||||
"namespace": Namespace,
|
||||
"cluster-namespace": PGClusterNamespace,
|
||||
"namespace": SystemNamespace,
|
||||
"cluster-namespace": root.PGClusterNamespace,
|
||||
"helm-repository-source": HelmSource(),
|
||||
"helm-release": HelmRelease(),
|
||||
"pg-cluster": Cluster(),
|
||||
"immich-db": ImmichDatabase(),
|
||||
})
|
||||
return s
|
||||
}
|
||||
|
||||
23
pkg/cnpg/database.go
Normal file
23
pkg/cnpg/database.go
Normal file
@@ -0,0 +1,23 @@
|
||||
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)
|
||||
}
|
||||
@@ -16,7 +16,7 @@ func HelmSource() source.HelmRepository {
|
||||
Interval: durHour(root.FLUX_HELM_MONITORING_INTERVAL),
|
||||
URL: root.HELM_CLOUD_NATIVE_PG_URL,
|
||||
}
|
||||
return flux.NewFluxHelmRepositorySource(meta, spec)
|
||||
return flux.NewFluxHelmRepositorySource(meta_system, spec)
|
||||
}
|
||||
|
||||
func HelmRelease() helm.HelmRelease {
|
||||
@@ -30,15 +30,15 @@ func HelmRelease() helm.HelmRelease {
|
||||
Interval: &interval,
|
||||
SourceRef: helm.CrossNamespaceObjectReference{
|
||||
Kind: flux.MetaHelmRepository.Kind,
|
||||
Name: meta.Meta().Name,
|
||||
Namespace: Namespace.Name,
|
||||
Name: meta_system.Meta().Name,
|
||||
Namespace: SystemNamespace.Name,
|
||||
},
|
||||
},
|
||||
},
|
||||
Install: &helm.Install{CRDs: helm.Create},
|
||||
Upgrade: &helm.Upgrade{CRDs: helm.CreateReplace},
|
||||
}
|
||||
return flux.NewFluxHelmRelease(meta, spec)
|
||||
return flux.NewFluxHelmRelease(meta_system, spec)
|
||||
}
|
||||
|
||||
func durHour(d int64) metav1.Duration {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -7,16 +7,6 @@ import (
|
||||
core "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
var Secret = struct {
|
||||
Name string
|
||||
DB_UserKey string
|
||||
DB_PasswordKey string
|
||||
}{
|
||||
Name: root.Immich.Name,
|
||||
DB_UserKey: "db_username",
|
||||
DB_PasswordKey: "db_password",
|
||||
}
|
||||
|
||||
var meta kube.Metadata
|
||||
var Namespace = kube.Namespace(root.Immich.Name)
|
||||
var srv core.Service
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package root
|
||||
|
||||
import (
|
||||
"danicos.dev/daniel/go-kube/pkg/kube"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
Name string
|
||||
Image string
|
||||
@@ -34,9 +38,10 @@ var Immich = Service{
|
||||
}
|
||||
|
||||
var (
|
||||
Longhorn = "longhorn"
|
||||
Monitoring = "monitoring"
|
||||
CloudNativePG = "cnpg"
|
||||
Longhorn = "longhorn"
|
||||
Monitoring = "monitoring"
|
||||
CloudNativePG = "cnpg"
|
||||
PGClusterNamespace = kube.Namespace(CloudNativePG + "-cluster")
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
Reference in New Issue
Block a user