Add ClusterImageCatalog

This commit is contained in:
Daniel Cosme
2026-05-05 13:45:42 -04:00
parent eee3907f1c
commit 75e85bc116
5 changed files with 73 additions and 14 deletions

View File

@@ -8,9 +8,15 @@ import (
kube_cnpg "danicos.dev/daniel/go-kube/pkg/cnpg"
pg "github.com/cloudnative-pg/api/pkg/api/v1"
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
)
var cluster_meta = kube.NewMetadata(root.CloudNativePG+"-cluster", root.PGClusterNamespace)
var image_catalog pg.ImageCatalog
func init() {
image_catalog = ImageCatalog()
}
func Stack() stack.Stack {
kz := kube.NewKuztomizedStack(
@@ -19,6 +25,7 @@ func Stack() stack.Stack {
"cluster-namespace": root.PGClusterNamespace,
"pg-cluster": Cluster(),
"immich-db": ImmichDatabase(),
"image-cataglog": image_catalog,
},
)
return kz.Stack("postgres")
@@ -35,19 +42,21 @@ func Cluster() pg.Cluster {
StorageClassName: new(root.KUBE_LOCAL_STORAGE_CLASS),
},
},
// PostgresConfiguration: pg.PostgresConfiguration{
// Extensions: []pg.ExtensionConfiguration{
// {
// Name: "vector",
// ImageVolumeSource: core.ImageVolumeSource{},
// ExtensionControlPath: []string{},
// DynamicLibraryPath: []string{},
// LdLibraryPath: []string{},
// BinPath: []string{},
// Env: []pg.ExtensionEnvVar{},
// },
// },
// },
ImageCatalogRef: &pg.ImageCatalogRef{
TypedLocalObjectReference: core.TypedLocalObjectReference{
APIGroup: &image_catalog.APIVersion,
Kind: image_catalog.Kind,
Name: image_catalog.Name,
},
Major: root.PG_VERSION_18,
},
PostgresConfiguration: pg.PostgresConfiguration{
Extensions: []pg.ExtensionConfiguration{
{
Name: "pgvector",
},
},
},
Managed: &pg.ManagedConfiguration{
Roles: []pg.RoleConfiguration{
{
@@ -63,6 +72,32 @@ func Cluster() pg.Cluster {
return kube_cnpg.NewCluster(cluster_meta, spec)
}
func ImageCatalog() pg.ImageCatalog {
return pg.ImageCatalog{
TypeMeta: meta.TypeMeta{
Kind: "ClusterImageCatalog",
APIVersion: "postgresql.cnpg.io/v1",
},
ObjectMeta: kube.ObjectMeta(root.PG_VERSION_NAME, ""),
Spec: pg.ImageCatalogSpec{
Images: []pg.CatalogImage{
{
Major: root.PG_VERSION_18,
Image: root.PG_VERSION_18_IMAGE,
Extensions: []pg.ExtensionConfiguration{
{
Name: "pgvector",
ImageVolumeSource: core.ImageVolumeSource{
Reference: "ghcr.io/cloudnative-pg/pgvector:0.8.2-18-trixie",
},
},
},
},
},
},
}
}
var ImmichPGSecret = kube_cnpg.NewPGSecret(root.Immich.Name, root.PGClusterNamespace)
func ImmichDatabase() pg.Database {
@@ -76,7 +111,7 @@ func ImmichDatabase() pg.Database {
Extensions: []pg.ExtensionSpec{
// {
// DatabaseObjectSpec: pg.DatabaseObjectSpec{
// Name: "vectors",
// Name: "pgvector",
// Ensure: pg.EnsurePresent,
// },
// },