Repository: pravega/zookeeper-operator (go)

Issue:
annotations does not take effect
```
apiVersion: zookeeper.pravega.io/v1beta1
kind: ZookeeperCluster
metadata:
  name: zookeepercluster
spec:
  # Add fields here
  replicas: 3
  pod:
    # 发现注解字段不生效
    annotations: 
      sidecar.istio.io/inject: "false"


when i check pod:
kubectl get pod zookeepercluster-0 -o yaml
apiVersion: v1
kind: Pod
metadata:
  annotations:
    sidecar.istio.io/status: '{"version":"761ebc5a63976754715f22fcf548f05270fb4b8db07324894aebdb31fa81d960","initContainers":null,"containers":["istio-proxy"],"volumes":["istio-envoy","istio-certs"],"imagePullSecrets":null}'
    tke.cloud.tencent.com/networks-status: |-
      [{
          "name": "tke-bridge",
          "ips": [
              "172.31.11.142"
          ],
          "default": true,
          "dns": {}
      }]


when i check statefulsets:
kubectl get statefulsets.apps  zookeepercluster  -o yaml        
apiVersion: apps/v1
kind: StatefulSet
metadata:
  creationTimestamp: "2020-02-12T11:40:33Z"
  generation: 1
  labels:
    app: zookeepercluster
    release: zookeepercluster
  name: zookeepercluster
  namespace: default
  ownerReferences:
  - apiVersion: zookeeper.pravega.io/v1beta1
    blockOwnerDeletion: true
    controller: true
    kind: ZookeeperCluster
    name: zookeepercluster
    uid: 7acda871-4d8c-11ea-a8df-525400fe84b0
  resourceVersion: "49757594"
  selfLink: /apis/apps/v1/namespaces/default/statefulsets/zookeepercluster
  uid: 7ad28a02-4d8c-11ea-b662-525400122c98
```

I can not find annotations with sidecar.istio.io/inject: false

Pull request:
Issue 125: Pass PodPolicy annotations from ZookeeperClusterSpec to StatefulSet Pod Templates.
Signed-off-by: Oliver Maskery <oliver@wellplayed.games>

### Change log description

Pass annotations specified in ZookeeperCluster's Pod Policy to the StatefulSet's pod template.

### Purpose of the change

Closes #125 

### What the code does

The ZookeeperClusterSpec already has a PodPolicy which contains an Annotations `map[string]string`, this PR simply passes it through into the constructed StatefulSet's pod template.

### How to verify it

**Given** a ZookeeperCluster resource has annotations in its Spec.Pod.Annotations
**And** this resource is applied to a Kubernetes cluster
**When** the Zookeeper Operator reconciles the ZookeeperCluster resource
**Then** a StatefulSet is created
**And** the StatefulSet's Pod Template has the requested annotations
**And** the Pods created by the StatefulSet have the requested annotations

Patch:
diff --git a/pkg/zk/generators.go b/pkg/zk/generators.go
index e6d7b17..f753383 100644
--- a/pkg/zk/generators.go
+++ b/pkg/zk/generators.go
@@ -95,6 +95,7 @@ func MakeStatefulSet(z *v1beta1.ZookeeperCluster) *appsv1.StatefulSet {
 							"kind": "ZookeeperMember",
 						},
 					),
+					Annotations: z.Spec.Pod.Annotations,
 				},
 				Spec: makeZkPodSpec(z, extraVolumes),
 			},


Test patch:
diff --git a/pkg/zk/generators_test.go b/pkg/zk/generators_test.go
index 379b37f..d2fb1c6 100644
--- a/pkg/zk/generators_test.go
+++ b/pkg/zk/generators_test.go
@@ -196,6 +196,33 @@ var _ = Describe("Generators Spec", func() {
 					"exampleValue"))
 			})
 		})
+
+		Context("with pod policy annotations", func() {
+
+			BeforeEach(func() {
+				z := &v1beta1.ZookeeperCluster{
+					ObjectMeta: metav1.ObjectMeta{
+						Name:      "example",
+						Namespace: "default",
+					},
+					Spec: v1beta1.ZookeeperClusterSpec{
+						Pod: v1beta1.PodPolicy{
+							Annotations: map[string]string{
+								"example-annotation": "example-value",
+							},
+						},
+					},
+				}
+				z.WithDefaults()
+				sts = zk.MakeStatefulSet(z)
+			})
+
+			It("should have custom labels set on pods", func() {
+				Ω(sts.Spec.Template.ObjectMeta.Annotations).To(HaveKeyWithValue(
+					"example-annotation",
+					"example-value"))
+			})
+		})
 	})
 
 	Context("#MakeStatefulSet with Ephemeral storage", func() {