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
@@ -0,0 +1,12 @@
apiVersion: postgresql.cnpg.io/v1
kind: ClusterImageCatalog
metadata:
name: pg-minimal-trixie
spec:
images:
- extensions:
- image:
reference: ghcr.io/cloudnative-pg/pgvector:0.8.2-18-trixie
name: pgvector
image: ghcr.io/cloudnative-pg/postgresql:18.3-minimal-trixie
major: 18
@@ -5,5 +5,6 @@ metadata:
namespace: cnpg-cluster namespace: cnpg-cluster
resources: resources:
- cluster-namespace.yaml - cluster-namespace.yaml
- image-cataglog.yaml
- immich-db.yaml - immich-db.yaml
- pg-cluster.yaml - pg-cluster.yaml
@@ -5,6 +5,11 @@ metadata:
namespace: cnpg-cluster namespace: cnpg-cluster
spec: spec:
affinity: {} affinity: {}
imageCatalogRef:
apiGroup: postgresql.cnpg.io/v1
kind: ClusterImageCatalog
major: 18
name: pg-minimal-trixie
instances: 3 instances: 3
managed: managed:
roles: roles:
@@ -13,6 +18,9 @@ spec:
passwordSecret: passwordSecret:
name: immich name: immich
postgresql: postgresql:
extensions:
- image: {}
name: pgvector
syncReplicaElectionConstraint: syncReplicaElectionConstraint:
enabled: false enabled: false
resources: {} resources: {}
+49 -14
View File
@@ -8,9 +8,15 @@ import (
kube_cnpg "danicos.dev/daniel/go-kube/pkg/cnpg" kube_cnpg "danicos.dev/daniel/go-kube/pkg/cnpg"
pg "github.com/cloudnative-pg/api/pkg/api/v1" pg "github.com/cloudnative-pg/api/pkg/api/v1"
core "k8s.io/api/core/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 cluster_meta = kube.NewMetadata(root.CloudNativePG+"-cluster", root.PGClusterNamespace)
var image_catalog pg.ImageCatalog
func init() {
image_catalog = ImageCatalog()
}
func Stack() stack.Stack { func Stack() stack.Stack {
kz := kube.NewKuztomizedStack( kz := kube.NewKuztomizedStack(
@@ -19,6 +25,7 @@ func Stack() stack.Stack {
"cluster-namespace": root.PGClusterNamespace, "cluster-namespace": root.PGClusterNamespace,
"pg-cluster": Cluster(), "pg-cluster": Cluster(),
"immich-db": ImmichDatabase(), "immich-db": ImmichDatabase(),
"image-cataglog": image_catalog,
}, },
) )
return kz.Stack("postgres") return kz.Stack("postgres")
@@ -35,19 +42,21 @@ func Cluster() pg.Cluster {
StorageClassName: new(root.KUBE_LOCAL_STORAGE_CLASS), StorageClassName: new(root.KUBE_LOCAL_STORAGE_CLASS),
}, },
}, },
// PostgresConfiguration: pg.PostgresConfiguration{ ImageCatalogRef: &pg.ImageCatalogRef{
// Extensions: []pg.ExtensionConfiguration{ TypedLocalObjectReference: core.TypedLocalObjectReference{
// { APIGroup: &image_catalog.APIVersion,
// Name: "vector", Kind: image_catalog.Kind,
// ImageVolumeSource: core.ImageVolumeSource{}, Name: image_catalog.Name,
// ExtensionControlPath: []string{}, },
// DynamicLibraryPath: []string{}, Major: root.PG_VERSION_18,
// LdLibraryPath: []string{}, },
// BinPath: []string{}, PostgresConfiguration: pg.PostgresConfiguration{
// Env: []pg.ExtensionEnvVar{}, Extensions: []pg.ExtensionConfiguration{
// }, {
// }, Name: "pgvector",
// }, },
},
},
Managed: &pg.ManagedConfiguration{ Managed: &pg.ManagedConfiguration{
Roles: []pg.RoleConfiguration{ Roles: []pg.RoleConfiguration{
{ {
@@ -63,6 +72,32 @@ func Cluster() pg.Cluster {
return kube_cnpg.NewCluster(cluster_meta, spec) 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) var ImmichPGSecret = kube_cnpg.NewPGSecret(root.Immich.Name, root.PGClusterNamespace)
func ImmichDatabase() pg.Database { func ImmichDatabase() pg.Database {
@@ -76,7 +111,7 @@ func ImmichDatabase() pg.Database {
Extensions: []pg.ExtensionSpec{ Extensions: []pg.ExtensionSpec{
// { // {
// DatabaseObjectSpec: pg.DatabaseObjectSpec{ // DatabaseObjectSpec: pg.DatabaseObjectSpec{
// Name: "vectors", // Name: "pgvector",
// Ensure: pg.EnsurePresent, // Ensure: pg.EnsurePresent,
// }, // },
// }, // },
+3
View File
@@ -38,6 +38,9 @@ const (
HELM_CLOUD_NATIVE_PG_URL = "https://cloudnative-pg.github.io/charts" HELM_CLOUD_NATIVE_PG_URL = "https://cloudnative-pg.github.io/charts"
HELM_CLOUD_NATIVE_PG_CHART = "cloudnative-pg" HELM_CLOUD_NATIVE_PG_CHART = "cloudnative-pg"
HELM_CLOUD_NATIVE_PG_CHART_VERSION = "0.28.0" HELM_CLOUD_NATIVE_PG_CHART_VERSION = "0.28.0"
PG_VERSION_NAME = "pg-minimal-trixie"
PG_VERSION_18 = 18
PG_VERSION_18_IMAGE = "ghcr.io/cloudnative-pg/postgresql:18.3-minimal-trixie"
) )
var ( var (