Initial commit
This commit is contained in:
parent
5014eebfb2
commit
5373b085d8
|
|
@ -21,48 +21,48 @@ const (
|
||||||
|
|
||||||
// PostgresCRDResourceColumns definition of AdditionalPrinterColumns for postgresql CRD
|
// PostgresCRDResourceColumns definition of AdditionalPrinterColumns for postgresql CRD
|
||||||
var PostgresCRDResourceColumns = []apiextv1beta1.CustomResourceColumnDefinition{
|
var PostgresCRDResourceColumns = []apiextv1beta1.CustomResourceColumnDefinition{
|
||||||
apiextv1beta1.CustomResourceColumnDefinition{
|
{
|
||||||
Name: "Team",
|
Name: "Team",
|
||||||
Type: "string",
|
Type: "string",
|
||||||
Description: "Team responsible for Postgres cluster",
|
Description: "Team responsible for Postgres cluster",
|
||||||
JSONPath: ".spec.teamId",
|
JSONPath: ".spec.teamId",
|
||||||
},
|
},
|
||||||
apiextv1beta1.CustomResourceColumnDefinition{
|
{
|
||||||
Name: "Version",
|
Name: "Version",
|
||||||
Type: "string",
|
Type: "string",
|
||||||
Description: "PostgreSQL version",
|
Description: "PostgreSQL version",
|
||||||
JSONPath: ".spec.postgresql.version",
|
JSONPath: ".spec.postgresql.version",
|
||||||
},
|
},
|
||||||
apiextv1beta1.CustomResourceColumnDefinition{
|
{
|
||||||
Name: "Pods",
|
Name: "Pods",
|
||||||
Type: "integer",
|
Type: "integer",
|
||||||
Description: "Number of Pods per Postgres cluster",
|
Description: "Number of Pods per Postgres cluster",
|
||||||
JSONPath: ".spec.numberOfInstances",
|
JSONPath: ".spec.numberOfInstances",
|
||||||
},
|
},
|
||||||
apiextv1beta1.CustomResourceColumnDefinition{
|
{
|
||||||
Name: "Volume",
|
Name: "Volume",
|
||||||
Type: "string",
|
Type: "string",
|
||||||
Description: "Size of the bound volume",
|
Description: "Size of the bound volume",
|
||||||
JSONPath: ".spec.volume.size",
|
JSONPath: ".spec.volume.size",
|
||||||
},
|
},
|
||||||
apiextv1beta1.CustomResourceColumnDefinition{
|
{
|
||||||
Name: "CPU-Request",
|
Name: "CPU-Request",
|
||||||
Type: "string",
|
Type: "string",
|
||||||
Description: "Requested CPU for Postgres containers",
|
Description: "Requested CPU for Postgres containers",
|
||||||
JSONPath: ".spec.resources.requests.cpu",
|
JSONPath: ".spec.resources.requests.cpu",
|
||||||
},
|
},
|
||||||
apiextv1beta1.CustomResourceColumnDefinition{
|
{
|
||||||
Name: "Memory-Request",
|
Name: "Memory-Request",
|
||||||
Type: "string",
|
Type: "string",
|
||||||
Description: "Requested memory for Postgres containers",
|
Description: "Requested memory for Postgres containers",
|
||||||
JSONPath: ".spec.resources.requests.memory",
|
JSONPath: ".spec.resources.requests.memory",
|
||||||
},
|
},
|
||||||
apiextv1beta1.CustomResourceColumnDefinition{
|
{
|
||||||
Name: "Age",
|
Name: "Age",
|
||||||
Type: "date",
|
Type: "date",
|
||||||
JSONPath: ".metadata.creationTimestamp",
|
JSONPath: ".metadata.creationTimestamp",
|
||||||
},
|
},
|
||||||
apiextv1beta1.CustomResourceColumnDefinition{
|
{
|
||||||
Name: "Status",
|
Name: "Status",
|
||||||
Type: "string",
|
Type: "string",
|
||||||
Description: "Current sync status of postgresql resource",
|
Description: "Current sync status of postgresql resource",
|
||||||
|
|
@ -72,31 +72,31 @@ var PostgresCRDResourceColumns = []apiextv1beta1.CustomResourceColumnDefinition{
|
||||||
|
|
||||||
// OperatorConfigCRDResourceColumns definition of AdditionalPrinterColumns for OperatorConfiguration CRD
|
// OperatorConfigCRDResourceColumns definition of AdditionalPrinterColumns for OperatorConfiguration CRD
|
||||||
var OperatorConfigCRDResourceColumns = []apiextv1beta1.CustomResourceColumnDefinition{
|
var OperatorConfigCRDResourceColumns = []apiextv1beta1.CustomResourceColumnDefinition{
|
||||||
apiextv1beta1.CustomResourceColumnDefinition{
|
{
|
||||||
Name: "Image",
|
Name: "Image",
|
||||||
Type: "string",
|
Type: "string",
|
||||||
Description: "Spilo image to be used for Pods",
|
Description: "Spilo image to be used for Pods",
|
||||||
JSONPath: ".configuration.docker_image",
|
JSONPath: ".configuration.docker_image",
|
||||||
},
|
},
|
||||||
apiextv1beta1.CustomResourceColumnDefinition{
|
{
|
||||||
Name: "Cluster-Label",
|
Name: "Cluster-Label",
|
||||||
Type: "string",
|
Type: "string",
|
||||||
Description: "Label for K8s resources created by operator",
|
Description: "Label for K8s resources created by operator",
|
||||||
JSONPath: ".configuration.kubernetes.cluster_name_label",
|
JSONPath: ".configuration.kubernetes.cluster_name_label",
|
||||||
},
|
},
|
||||||
apiextv1beta1.CustomResourceColumnDefinition{
|
{
|
||||||
Name: "Service-Account",
|
Name: "Service-Account",
|
||||||
Type: "string",
|
Type: "string",
|
||||||
Description: "Name of service account to be used",
|
Description: "Name of service account to be used",
|
||||||
JSONPath: ".configuration.kubernetes.pod_service_account_name",
|
JSONPath: ".configuration.kubernetes.pod_service_account_name",
|
||||||
},
|
},
|
||||||
apiextv1beta1.CustomResourceColumnDefinition{
|
{
|
||||||
Name: "Min-Instances",
|
Name: "Min-Instances",
|
||||||
Type: "integer",
|
Type: "integer",
|
||||||
Description: "Minimum number of instances per Postgres cluster",
|
Description: "Minimum number of instances per Postgres cluster",
|
||||||
JSONPath: ".configuration.min_instances",
|
JSONPath: ".configuration.min_instances",
|
||||||
},
|
},
|
||||||
apiextv1beta1.CustomResourceColumnDefinition{
|
{
|
||||||
Name: "Age",
|
Name: "Age",
|
||||||
Type: "date",
|
Type: "date",
|
||||||
JSONPath: ".metadata.creationTimestamp",
|
JSONPath: ".metadata.creationTimestamp",
|
||||||
|
|
@ -837,6 +837,14 @@ var OperatorConfigCRDResourceValidation = apiextv1beta1.CustomResourceValidation
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"statefulset_propagate_annotations": {
|
||||||
|
Type: "object",
|
||||||
|
AdditionalProperties: &apiextv1beta1.JSONSchemaPropsOrBool{
|
||||||
|
Schema: &apiextv1beta1.JSONSchemaProps{
|
||||||
|
Type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
"enable_init_containers": {
|
"enable_init_containers": {
|
||||||
Type: "boolean",
|
Type: "boolean",
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ type KubernetesMetaConfiguration struct {
|
||||||
EnablePodAntiAffinity bool `json:"enable_pod_antiaffinity,omitempty"`
|
EnablePodAntiAffinity bool `json:"enable_pod_antiaffinity,omitempty"`
|
||||||
PodAntiAffinityTopologyKey string `json:"pod_antiaffinity_topology_key,omitempty"`
|
PodAntiAffinityTopologyKey string `json:"pod_antiaffinity_topology_key,omitempty"`
|
||||||
PodManagementPolicy string `json:"pod_management_policy,omitempty"`
|
PodManagementPolicy string `json:"pod_management_policy,omitempty"`
|
||||||
|
StatefulsetPropAnnotations []string `json:"statefulset_propagate_annotations,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PostgresPodResourcesDefaults defines the spec of default resources
|
// PostgresPodResourcesDefaults defines the spec of default resources
|
||||||
|
|
@ -205,6 +206,7 @@ type OperatorConfigurationData struct {
|
||||||
Scalyr ScalyrConfiguration `json:"scalyr"`
|
Scalyr ScalyrConfiguration `json:"scalyr"`
|
||||||
LogicalBackup OperatorLogicalBackupConfiguration `json:"logical_backup"`
|
LogicalBackup OperatorLogicalBackupConfiguration `json:"logical_backup"`
|
||||||
ConnectionPooler ConnectionPoolerConfiguration `json:"connection_pooler"`
|
ConnectionPooler ConnectionPoolerConfiguration `json:"connection_pooler"`
|
||||||
|
StatefulsetPropAnnotations []string `json:"statefulset_propagate_annotations,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//Duration shortens this frequently used name
|
//Duration shortens this frequently used name
|
||||||
|
|
|
||||||
|
|
@ -1148,12 +1148,26 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
|
||||||
return nil, fmt.Errorf("could not set the pod management policy to the unknown value: %v", c.OpConfig.PodManagementPolicy)
|
return nil, fmt.Errorf("could not set the pod management policy to the unknown value: %v", c.OpConfig.PodManagementPolicy)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
annotations = make(map[string]string)
|
||||||
|
|
||||||
|
ToPropagateAnnotations := c.OpConfig.StatefulsetPropAnnotations
|
||||||
|
if ToPropagateAnnotations != nil {
|
||||||
|
PgCRDAnnotations := c.Postgresql.ObjectMeta.GetAnnotations()
|
||||||
|
for _, anno := range ToPropagateAnnotations {
|
||||||
|
for k, v := range PgCRDAnnotations {
|
||||||
|
if k == anno {
|
||||||
|
annotations[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
statefulSet := &appsv1.StatefulSet{
|
statefulSet := &appsv1.StatefulSet{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: c.statefulSetName(),
|
Name: c.statefulSetName(),
|
||||||
Namespace: c.Namespace,
|
Namespace: c.Namespace,
|
||||||
Labels: c.labelsSet(true),
|
Labels: c.labelsSet(true),
|
||||||
Annotations: map[string]string{rollingUpdateStatefulsetAnnotationKey: "false"},
|
Annotations: annotations,
|
||||||
},
|
},
|
||||||
Spec: appsv1.StatefulSetSpec{
|
Spec: appsv1.StatefulSetSpec{
|
||||||
Replicas: &numberOfInstances,
|
Replicas: &numberOfInstances,
|
||||||
|
|
@ -1531,6 +1545,7 @@ func (c *Cluster) generateService(role PostgresRole, spec *acidv1.PostgresSpec)
|
||||||
},
|
},
|
||||||
Spec: serviceSpec,
|
Spec: serviceSpec,
|
||||||
}
|
}
|
||||||
|
c.logger.Warningln("Rafia get service annotations", service.GetObjectMeta)
|
||||||
|
|
||||||
return service
|
return service
|
||||||
}
|
}
|
||||||
|
|
@ -1803,7 +1818,7 @@ func (c *Cluster) generateLogicalBackupJob() (*batchv1beta1.CronJob, error) {
|
||||||
c.OpConfig.AdditionalSecretMount,
|
c.OpConfig.AdditionalSecretMount,
|
||||||
c.OpConfig.AdditionalSecretMountPath,
|
c.OpConfig.AdditionalSecretMountPath,
|
||||||
[]acidv1.AdditionalVolume{}); err != nil {
|
[]acidv1.AdditionalVolume{}); err != nil {
|
||||||
return nil, fmt.Errorf("could not generate pod template for logical backup pod: %v", err)
|
return nil, fmt.Errorf("could not generate pod template for logical backup pod: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// overwrite specific params of logical backups pods
|
// overwrite specific params of logical backups pods
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,8 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur
|
||||||
result.ShmVolume = fromCRD.ShmVolume
|
result.ShmVolume = fromCRD.ShmVolume
|
||||||
result.Sidecars = fromCRD.Sidecars
|
result.Sidecars = fromCRD.Sidecars
|
||||||
|
|
||||||
|
result.StatefulsetPropAnnotations = fromCRD.StatefulsetPropAnnotations
|
||||||
|
|
||||||
// user config
|
// user config
|
||||||
result.SuperUsername = fromCRD.PostgresUsersConfiguration.SuperUsername
|
result.SuperUsername = fromCRD.PostgresUsersConfiguration.SuperUsername
|
||||||
result.ReplicationUsername = fromCRD.PostgresUsersConfiguration.ReplicationUsername
|
result.ReplicationUsername = fromCRD.PostgresUsersConfiguration.ReplicationUsername
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,7 @@ type Config struct {
|
||||||
EnableReplicaLoadBalancer bool `name:"enable_replica_load_balancer" default:"false"`
|
EnableReplicaLoadBalancer bool `name:"enable_replica_load_balancer" default:"false"`
|
||||||
CustomServiceAnnotations map[string]string `name:"custom_service_annotations"`
|
CustomServiceAnnotations map[string]string `name:"custom_service_annotations"`
|
||||||
CustomPodAnnotations map[string]string `name:"custom_pod_annotations"`
|
CustomPodAnnotations map[string]string `name:"custom_pod_annotations"`
|
||||||
|
StatefulsetPropAnnotations []string `name:"statefulset_propagate_annotations"`
|
||||||
EnablePodAntiAffinity bool `name:"enable_pod_antiaffinity" default:"false"`
|
EnablePodAntiAffinity bool `name:"enable_pod_antiaffinity" default:"false"`
|
||||||
PodAntiAffinityTopologyKey string `name:"pod_antiaffinity_topology_key" default:"kubernetes.io/hostname"`
|
PodAntiAffinityTopologyKey string `name:"pod_antiaffinity_topology_key" default:"kubernetes.io/hostname"`
|
||||||
// deprecated and kept for backward compatibility
|
// deprecated and kept for backward compatibility
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue