Initial commit
This commit is contained in:
		
							parent
							
								
									5014eebfb2
								
							
						
					
					
						commit
						5373b085d8
					
				|  | @ -21,48 +21,48 @@ const ( | |||
| 
 | ||||
| // PostgresCRDResourceColumns definition of AdditionalPrinterColumns for postgresql CRD
 | ||||
| var PostgresCRDResourceColumns = []apiextv1beta1.CustomResourceColumnDefinition{ | ||||
| 	apiextv1beta1.CustomResourceColumnDefinition{ | ||||
| 	{ | ||||
| 		Name:        "Team", | ||||
| 		Type:        "string", | ||||
| 		Description: "Team responsible for Postgres cluster", | ||||
| 		JSONPath:    ".spec.teamId", | ||||
| 	}, | ||||
| 	apiextv1beta1.CustomResourceColumnDefinition{ | ||||
| 	{ | ||||
| 		Name:        "Version", | ||||
| 		Type:        "string", | ||||
| 		Description: "PostgreSQL version", | ||||
| 		JSONPath:    ".spec.postgresql.version", | ||||
| 	}, | ||||
| 	apiextv1beta1.CustomResourceColumnDefinition{ | ||||
| 	{ | ||||
| 		Name:        "Pods", | ||||
| 		Type:        "integer", | ||||
| 		Description: "Number of Pods per Postgres cluster", | ||||
| 		JSONPath:    ".spec.numberOfInstances", | ||||
| 	}, | ||||
| 	apiextv1beta1.CustomResourceColumnDefinition{ | ||||
| 	{ | ||||
| 		Name:        "Volume", | ||||
| 		Type:        "string", | ||||
| 		Description: "Size of the bound volume", | ||||
| 		JSONPath:    ".spec.volume.size", | ||||
| 	}, | ||||
| 	apiextv1beta1.CustomResourceColumnDefinition{ | ||||
| 	{ | ||||
| 		Name:        "CPU-Request", | ||||
| 		Type:        "string", | ||||
| 		Description: "Requested CPU for Postgres containers", | ||||
| 		JSONPath:    ".spec.resources.requests.cpu", | ||||
| 	}, | ||||
| 	apiextv1beta1.CustomResourceColumnDefinition{ | ||||
| 	{ | ||||
| 		Name:        "Memory-Request", | ||||
| 		Type:        "string", | ||||
| 		Description: "Requested memory for Postgres containers", | ||||
| 		JSONPath:    ".spec.resources.requests.memory", | ||||
| 	}, | ||||
| 	apiextv1beta1.CustomResourceColumnDefinition{ | ||||
| 	{ | ||||
| 		Name:     "Age", | ||||
| 		Type:     "date", | ||||
| 		JSONPath: ".metadata.creationTimestamp", | ||||
| 	}, | ||||
| 	apiextv1beta1.CustomResourceColumnDefinition{ | ||||
| 	{ | ||||
| 		Name:        "Status", | ||||
| 		Type:        "string", | ||||
| 		Description: "Current sync status of postgresql resource", | ||||
|  | @ -72,31 +72,31 @@ var PostgresCRDResourceColumns = []apiextv1beta1.CustomResourceColumnDefinition{ | |||
| 
 | ||||
| // OperatorConfigCRDResourceColumns definition of AdditionalPrinterColumns for OperatorConfiguration CRD
 | ||||
| var OperatorConfigCRDResourceColumns = []apiextv1beta1.CustomResourceColumnDefinition{ | ||||
| 	apiextv1beta1.CustomResourceColumnDefinition{ | ||||
| 	{ | ||||
| 		Name:        "Image", | ||||
| 		Type:        "string", | ||||
| 		Description: "Spilo image to be used for Pods", | ||||
| 		JSONPath:    ".configuration.docker_image", | ||||
| 	}, | ||||
| 	apiextv1beta1.CustomResourceColumnDefinition{ | ||||
| 	{ | ||||
| 		Name:        "Cluster-Label", | ||||
| 		Type:        "string", | ||||
| 		Description: "Label for K8s resources created by operator", | ||||
| 		JSONPath:    ".configuration.kubernetes.cluster_name_label", | ||||
| 	}, | ||||
| 	apiextv1beta1.CustomResourceColumnDefinition{ | ||||
| 	{ | ||||
| 		Name:        "Service-Account", | ||||
| 		Type:        "string", | ||||
| 		Description: "Name of service account to be used", | ||||
| 		JSONPath:    ".configuration.kubernetes.pod_service_account_name", | ||||
| 	}, | ||||
| 	apiextv1beta1.CustomResourceColumnDefinition{ | ||||
| 	{ | ||||
| 		Name:        "Min-Instances", | ||||
| 		Type:        "integer", | ||||
| 		Description: "Minimum number of instances per Postgres cluster", | ||||
| 		JSONPath:    ".configuration.min_instances", | ||||
| 	}, | ||||
| 	apiextv1beta1.CustomResourceColumnDefinition{ | ||||
| 	{ | ||||
| 		Name:     "Age", | ||||
| 		Type:     "date", | ||||
| 		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": { | ||||
| 								Type: "boolean", | ||||
| 							}, | ||||
|  |  | |||
|  | @ -72,6 +72,7 @@ type KubernetesMetaConfiguration struct { | |||
| 	EnablePodAntiAffinity      bool                `json:"enable_pod_antiaffinity,omitempty"` | ||||
| 	PodAntiAffinityTopologyKey string              `json:"pod_antiaffinity_topology_key,omitempty"` | ||||
| 	PodManagementPolicy        string              `json:"pod_management_policy,omitempty"` | ||||
| 	StatefulsetPropAnnotations []string            `json:"statefulset_propagate_annotations,omitempty"` | ||||
| } | ||||
| 
 | ||||
| // PostgresPodResourcesDefaults defines the spec of default resources
 | ||||
|  | @ -205,6 +206,7 @@ type OperatorConfigurationData struct { | |||
| 	Scalyr                     ScalyrConfiguration                `json:"scalyr"` | ||||
| 	LogicalBackup              OperatorLogicalBackupConfiguration `json:"logical_backup"` | ||||
| 	ConnectionPooler           ConnectionPoolerConfiguration      `json:"connection_pooler"` | ||||
| 	StatefulsetPropAnnotations []string                           `json:"statefulset_propagate_annotations,omitempty"` | ||||
| } | ||||
| 
 | ||||
| //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) | ||||
| 	} | ||||
| 
 | ||||
| 	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{ | ||||
| 		ObjectMeta: metav1.ObjectMeta{ | ||||
| 			Name:        c.statefulSetName(), | ||||
| 			Namespace:   c.Namespace, | ||||
| 			Labels:      c.labelsSet(true), | ||||
| 			Annotations: map[string]string{rollingUpdateStatefulsetAnnotationKey: "false"}, | ||||
| 			Annotations: annotations, | ||||
| 		}, | ||||
| 		Spec: appsv1.StatefulSetSpec{ | ||||
| 			Replicas:             &numberOfInstances, | ||||
|  | @ -1531,6 +1545,7 @@ func (c *Cluster) generateService(role PostgresRole, spec *acidv1.PostgresSpec) | |||
| 		}, | ||||
| 		Spec: serviceSpec, | ||||
| 	} | ||||
| 	c.logger.Warningln("Rafia get service annotations", service.GetObjectMeta) | ||||
| 
 | ||||
| 	return service | ||||
| } | ||||
|  | @ -1803,7 +1818,7 @@ func (c *Cluster) generateLogicalBackupJob() (*batchv1beta1.CronJob, error) { | |||
| 		c.OpConfig.AdditionalSecretMount, | ||||
| 		c.OpConfig.AdditionalSecretMountPath, | ||||
| 		[]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
 | ||||
|  |  | |||
|  | @ -46,6 +46,8 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur | |||
| 	result.ShmVolume = fromCRD.ShmVolume | ||||
| 	result.Sidecars = fromCRD.Sidecars | ||||
| 
 | ||||
| 	result.StatefulsetPropAnnotations = fromCRD.StatefulsetPropAnnotations | ||||
| 
 | ||||
| 	// user config
 | ||||
| 	result.SuperUsername = fromCRD.PostgresUsersConfiguration.SuperUsername | ||||
| 	result.ReplicationUsername = fromCRD.PostgresUsersConfiguration.ReplicationUsername | ||||
|  |  | |||
|  | @ -134,6 +134,7 @@ type Config struct { | |||
| 	EnableReplicaLoadBalancer              bool              `name:"enable_replica_load_balancer" default:"false"` | ||||
| 	CustomServiceAnnotations               map[string]string `name:"custom_service_annotations"` | ||||
| 	CustomPodAnnotations                   map[string]string `name:"custom_pod_annotations"` | ||||
| 	StatefulsetPropAnnotations             []string          `name:"statefulset_propagate_annotations"` | ||||
| 	EnablePodAntiAffinity                  bool              `name:"enable_pod_antiaffinity" default:"false"` | ||||
| 	PodAntiAffinityTopologyKey             string            `name:"pod_antiaffinity_topology_key" default:"kubernetes.io/hostname"` | ||||
| 	// deprecated and kept for backward compatibility
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue