inherited_labels and inherited_annotations not passed to PVC (#1784)
* inherited_labels and inherited_annotations not passed to PVC * Fix developer.md related to the local operator deployment
This commit is contained in:
parent
fb8a6c7a68
commit
da83982313
|
|
@ -72,22 +72,32 @@ make docker
|
||||||
|
|
||||||
# kind
|
# kind
|
||||||
make docker
|
make docker
|
||||||
kind load docker-image <image> --name <kind-cluster-name>
|
kind load docker-image registry.opensource.zalan.do/acid/postgres-operator:${TAG} --name <kind-cluster-name>
|
||||||
```
|
```
|
||||||
|
|
||||||
Then create a new Postgres Operator deployment. You can reuse the provided
|
Then create a new Postgres Operator deployment.
|
||||||
manifest but replace the version and tag. Don't forget to also apply
|
|
||||||
|
### Deploying manually with manifests and kubectl
|
||||||
|
|
||||||
|
You can reuse the provided manifest but replace the version and tag. Don't forget to also apply
|
||||||
configuration and RBAC manifests first, e.g.:
|
configuration and RBAC manifests first, e.g.:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl create -f manifests/configmap.yaml
|
kubectl create -f manifests/configmap.yaml
|
||||||
kubectl create -f manifests/operator-service-account-rbac.yaml
|
kubectl create -f manifests/operator-service-account-rbac.yaml
|
||||||
sed -e "s/\(image\:.*\:\).*$/\1$TAG/" manifests/postgres-operator.yaml | kubectl create -f -
|
sed -e "s/\(image\:.*\:\).*$/\1$TAG/" -e "s/\(imagePullPolicy\:\).*$/\1 Never/" manifests/postgres-operator.yaml | kubectl create -f -
|
||||||
|
|
||||||
# check if the operator is coming up
|
# check if the operator is coming up
|
||||||
kubectl get pod -l name=postgres-operator
|
kubectl get pod -l name=postgres-operator
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Deploying with Helm chart
|
||||||
|
|
||||||
|
Yoy can reuse the provided Helm chart to deploy local operator build with the following command:
|
||||||
|
```bash
|
||||||
|
helm install postgres-operator ./charts/postgres-operator --namespace zalando-operator --set image.tag=${TAG} --set image.pullPolicy=Never
|
||||||
|
```
|
||||||
|
|
||||||
## Code generation
|
## Code generation
|
||||||
|
|
||||||
The operator employs K8s-provided code generation to obtain deep copy methods
|
The operator employs K8s-provided code generation to obtain deep copy methods
|
||||||
|
|
|
||||||
|
|
@ -1291,7 +1291,7 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
|
||||||
return nil, fmt.Errorf("could not generate pod template: %v", err)
|
return nil, fmt.Errorf("could not generate pod template: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if volumeClaimTemplate, err = generatePersistentVolumeClaimTemplate(spec.Volume.Size,
|
if volumeClaimTemplate, err = c.generatePersistentVolumeClaimTemplate(spec.Volume.Size,
|
||||||
spec.Volume.StorageClass, spec.Volume.Selector); err != nil {
|
spec.Volume.StorageClass, spec.Volume.Selector); err != nil {
|
||||||
return nil, fmt.Errorf("could not generate volume claim template: %v", err)
|
return nil, fmt.Errorf("could not generate volume claim template: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -1540,21 +1540,12 @@ func (c *Cluster) addAdditionalVolumes(podSpec *v1.PodSpec,
|
||||||
podSpec.Volumes = volumes
|
podSpec.Volumes = volumes
|
||||||
}
|
}
|
||||||
|
|
||||||
func generatePersistentVolumeClaimTemplate(volumeSize, volumeStorageClass string,
|
func (c *Cluster) generatePersistentVolumeClaimTemplate(volumeSize, volumeStorageClass string,
|
||||||
volumeSelector *metav1.LabelSelector) (*v1.PersistentVolumeClaim, error) {
|
volumeSelector *metav1.LabelSelector) (*v1.PersistentVolumeClaim, error) {
|
||||||
|
|
||||||
var storageClassName *string
|
var storageClassName *string
|
||||||
|
|
||||||
metadata := metav1.ObjectMeta{
|
|
||||||
Name: constants.DataVolumeName,
|
|
||||||
}
|
|
||||||
if volumeStorageClass != "" {
|
if volumeStorageClass != "" {
|
||||||
// TODO: remove the old annotation, switching completely to the StorageClassName field.
|
|
||||||
metadata.Annotations = map[string]string{"volume.beta.kubernetes.io/storage-class": volumeStorageClass}
|
|
||||||
storageClassName = &volumeStorageClass
|
storageClassName = &volumeStorageClass
|
||||||
} else {
|
|
||||||
metadata.Annotations = map[string]string{"volume.alpha.kubernetes.io/storage-class": "default"}
|
|
||||||
storageClassName = nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
quantity, err := resource.ParseQuantity(volumeSize)
|
quantity, err := resource.ParseQuantity(volumeSize)
|
||||||
|
|
@ -1564,7 +1555,11 @@ func generatePersistentVolumeClaimTemplate(volumeSize, volumeStorageClass string
|
||||||
|
|
||||||
volumeMode := v1.PersistentVolumeFilesystem
|
volumeMode := v1.PersistentVolumeFilesystem
|
||||||
volumeClaim := &v1.PersistentVolumeClaim{
|
volumeClaim := &v1.PersistentVolumeClaim{
|
||||||
ObjectMeta: metadata,
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: constants.DataVolumeName,
|
||||||
|
Annotations: c.annotationsSet(nil),
|
||||||
|
Labels: c.labelsSet(true),
|
||||||
|
},
|
||||||
Spec: v1.PersistentVolumeClaimSpec{
|
Spec: v1.PersistentVolumeClaimSpec{
|
||||||
AccessModes: []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce},
|
AccessModes: []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce},
|
||||||
Resources: v1.ResourceRequirements{
|
Resources: v1.ResourceRequirements{
|
||||||
|
|
|
||||||
|
|
@ -98,8 +98,8 @@ func TestInheritedAnnotations(t *testing.T) {
|
||||||
t.Errorf("%s: pod template %v not inherited annotations %#v, got %#v", testName, sts.ObjectMeta.Name, inheritedAnnotations, sts.ObjectMeta.Annotations)
|
t.Errorf("%s: pod template %v not inherited annotations %#v, got %#v", testName, sts.ObjectMeta.Name, inheritedAnnotations, sts.ObjectMeta.Annotations)
|
||||||
}
|
}
|
||||||
// pvc template
|
// pvc template
|
||||||
if util.MapContains(sts.Spec.VolumeClaimTemplates[0].Annotations, inheritedAnnotations) {
|
if !(util.MapContains(sts.Spec.VolumeClaimTemplates[0].Annotations, inheritedAnnotations)) {
|
||||||
t.Errorf("%s: PVC template %v not expected to have inherited annotations %#v, got %#v", testName, sts.ObjectMeta.Name, inheritedAnnotations, sts.ObjectMeta.Annotations)
|
t.Errorf("%s: PVC template %v not inherited annotations %#v, got %#v", testName, sts.ObjectMeta.Name, inheritedAnnotations, sts.ObjectMeta.Annotations)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -505,8 +505,6 @@ func (c *Controller) postgresqlAdd(obj interface{}) {
|
||||||
// We will not get multiple Add events for the same cluster
|
// We will not get multiple Add events for the same cluster
|
||||||
c.queueClusterEvent(nil, pg, EventAdd)
|
c.queueClusterEvent(nil, pg, EventAdd)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Controller) postgresqlUpdate(prev, cur interface{}) {
|
func (c *Controller) postgresqlUpdate(prev, cur interface{}) {
|
||||||
|
|
@ -521,8 +519,6 @@ func (c *Controller) postgresqlUpdate(prev, cur interface{}) {
|
||||||
}
|
}
|
||||||
c.queueClusterEvent(pgOld, pgNew, EventUpdate)
|
c.queueClusterEvent(pgOld, pgNew, EventUpdate)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Controller) postgresqlDelete(obj interface{}) {
|
func (c *Controller) postgresqlDelete(obj interface{}) {
|
||||||
|
|
@ -530,8 +526,6 @@ func (c *Controller) postgresqlDelete(obj interface{}) {
|
||||||
if pg != nil {
|
if pg != nil {
|
||||||
c.queueClusterEvent(pg, nil, EventDelete)
|
c.queueClusterEvent(pg, nil, EventDelete)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Controller) postgresqlCheck(obj interface{}) *acidv1.Postgresql {
|
func (c *Controller) postgresqlCheck(obj interface{}) *acidv1.Postgresql {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue