2867: Configurable api group for postgres operator with default
In Kubernetes, there is tight coupling of API group, CRD and Custom Resources managed by operators. CRDs are cluster resource and unique per cluster. CRD operatorconfigurations.acid.zalan.do defines the operator configurations for postgres operator. CRD postgresqls.acid.zalan.do defines minimum and maximum supported postgresql versions. This leads to issues in a multi-tenant k8s cluster, an example provided below. In Namespace X, user X deploys web tier application which uses zalando postgres-operator with max version PG 15. In Namespace Y, user Y deploys web tier application which also uses zalando postgres-operator but needs PG 17 runs into an issue as CRD postgresqls.acid.zalan.do supports only PG 15. This happens because CRD is cluster scope and all namespace scoped applications should adhere to it. With large k8s clusters, postgresql being a very popular database, zalando postgres operator being defacto way to manage databases, there is a need to keep this configurable so applications can manage the API group of CRDs. Take API group for postgres operator as an env variable, assuming that the relevant CRDs with API groups are installed.
This commit is contained in:
parent
2a4be1cb39
commit
acb88d9b93
|
|
@ -1,6 +1,18 @@
|
|||
package acidzalando
|
||||
|
||||
const (
|
||||
import "os"
|
||||
|
||||
var (
|
||||
// GroupName is the group name for the operator CRDs
|
||||
GroupName = "acid.zalan.do"
|
||||
GroupName = getEnvWithDefault("POSTGRES_OPERATOR_API_GROUP", "ost.cloud.rakuten.com")
|
||||
)
|
||||
|
||||
func getEnvWithDefault(key, defaultValue string) string {
|
||||
if value := os.Getenv(key); value != "" {
|
||||
return value
|
||||
}
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,16 +15,19 @@ const (
|
|||
PostgresCRDResourceKind = "postgresql"
|
||||
PostgresCRDResourcePlural = "postgresqls"
|
||||
PostgresCRDResourceList = PostgresCRDResourceKind + "List"
|
||||
PostgresCRDResouceName = PostgresCRDResourcePlural + "." + acidzalando.GroupName
|
||||
PostgresCRDResourceShort = "pg"
|
||||
|
||||
OperatorConfigCRDResouceKind = "OperatorConfiguration"
|
||||
OperatorConfigCRDResourcePlural = "operatorconfigurations"
|
||||
OperatorConfigCRDResourceList = OperatorConfigCRDResouceKind + "List"
|
||||
OperatorConfigCRDResourceName = OperatorConfigCRDResourcePlural + "." + acidzalando.GroupName
|
||||
OperatorConfigCRDResourceShort = "opconfig"
|
||||
)
|
||||
|
||||
var (
|
||||
PostgresCRDResouceName = PostgresCRDResourcePlural + "." + acidzalando.GroupName
|
||||
OperatorConfigCRDResourceName = OperatorConfigCRDResourcePlural + "." + acidzalando.GroupName
|
||||
)
|
||||
|
||||
// PostgresCRDResourceColumns definition of AdditionalPrinterColumns for postgresql CRD
|
||||
var PostgresCRDResourceColumns = []apiextv1.CustomResourceColumnDefinition{
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue