From c29d475794226ce38de021d72430ccde75a38d2a Mon Sep 17 00:00:00 2001 From: Alfred Landrum Date: Thu, 27 Oct 2022 11:22:09 -0700 Subject: [PATCH 01/22] use socat instead of nc (#476) Signed-off-by: Alfred Landrum Signed-off-by: Alfred Landrum Co-authored-by: anishakj <43978302+anishakj@users.noreply.github.com> --- docker/Dockerfile | 2 +- docker/bin/zookeeperLive.sh | 2 +- docker/bin/zookeeperMetrics.sh | 2 +- docker/bin/zookeeperReady.sh | 2 +- docker/bin/zookeeperTeardown.sh | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index baaf42b3c..1ef1fbdc7 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -21,4 +21,4 @@ RUN chmod +x /usr/local/bin/* COPY --from=0 /zu/build/libs/zu.jar /opt/libs/ RUN apt-get -q update && \ - apt-get install -y dnsutils curl procps + apt-get install -y dnsutils curl procps socat diff --git a/docker/bin/zookeeperLive.sh b/docker/bin/zookeeperLive.sh index 9291c0e5f..9e6d6e02f 100755 --- a/docker/bin/zookeeperLive.sh +++ b/docker/bin/zookeeperLive.sh @@ -13,7 +13,7 @@ set -ex source /conf/env.sh -OK=$(echo ruok | nc 127.0.0.1 $CLIENT_PORT) +OK=$(echo ruok | socat stdio tcp:localhost:$CLIENT_PORT) # Check to see if zookeeper service answers if [[ "$OK" == "imok" ]]; then diff --git a/docker/bin/zookeeperMetrics.sh b/docker/bin/zookeeperMetrics.sh index a5225ba83..bd0c875e3 100755 --- a/docker/bin/zookeeperMetrics.sh +++ b/docker/bin/zookeeperMetrics.sh @@ -13,4 +13,4 @@ set -ex source /conf/env.sh -echo mntr | nc localhost $CLIENT_PORT >& 1 +echo mntr | socat stdio tcp:localhost:$CLIENT_PORT >& 1 diff --git a/docker/bin/zookeeperReady.sh b/docker/bin/zookeeperReady.sh index e31469e6a..e9583e5b6 100755 --- a/docker/bin/zookeeperReady.sh +++ b/docker/bin/zookeeperReady.sh @@ -20,7 +20,7 @@ MYID_FILE=$DATA_DIR/myid LOG4J_CONF=/conf/log4j-quiet.properties STATIC_CONFIG=/data/conf/zoo.cfg -OK=$(echo ruok | nc 127.0.0.1 $CLIENT_PORT) +OK=$(echo ruok | socat stdio tcp:localhost:$CLIENT_PORT) # Check to see if zookeeper service answers if [[ "$OK" == "imok" ]]; then diff --git a/docker/bin/zookeeperTeardown.sh b/docker/bin/zookeeperTeardown.sh index 85af30fbb..da361b8db 100755 --- a/docker/bin/zookeeperTeardown.sh +++ b/docker/bin/zookeeperTeardown.sh @@ -21,7 +21,7 @@ LOG4J_CONF=/conf/log4j-quiet.properties # Wait for client connections to drain. Kubernetes will wait until the confiugred # "terminationGracePeriodSeconds" before focibly killing the container for (( i = 0; i < 6; i++ )); do - CONN_COUNT=`echo cons | nc localhost 2181 | grep -v "^$" |grep -v "/127.0.0.1:" | wc -l` + CONN_COUNT=`echo cons | socat stdio tcp:localhost:$CLIENT_PORT | grep -v "^$" |grep -v "/127.0.0.1:" | wc -l` if [[ "$CONN_COUNT" -gt 0 ]]; then echo "$CONN_COUNT non-local connections still connected." sleep 5 From adcf3bf0adaf1aef2c3f0fb89aff8c5bde1e0021 Mon Sep 17 00:00:00 2001 From: Casey Buto Date: Wed, 11 Jan 2023 08:29:44 -0500 Subject: [PATCH 02/22] feat: Replace deprecated policy/v1beta1 PDB API (#523) Signed-off-by: Casey Buto Signed-off-by: Casey Buto --- controllers/zookeepercluster_controller.go | 14 ++++++++------ controllers/zookeepercluster_controller_test.go | 11 ++++++----- pkg/zk/generators.go | 13 +++++++------ pkg/zk/generators_test.go | 12 ++++++------ 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/controllers/zookeepercluster_controller.go b/controllers/zookeepercluster_controller.go index 934f4050c..eb6241359 100644 --- a/controllers/zookeepercluster_controller.go +++ b/controllers/zookeepercluster_controller.go @@ -15,19 +15,19 @@ import ( "strconv" "time" + "k8s.io/client-go/kubernetes/scheme" + "sigs.k8s.io/controller-runtime/pkg/client/fake" + "sigs.k8s.io/controller-runtime/pkg/predicate" + "github.com/pravega/zookeeper-operator/pkg/controller/config" "github.com/pravega/zookeeper-operator/pkg/utils" "github.com/pravega/zookeeper-operator/pkg/yamlexporter" "github.com/pravega/zookeeper-operator/pkg/zk" - "k8s.io/client-go/kubernetes/scheme" - "sigs.k8s.io/controller-runtime/pkg/client/fake" - "sigs.k8s.io/controller-runtime/pkg/predicate" "github.com/go-logr/logr" - zookeeperv1beta1 "github.com/pravega/zookeeper-operator/api/v1beta1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" - policyv1beta1 "k8s.io/api/policy/v1beta1" + policyv1 "k8s.io/api/policy/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" @@ -38,6 +38,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + zookeeperv1beta1 "github.com/pravega/zookeeper-operator/api/v1beta1" ) // ReconcileTime is the delay between reconciliations @@ -467,7 +469,7 @@ func (r *ZookeeperClusterReconciler) reconcilePodDisruptionBudget(instance *zook if err = controllerutil.SetControllerReference(instance, pdb, r.Scheme); err != nil { return err } - foundPdb := &policyv1beta1.PodDisruptionBudget{} + foundPdb := &policyv1.PodDisruptionBudget{} err = r.Client.Get(context.TODO(), types.NamespacedName{ Name: pdb.Name, Namespace: pdb.Namespace, diff --git a/controllers/zookeepercluster_controller_test.go b/controllers/zookeepercluster_controller_test.go index fe530dbd7..712cccf1b 100644 --- a/controllers/zookeepercluster_controller_test.go +++ b/controllers/zookeepercluster_controller_test.go @@ -16,12 +16,9 @@ import ( "testing" "time" - "github.com/pravega/zookeeper-operator/api/v1beta1" - "github.com/pravega/zookeeper-operator/pkg/controller/config" - "github.com/pravega/zookeeper-operator/pkg/zk" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" - policyv1beta1 "k8s.io/api/policy/v1beta1" + policyv1 "k8s.io/api/policy/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/scheme" @@ -29,6 +26,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/reconcile" + "github.com/pravega/zookeeper-operator/api/v1beta1" + "github.com/pravega/zookeeper-operator/pkg/controller/config" + "github.com/pravega/zookeeper-operator/pkg/zk" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) @@ -185,7 +186,7 @@ var _ = Describe("ZookeeperCluster Controller", func() { }) It("should create a pdb", func() { - foundPdb := &policyv1beta1.PodDisruptionBudget{} + foundPdb := &policyv1.PodDisruptionBudget{} err = cl.Get(context.TODO(), req.NamespacedName, foundPdb) Ω(err).To(BeNil()) }) diff --git a/pkg/zk/generators.go b/pkg/zk/generators.go index 25da7f9a6..07720c1f6 100644 --- a/pkg/zk/generators.go +++ b/pkg/zk/generators.go @@ -16,12 +16,13 @@ import ( "strconv" "strings" - "github.com/pravega/zookeeper-operator/api/v1beta1" appsv1 "k8s.io/api/apps/v1" v1 "k8s.io/api/core/v1" - policyv1beta1 "k8s.io/api/policy/v1beta1" + policyv1 "k8s.io/api/policy/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + + "github.com/pravega/zookeeper-operator/api/v1beta1" ) const ( @@ -352,19 +353,19 @@ func makeService(name string, ports []v1.ServicePort, clusterIP bool, external b } // MakePodDisruptionBudget returns a pdb for the zookeeper cluster -func MakePodDisruptionBudget(z *v1beta1.ZookeeperCluster) *policyv1beta1.PodDisruptionBudget { +func MakePodDisruptionBudget(z *v1beta1.ZookeeperCluster) *policyv1.PodDisruptionBudget { pdbCount := intstr.FromInt(int(z.Spec.MaxUnavailableReplicas)) - return &policyv1beta1.PodDisruptionBudget{ + return &policyv1.PodDisruptionBudget{ TypeMeta: metav1.TypeMeta{ Kind: "PodDisruptionBudget", - APIVersion: "policy/v1beta1", + APIVersion: "policy/v1", }, ObjectMeta: metav1.ObjectMeta{ Name: z.GetName(), Namespace: z.Namespace, Labels: z.Spec.Labels, }, - Spec: policyv1beta1.PodDisruptionBudgetSpec{ + Spec: policyv1.PodDisruptionBudgetSpec{ MaxUnavailable: &pdbCount, Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{ diff --git a/pkg/zk/generators_test.go b/pkg/zk/generators_test.go index 7fdda6aba..a077bb9aa 100644 --- a/pkg/zk/generators_test.go +++ b/pkg/zk/generators_test.go @@ -12,18 +12,18 @@ package zk_test import ( "fmt" + "strings" log "github.com/sirupsen/logrus" + policyv1 "k8s.io/api/policy/v1" - "strings" + appsv1 "k8s.io/api/apps/v1" + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/pravega/zookeeper-operator/api/v1beta1" "github.com/pravega/zookeeper-operator/pkg/utils" "github.com/pravega/zookeeper-operator/pkg/zk" - appsv1 "k8s.io/api/apps/v1" - v1 "k8s.io/api/core/v1" - policyv1beta1 "k8s.io/api/policy/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -560,7 +560,7 @@ var _ = Describe("Generators Spec", func() { }) Context("#MakePodDisruptionBudget", func() { - var pdb *policyv1beta1.PodDisruptionBudget + var pdb *policyv1.PodDisruptionBudget var domainName string var zkClusterName string From 8076745b374a34bd1f690b8ca16e7fd7532bc73a Mon Sep 17 00:00:00 2001 From: Nick Huanca <1903525+endzyme@users.noreply.github.com> Date: Thu, 12 Jan 2023 02:08:55 -0700 Subject: [PATCH 03/22] Add topologySpreadConstraints to PodSpec (#522) * Add topologySpreadConstraints Add `topologySpreadConstraints` support to pod specification. Signed-off-by: Nick Huanca <1903525+endzyme@users.noreply.github.com> * Add crd changes to helm chart for ZK instance Signed-off-by: Nick Huanca <1903525+endzyme@users.noreply.github.com> * Test to make sure we have topospreadconst Signed-off-by: Nick Huanca <1903525+endzyme@users.noreply.github.com> * Add coverage in deepcopy_test.go Signed-off-by: Nick Huanca <1903525+endzyme@users.noreply.github.com> * Add test for deepcopy Signed-off-by: Nick Huanca <1903525+endzyme@users.noreply.github.com> Signed-off-by: Nick Huanca <1903525+endzyme@users.noreply.github.com> --- api/v1beta1/deepcopy_test.go | 11 ++ api/v1beta1/zookeepercluster_types.go | 3 + api/v1beta1/zz_generated.deepcopy.go | 7 + ...eper.pravega.io_zookeeperclusters_crd.yaml | 138 ++++++++++++++++++ charts/zookeeper/templates/zookeeper.yaml | 4 + charts/zookeeper/values.yaml | 1 + ...ookeeper.pravega.io_zookeeperclusters.yaml | 138 ++++++++++++++++++ pkg/zk/generators.go | 7 +- pkg/zk/generators_test.go | 4 + 9 files changed, 310 insertions(+), 3 deletions(-) diff --git a/api/v1beta1/deepcopy_test.go b/api/v1beta1/deepcopy_test.go index 52edca265..5743a5af1 100644 --- a/api/v1beta1/deepcopy_test.go +++ b/api/v1beta1/deepcopy_test.go @@ -173,6 +173,9 @@ var _ = Describe("ZookeeperCluster DeepCopy", func() { It("value of Tol should be example", func() { Ω(z2.Spec.Pod.Tolerations[0].Key).To(Equal("tol")) }) + It("have empty topologySpreadConstraints", func() { + Ω(z2.Spec.Pod.TopologySpreadConstraints).To(HaveLen(0)) + }) It("checking status conditions", func() { Ω(z2.Status.Conditions[0].Reason).To(Equal(z1.Status.Conditions[0].Reason)) }) @@ -242,6 +245,14 @@ var _ = Describe("ZookeeperCluster DeepCopy", func() { podpolicy2 := podpolicy.DeepCopy() Ω(podpolicy2).To(BeNil()) }) + It("checking for deepcopy podpolicy.topologyspreadconstraints", func() { + t := v1.TopologySpreadConstraint{} + podpolicy := v1beta1.PodPolicy{ + TopologySpreadConstraints: []v1.TopologySpreadConstraint{t}, + } + podpolicy2 := podpolicy.DeepCopy() + Ω(podpolicy2.TopologySpreadConstraints).To(HaveLen(1)) + }) It("checking for nil zookeepercluster", func() { var zk *v1beta1.ZookeeperCluster zk2 := zk.DeepCopy() diff --git a/api/v1beta1/zookeepercluster_types.go b/api/v1beta1/zookeepercluster_types.go index 3f5da83b4..8985daba8 100644 --- a/api/v1beta1/zookeepercluster_types.go +++ b/api/v1beta1/zookeepercluster_types.go @@ -445,6 +445,9 @@ type PodPolicy struct { // The scheduling constraints on pods. Affinity *v1.Affinity `json:"affinity,omitempty"` + // TopologySpreadConstraints to apply to the pods + TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"` + // Resources is the resource requirements for the container. // This field cannot be updated once the cluster is created. Resources v1.ResourceRequirements `json:"resources,omitempty"` diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 409d989b1..e712f6cba 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -192,6 +192,13 @@ func (in *PodPolicy) DeepCopyInto(out *PodPolicy) { *out = new(v1.Affinity) (*in).DeepCopyInto(*out) } + if in.TopologySpreadConstraints != nil { + in, out := &in.TopologySpreadConstraints, &out.TopologySpreadConstraints + *out = make([]v1.TopologySpreadConstraint, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } in.Resources.DeepCopyInto(&out.Resources) if in.Tolerations != nil { in, out := &in.Tolerations, &out.Tolerations diff --git a/charts/zookeeper-operator/templates/zookeeper.pravega.io_zookeeperclusters_crd.yaml b/charts/zookeeper-operator/templates/zookeeper.pravega.io_zookeeperclusters_crd.yaml index 03555d8d9..c38f3a435 100644 --- a/charts/zookeeper-operator/templates/zookeeper.pravega.io_zookeeperclusters_crd.yaml +++ b/charts/zookeeper-operator/templates/zookeeper.pravega.io_zookeeperclusters_crd.yaml @@ -4133,6 +4133,144 @@ spec: type: string type: object type: array + topologySpreadConstraints: + description: TopologySpreadConstraints to apply to the pods + items: + description: TopologySpreadConstraint specifies how to spread + matching pods among the given topology. + properties: + labelSelector: + description: LabelSelector is used to find matching pods. + Pods that match this label selector are counted to determine + the number of pods in their corresponding topology domain. + properties: + matchExpressions: + description: matchExpressions is a list of label selector + requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector + that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: key is the label key that the selector + applies to. + type: string + operator: + description: operator represents a key's relationship + to a set of values. Valid operators are In, + NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. + If the operator is In or NotIn, the values array + must be non-empty. If the operator is Exists + or DoesNotExist, the values array must be empty. + This array is replaced during a strategic merge + patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. + A single {key,value} in the matchLabels map is equivalent + to an element of matchExpressions, whose key field + is "key", the operator is "In", and the values array + contains only "value". The requirements are ANDed. + type: object + type: object + maxSkew: + description: 'MaxSkew describes the degree to which pods + may be unevenly distributed. When `whenUnsatisfiable=DoNotSchedule`, + it is the maximum permitted difference between the number + of matching pods in the target topology and the global + minimum. The global minimum is the minimum number of matching + pods in an eligible domain or zero if the number of eligible + domains is less than MinDomains. For example, in a 3-zone + cluster, MaxSkew is set to 1, and pods with the same labelSelector + spread as 2/2/1: In this case, the global minimum is 1. + | zone1 | zone2 | zone3 | | P P | P P | P | - + if MaxSkew is 1, incoming pod can only be scheduled to + zone3 to become 2/2/2; scheduling it onto zone1(zone2) + would make the ActualSkew(3-1) on zone1(zone2) violate + MaxSkew(1). - if MaxSkew is 2, incoming pod can be scheduled + onto any zone. When `whenUnsatisfiable=ScheduleAnyway`, + it is used to give higher precedence to topologies that + satisfy it. It''s a required field. Default value is 1 + and 0 is not allowed.' + format: int32 + type: integer + minDomains: + description: "MinDomains indicates a minimum number of eligible + domains. When the number of eligible domains with matching + topology keys is less than minDomains, Pod Topology Spread + treats \"global minimum\" as 0, and then the calculation + of Skew is performed. And when the number of eligible + domains with matching topology keys equals or greater + than minDomains, this value has no effect on scheduling. + As a result, when the number of eligible domains is less + than minDomains, scheduler won't schedule more than maxSkew + Pods to those domains. If value is nil, the constraint + behaves as if MinDomains is equal to 1. Valid values are + integers greater than 0. When value is not nil, WhenUnsatisfiable + must be DoNotSchedule. \n For example, in a 3-zone cluster, + MaxSkew is set to 2, MinDomains is set to 5 and pods with + the same labelSelector spread as 2/2/2: | zone1 | zone2 + | zone3 | | P P | P P | P P | The number of domains + is less than 5(MinDomains), so \"global minimum\" is treated + as 0. In this situation, new pod with the same labelSelector + cannot be scheduled, because computed skew will be 3(3 + - 0) if new Pod is scheduled to any of the three zones, + it will violate MaxSkew. \n This is an alpha field and + requires enabling MinDomainsInPodTopologySpread feature + gate." + format: int32 + type: integer + topologyKey: + description: TopologyKey is the key of node labels. Nodes + that have a label with this key and identical values are + considered to be in the same topology. We consider each + as a "bucket", and try to put balanced number + of pods into each bucket. We define a domain as a particular + instance of a topology. Also, we define an eligible domain + as a domain whose nodes match the node selector. e.g. + If TopologyKey is "kubernetes.io/hostname", each Node + is a domain of that topology. And, if TopologyKey is "topology.kubernetes.io/zone", + each zone is a domain of that topology. It's a required + field. + type: string + whenUnsatisfiable: + description: 'WhenUnsatisfiable indicates how to deal with + a pod if it doesn''t satisfy the spread constraint. - + DoNotSchedule (default) tells the scheduler not to schedule + it. - ScheduleAnyway tells the scheduler to schedule the + pod in any location, but giving higher precedence to topologies + that would help reduce the skew. A constraint is considered + "Unsatisfiable" for an incoming pod if and only if every + possible node assignment for that pod would violate "MaxSkew" + on some topology. For example, in a 3-zone cluster, MaxSkew + is set to 1, and pods with the same labelSelector spread + as 3/1/1: | zone1 | zone2 | zone3 | | P P P | P | P | + If WhenUnsatisfiable is set to DoNotSchedule, incoming + pod can only be scheduled to zone2(zone3) to become 3/2/1(3/1/2) + as ActualSkew(2-1) on zone2(zone3) satisfies MaxSkew(1). + In other words, the cluster can still be imbalanced, but + scheduler won''t make it *more* imbalanced. It''s a required + field.' + type: string + required: + - maxSkew + - topologyKey + - whenUnsatisfiable + type: object + type: array type: object ports: items: diff --git a/charts/zookeeper/templates/zookeeper.yaml b/charts/zookeeper/templates/zookeeper.yaml index 6a877a8c1..902440e61 100644 --- a/charts/zookeeper/templates/zookeeper.yaml +++ b/charts/zookeeper/templates/zookeeper.yaml @@ -76,6 +76,10 @@ spec: {{- if .Values.pod.affinity }} affinity: {{ toYaml .Values.pod.affinity | indent 6 }} + {{- end }} + {{- if .Values.pod.topologySpreadConstraints }} + topologySpreadConstraints: +{{ toYaml .Values.pod.topologySpreadConstraints | indent 6 }} {{- end }} {{- if .Values.pod.resources }} resources: diff --git a/charts/zookeeper/values.yaml b/charts/zookeeper/values.yaml index 0209149a8..d7977ec75 100644 --- a/charts/zookeeper/values.yaml +++ b/charts/zookeeper/values.yaml @@ -36,6 +36,7 @@ pod: # labels: {} # nodeSelector: {} # affinity: {} + # topologySpreadConstraints: {} # resources: {} # tolerations: [] # env: [] diff --git a/config/crd/bases/zookeeper.pravega.io_zookeeperclusters.yaml b/config/crd/bases/zookeeper.pravega.io_zookeeperclusters.yaml index 46f114d39..af5084e8a 100644 --- a/config/crd/bases/zookeeper.pravega.io_zookeeperclusters.yaml +++ b/config/crd/bases/zookeeper.pravega.io_zookeeperclusters.yaml @@ -4132,6 +4132,144 @@ spec: type: string type: object type: array + topologySpreadConstraints: + description: TopologySpreadConstraints to apply to the pods + items: + description: TopologySpreadConstraint specifies how to spread + matching pods among the given topology. + properties: + labelSelector: + description: LabelSelector is used to find matching pods. + Pods that match this label selector are counted to determine + the number of pods in their corresponding topology domain. + properties: + matchExpressions: + description: matchExpressions is a list of label selector + requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector + that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: key is the label key that the selector + applies to. + type: string + operator: + description: operator represents a key's relationship + to a set of values. Valid operators are In, + NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. + If the operator is In or NotIn, the values array + must be non-empty. If the operator is Exists + or DoesNotExist, the values array must be empty. + This array is replaced during a strategic merge + patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. + A single {key,value} in the matchLabels map is equivalent + to an element of matchExpressions, whose key field + is "key", the operator is "In", and the values array + contains only "value". The requirements are ANDed. + type: object + type: object + maxSkew: + description: 'MaxSkew describes the degree to which pods + may be unevenly distributed. When `whenUnsatisfiable=DoNotSchedule`, + it is the maximum permitted difference between the number + of matching pods in the target topology and the global + minimum. The global minimum is the minimum number of matching + pods in an eligible domain or zero if the number of eligible + domains is less than MinDomains. For example, in a 3-zone + cluster, MaxSkew is set to 1, and pods with the same labelSelector + spread as 2/2/1: In this case, the global minimum is 1. + | zone1 | zone2 | zone3 | | P P | P P | P | - + if MaxSkew is 1, incoming pod can only be scheduled to + zone3 to become 2/2/2; scheduling it onto zone1(zone2) + would make the ActualSkew(3-1) on zone1(zone2) violate + MaxSkew(1). - if MaxSkew is 2, incoming pod can be scheduled + onto any zone. When `whenUnsatisfiable=ScheduleAnyway`, + it is used to give higher precedence to topologies that + satisfy it. It''s a required field. Default value is 1 + and 0 is not allowed.' + format: int32 + type: integer + minDomains: + description: "MinDomains indicates a minimum number of eligible + domains. When the number of eligible domains with matching + topology keys is less than minDomains, Pod Topology Spread + treats \"global minimum\" as 0, and then the calculation + of Skew is performed. And when the number of eligible + domains with matching topology keys equals or greater + than minDomains, this value has no effect on scheduling. + As a result, when the number of eligible domains is less + than minDomains, scheduler won't schedule more than maxSkew + Pods to those domains. If value is nil, the constraint + behaves as if MinDomains is equal to 1. Valid values are + integers greater than 0. When value is not nil, WhenUnsatisfiable + must be DoNotSchedule. \n For example, in a 3-zone cluster, + MaxSkew is set to 2, MinDomains is set to 5 and pods with + the same labelSelector spread as 2/2/2: | zone1 | zone2 + | zone3 | | P P | P P | P P | The number of domains + is less than 5(MinDomains), so \"global minimum\" is treated + as 0. In this situation, new pod with the same labelSelector + cannot be scheduled, because computed skew will be 3(3 + - 0) if new Pod is scheduled to any of the three zones, + it will violate MaxSkew. \n This is an alpha field and + requires enabling MinDomainsInPodTopologySpread feature + gate." + format: int32 + type: integer + topologyKey: + description: TopologyKey is the key of node labels. Nodes + that have a label with this key and identical values are + considered to be in the same topology. We consider each + as a "bucket", and try to put balanced number + of pods into each bucket. We define a domain as a particular + instance of a topology. Also, we define an eligible domain + as a domain whose nodes match the node selector. e.g. + If TopologyKey is "kubernetes.io/hostname", each Node + is a domain of that topology. And, if TopologyKey is "topology.kubernetes.io/zone", + each zone is a domain of that topology. It's a required + field. + type: string + whenUnsatisfiable: + description: 'WhenUnsatisfiable indicates how to deal with + a pod if it doesn''t satisfy the spread constraint. - + DoNotSchedule (default) tells the scheduler not to schedule + it. - ScheduleAnyway tells the scheduler to schedule the + pod in any location, but giving higher precedence to topologies + that would help reduce the skew. A constraint is considered + "Unsatisfiable" for an incoming pod if and only if every + possible node assignment for that pod would violate "MaxSkew" + on some topology. For example, in a 3-zone cluster, MaxSkew + is set to 1, and pods with the same labelSelector spread + as 3/1/1: | zone1 | zone2 | zone3 | | P P P | P | P | + If WhenUnsatisfiable is set to DoNotSchedule, incoming + pod can only be scheduled to zone2(zone3) to become 3/2/1(3/1/2) + as ActualSkew(2-1) on zone2(zone3) satisfies MaxSkew(1). + In other words, the cluster can still be imbalanced, but + scheduler won''t make it *more* imbalanced. It''s a required + field.' + type: string + required: + - maxSkew + - topologyKey + - whenUnsatisfiable + type: object + type: array type: object ports: items: diff --git a/pkg/zk/generators.go b/pkg/zk/generators.go index 07720c1f6..fddb48727 100644 --- a/pkg/zk/generators.go +++ b/pkg/zk/generators.go @@ -172,9 +172,10 @@ func makeZkPodSpec(z *v1beta1.ZookeeperCluster, volumes []v1.Volume) v1.PodSpec zkContainer.Env = append(zkContainer.Env, z.Spec.Pod.Env...) podSpec := v1.PodSpec{ - Containers: append(z.Spec.Containers, zkContainer), - Affinity: z.Spec.Pod.Affinity, - Volumes: append(z.Spec.Volumes, volumes...), + Containers: append(z.Spec.Containers, zkContainer), + Affinity: z.Spec.Pod.Affinity, + TopologySpreadConstraints: z.Spec.Pod.TopologySpreadConstraints, + Volumes: append(z.Spec.Volumes, volumes...), } if !reflect.DeepEqual(v1.PodSecurityContext{}, z.Spec.Pod.SecurityContext) { podSpec.SecurityContext = z.Spec.Pod.SecurityContext diff --git a/pkg/zk/generators_test.go b/pkg/zk/generators_test.go index a077bb9aa..f545ddb55 100644 --- a/pkg/zk/generators_test.go +++ b/pkg/zk/generators_test.go @@ -209,6 +209,10 @@ var _ = Describe("Generators Spec", func() { "exampleLabel", "exampleValue")) }) + + It("should have blank topologySpreadConstraints", func() { + Ω(sts.Spec.Template.Spec.TopologySpreadConstraints).To(HaveLen(0)) + }) }) Context("with pod policy annotations", func() { From 66fcc71b23cf57203cc923e98b5a2e80071549e4 Mon Sep 17 00:00:00 2001 From: Nick Huanca <1903525+endzyme@users.noreply.github.com> Date: Thu, 12 Jan 2023 21:10:45 -0700 Subject: [PATCH 04/22] Adjust behavior for pod labels (#521) Pod labels from the Spec.Pod.Labels were previously not propagated to the StatefulSet.Template. This change notes the differences between the two Label locations in the ZookeeperCluster CRD and denotes priority ordering. Signed-off-by: Nick Huanca <1903525+endzyme@users.noreply.github.com> Signed-off-by: Nick Huanca <1903525+endzyme@users.noreply.github.com> Co-authored-by: anishakj <43978302+anishakj@users.noreply.github.com> --- api/v1beta1/zookeepercluster_types.go | 9 +++++---- .../zookeeper.pravega.io_zookeeperclusters_crd.yaml | 8 +++++--- .../bases/zookeeper.pravega.io_zookeeperclusters.yaml | 8 +++++--- pkg/zk/generators.go | 1 + 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/api/v1beta1/zookeepercluster_types.go b/api/v1beta1/zookeepercluster_types.go index 8985daba8..a1269b86d 100644 --- a/api/v1beta1/zookeepercluster_types.go +++ b/api/v1beta1/zookeepercluster_types.go @@ -82,8 +82,9 @@ type ZookeeperClusterSpec struct { // Image is the container image. default is zookeeper:0.2.10 Image ContainerImage `json:"image,omitempty"` - // Labels specifies the labels to attach to pods the operator creates for - // the zookeeper cluster. + // Labels specifies the labels to attach to all resources the operator + // creates for the zookeeper cluster, including StatefulSet, Pod, + // PersistentVolumeClaim, Service, ConfigMap, et al. Labels map[string]string `json:"labels,omitempty"` // Replicas is the expected size of the zookeeper cluster. @@ -433,8 +434,8 @@ func (c *ContainerImage) ToString() string { // PodPolicy defines the common pod configuration for Pods, including when used // in deployments, stateful-sets, etc. type PodPolicy struct { - // Labels specifies the labels to attach to pods the operator creates for - // the zookeeper cluster. + // Labels specifies the labels to attach to pods the operator creates for the + // zookeeper cluster. Overrides any values specified in Spec.Labels. Labels map[string]string `json:"labels,omitempty"` // NodeSelector specifies a map of key-value pairs. For the pod to be diff --git a/charts/zookeeper-operator/templates/zookeeper.pravega.io_zookeeperclusters_crd.yaml b/charts/zookeeper-operator/templates/zookeeper.pravega.io_zookeeperclusters_crd.yaml index c38f3a435..c65974754 100644 --- a/charts/zookeeper-operator/templates/zookeeper.pravega.io_zookeeperclusters_crd.yaml +++ b/charts/zookeeper-operator/templates/zookeeper.pravega.io_zookeeperclusters_crd.yaml @@ -2684,8 +2684,9 @@ spec: labels: additionalProperties: type: string - description: Labels specifies the labels to attach to pods the operator - creates for the zookeeper cluster. + description: Labels specifies the labels to attach to all resources + the operator creates for the zookeeper cluster, including StatefulSet, + Pod, PersistentVolumeClaim, Service, ConfigMap, et al. type: object maxUnavailableReplicas: description: MaxUnavailableReplicas defines the MaxUnavailable Replicas @@ -3875,7 +3876,8 @@ spec: additionalProperties: type: string description: Labels specifies the labels to attach to pods the - operator creates for the zookeeper cluster. + operator creates for the zookeeper cluster. Overrides any values + specified in Spec.Labels. type: object nodeSelector: additionalProperties: diff --git a/config/crd/bases/zookeeper.pravega.io_zookeeperclusters.yaml b/config/crd/bases/zookeeper.pravega.io_zookeeperclusters.yaml index af5084e8a..44b0d742c 100644 --- a/config/crd/bases/zookeeper.pravega.io_zookeeperclusters.yaml +++ b/config/crd/bases/zookeeper.pravega.io_zookeeperclusters.yaml @@ -2683,8 +2683,9 @@ spec: labels: additionalProperties: type: string - description: Labels specifies the labels to attach to pods the operator - creates for the zookeeper cluster. + description: Labels specifies the labels to attach to all resources + the operator creates for the zookeeper cluster, including StatefulSet, + Pod, PersistentVolumeClaim, Service, ConfigMap, et al. type: object maxUnavailableReplicas: description: MaxUnavailableReplicas defines the MaxUnavailable Replicas @@ -3874,7 +3875,8 @@ spec: additionalProperties: type: string description: Labels specifies the labels to attach to pods the - operator creates for the zookeeper cluster. + operator creates for the zookeeper cluster. Overrides any values + specified in Spec.Labels. type: object nodeSelector: additionalProperties: diff --git a/pkg/zk/generators.go b/pkg/zk/generators.go index fddb48727..f13ae37bb 100644 --- a/pkg/zk/generators.go +++ b/pkg/zk/generators.go @@ -92,6 +92,7 @@ func MakeStatefulSet(z *v1beta1.ZookeeperCluster) *appsv1.StatefulSet { GenerateName: z.GetName(), Labels: mergeLabels( z.Spec.Labels, + z.Spec.Pod.Labels, map[string]string{ "app": z.GetName(), "kind": "ZookeeperMember", From a4a345f12c55442ef49dd4fa2223b38a3d02f046 Mon Sep 17 00:00:00 2001 From: georgekaz <1391828+georgekaz@users.noreply.github.com> Date: Sat, 14 Jan 2023 15:11:52 +0000 Subject: [PATCH 05/22] Delete Job scheduling (#520) Signed-off-by: George Kaz <1391828+georgekaz@users.noreply.github.com> Signed-off-by: George Kaz <1391828+georgekaz@users.noreply.github.com> Co-authored-by: anishakj <43978302+anishakj@users.noreply.github.com> --- .../templates/pre-delete-hooks.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/charts/zookeeper-operator/templates/pre-delete-hooks.yaml b/charts/zookeeper-operator/templates/pre-delete-hooks.yaml index 0156d4849..77fa3895a 100644 --- a/charts/zookeeper-operator/templates/pre-delete-hooks.yaml +++ b/charts/zookeeper-operator/templates/pre-delete-hooks.yaml @@ -115,4 +115,16 @@ spec: configMap: name: {{ template "zookeeper-operator.fullname" . }}-pre-delete defaultMode: 0555 + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} + {{- if .Values.affinity }} + affinity: +{{ toYaml .Values.affinity | indent 8 }} + {{- end }} + {{- if .Values.tolerations }} + tolerations: +{{ toYaml .Values.tolerations | indent 8 }} + {{- end }} {{- end }} From 3d3e647985d03a0b63b80fb08d62b45e59cbde79 Mon Sep 17 00:00:00 2001 From: Ann Taraday Date: Tue, 14 Mar 2023 16:15:25 +0100 Subject: [PATCH 06/22] Use distroless image for operator image (#533) * Use distroless image for operator image To avoid security issues switch to usage of distroless image. Also bumped go version to 1.19 Fixes: #508 Signed-off-by: Ann Taraday * Add user setting in Dockerfile Signed-off-by: Ann Taraday * Revert setting USER in Dockerfile Signed-off-by: Ann Taraday * Use cr.io/distroless/static-debian11 Signed-off-by: Ann Taraday * Introduce DISTROLESS_DOCKER_REGISTRY arg Signed-off-by: Ann Taraday * Drop DISTROLESS_DOCKER_REGISTRY from Makefile Signed-off-by: Ann Taraday --------- Signed-off-by: Ann Taraday --- Dockerfile | 11 ++++------- Makefile | 3 ++- go.mod | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index a30e213c5..0fbd405b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ ARG DOCKER_REGISTRY -ARG ALPINE_VERSION=3.15 -FROM ${DOCKER_REGISTRY:+$DOCKER_REGISTRY/}golang:1.18-alpine${ALPINE_VERSION} as go-builder +ARG DISTROLESS_DOCKER_REGISTRY +ARG ALPINE_VERSION=3.17 +FROM ${DOCKER_REGISTRY:+$DOCKER_REGISTRY/}golang:1.19-alpine${ALPINE_VERSION} as go-builder ARG PROJECT_NAME=zookeeper-operator ARG REPO_PATH=github.com/pravega/$PROJECT_NAME @@ -28,14 +29,10 @@ COPY controllers/ controllers/ RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o /src/${PROJECT_NAME} \ -ldflags "-X ${REPO_PATH}/pkg/version.Version=${VERSION} -X ${REPO_PATH}/pkg/version.GitSHA=${GIT_SHA}" main.go -FROM ${DOCKER_REGISTRY:+$DOCKER_REGISTRY/}alpine:${ALPINE_VERSION} AS final - +FROM ${DISTROLESS_DOCKER_REGISTRY:-gcr.io/}distroless/static-debian11:nonroot AS final ARG PROJECT_NAME=zookeeper-operator COPY --from=go-builder /src/${PROJECT_NAME} /usr/local/bin/${PROJECT_NAME} -RUN adduser -D ${PROJECT_NAME} -USER ${PROJECT_NAME} - ENTRYPOINT ["/usr/local/bin/zookeeper-operator"] diff --git a/Makefile b/Makefile index b1d37124a..0017afbb1 100644 --- a/Makefile +++ b/Makefile @@ -130,10 +130,11 @@ build-go: -o bin/$(EXPORTER_NAME)-windows-amd64.exe cmd/exporter/main.go build-image: - docker build --build-arg VERSION=$(VERSION) --build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) --build-arg GIT_SHA=$(GIT_SHA) -t $(REPO):$(VERSION) . + docker build --build-arg VERSION=$(VERSION) --build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) --build-arg DISTROLESS_DOCKER_REGISTRY=$(DISTROLESS_DOCKER_REGISTRY) --build-arg GIT_SHA=$(GIT_SHA) -t $(REPO):$(VERSION) . docker tag $(REPO):$(VERSION) $(REPO):latest build-zk-image: + docker build --build-arg VERSION=$(VERSION) --build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) --build-arg GIT_SHA=$(GIT_SHA) -t $(APP_REPO):$(VERSION) ./docker docker tag $(APP_REPO):$(VERSION) $(APP_REPO):latest diff --git a/go.mod b/go.mod index 1f60fd171..41059a9df 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/pravega/zookeeper-operator -go 1.18 +go 1.19 require ( github.com/ghodss/yaml v1.0.0 From 12e22de616510c66867155cfdf551c6933a6f36b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Mar 2023 22:09:32 +0530 Subject: [PATCH 07/22] Bump github.com/emicklei/go-restful (#528) Bumps [github.com/emicklei/go-restful](https://github.com/emicklei/go-restful) from 2.15.0+incompatible to 2.16.0+incompatible. - [Release notes](https://github.com/emicklei/go-restful/releases) - [Changelog](https://github.com/emicklei/go-restful/blob/v3/CHANGES.md) - [Commits](https://github.com/emicklei/go-restful/compare/v2.15.0...v2.16.0) --- updated-dependencies: - dependency-name: github.com/emicklei/go-restful dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: anishakj <43978302+anishakj@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 41059a9df..4baab2253 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/emicklei/go-restful v2.15.0+incompatible // indirect + github.com/emicklei/go-restful v2.16.0+incompatible // indirect github.com/evanphx/json-patch v5.6.0+incompatible // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/go-logr/zapr v1.2.3 // indirect diff --git a/go.sum b/go.sum index 2388f754b..0cae775dd 100644 --- a/go.sum +++ b/go.sum @@ -133,8 +133,8 @@ github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25Kn github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emicklei/go-restful v2.15.0+incompatible h1:8KpYO/Xl/ZudZs5RNOEhWMBY4hmzlZhhRd9cu+jrZP4= -github.com/emicklei/go-restful v2.15.0+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= +github.com/emicklei/go-restful v2.16.0+incompatible h1:rgqiKNjTnFQA6kkhFe16D8epTksy9HQ1MyrbDXSdYhM= +github.com/emicklei/go-restful v2.16.0+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= From 113814c2647f37f7ee2c690b47b2b4670396094e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 15 Mar 2023 09:33:31 +0530 Subject: [PATCH 08/22] Bump golang.org/x/text from 0.3.7 to 0.3.8 (#532) Bumps [golang.org/x/text](https://github.com/golang/text) from 0.3.7 to 0.3.8. - [Release notes](https://github.com/golang/text/releases) - [Commits](https://github.com/golang/text/compare/v0.3.7...v0.3.8) --- updated-dependencies: - dependency-name: golang.org/x/text dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 4baab2253..576773da6 100644 --- a/go.mod +++ b/go.mod @@ -55,9 +55,9 @@ require ( go.uber.org/zap v1.21.0 // indirect golang.org/x/net v0.0.0-20220526153639-5463443f8c37 // indirect golang.org/x/oauth2 v0.0.0-20220524215830-622c5d57e401 // indirect - golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect + golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect - golang.org/x/text v0.3.7 // indirect + golang.org/x/text v0.3.8 // indirect golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect google.golang.org/appengine v1.6.7 // indirect diff --git a/go.sum b/go.sum index 0cae775dd..39f15eb24 100644 --- a/go.sum +++ b/go.sum @@ -768,8 +768,8 @@ golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 h1:CBpWXWQpIRjzmkkA+M7q9Fqnwd2mZr3AFqexg8YTfoM= @@ -782,8 +782,9 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= From 28d1f6917d2284c5673503816e110cf25555bd49 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 15 Mar 2023 10:53:44 +0530 Subject: [PATCH 09/22] Bump golang.org/x/net from 0.0.0-20220526153639-5463443f8c37 to 0.7.0 (#534) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.0.0-20220526153639-5463443f8c37 to 0.7.0. - [Release notes](https://github.com/golang/net/releases) - [Commits](https://github.com/golang/net/commits/v0.7.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 8 ++++---- go.sum | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 576773da6..def2cc2b8 100644 --- a/go.mod +++ b/go.mod @@ -53,11 +53,11 @@ require ( go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect go.uber.org/zap v1.21.0 // indirect - golang.org/x/net v0.0.0-20220526153639-5463443f8c37 // indirect + golang.org/x/net v0.7.0 // indirect golang.org/x/oauth2 v0.0.0-20220524215830-622c5d57e401 // indirect - golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect - golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect - golang.org/x/text v0.3.8 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/term v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect google.golang.org/appengine v1.6.7 // indirect diff --git a/go.sum b/go.sum index 39f15eb24..31eb30954 100644 --- a/go.sum +++ b/go.sum @@ -657,8 +657,8 @@ golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220526153639-5463443f8c37 h1:lUkvobShwKsOesNfWWlCS5q7fnbG1MEliIzwu886fn8= -golang.org/x/net v0.0.0-20220526153639-5463443f8c37/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -768,12 +768,12 @@ golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 h1:CBpWXWQpIRjzmkkA+M7q9Fqnwd2mZr3AFqexg8YTfoM= -golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -783,8 +783,8 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= From 72bea545a73130c82b530e508a2a14daaa824435 Mon Sep 17 00:00:00 2001 From: anishakj <43978302+anishakj@users.noreply.github.com> Date: Tue, 4 Apr 2023 20:50:47 +0530 Subject: [PATCH 10/22] Issue 543: Updating zookeeper operator/zookeeper chart version (#544) Signed-off-by: anisha.kj --- api/v1beta1/zookeepercluster_types.go | 2 +- api/v1beta1/zookeepercluster_types_test.go | 2 +- charts/zookeeper-operator/Chart.yaml | 4 ++-- charts/zookeeper-operator/README.md | 2 +- charts/zookeeper-operator/values.yaml | 2 +- charts/zookeeper/Chart.yaml | 4 ++-- charts/zookeeper/README.md | 2 +- charts/zookeeper/values.yaml | 2 +- config/manager/manager.yaml | 2 +- config/samples/ECS/zookeeper_v1beta1_zookeepercluster_cr.yaml | 2 +- .../pravega/zookeeper_v1beta1_zookeepercluster_cr.yaml | 2 +- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/api/v1beta1/zookeepercluster_types.go b/api/v1beta1/zookeepercluster_types.go index a1269b86d..f64474b4d 100644 --- a/api/v1beta1/zookeepercluster_types.go +++ b/api/v1beta1/zookeepercluster_types.go @@ -26,7 +26,7 @@ const ( // DefaultZkContainerVersion is the default tag used for for the zookeeper // container - DefaultZkContainerVersion = "0.2.14" + DefaultZkContainerVersion = "0.2.15" // DefaultZkContainerPolicy is the default container pull policy used DefaultZkContainerPolicy = "Always" diff --git a/api/v1beta1/zookeepercluster_types_test.go b/api/v1beta1/zookeepercluster_types_test.go index c098cbd67..c8d59fb0b 100644 --- a/api/v1beta1/zookeepercluster_types_test.go +++ b/api/v1beta1/zookeepercluster_types_test.go @@ -79,7 +79,7 @@ var _ = Describe("ZookeeperCluster Types", func() { }) It("Checking tostring() function", func() { - Ω(z.Spec.Image.ToString()).To(Equal("pravega/zookeeper:0.2.14")) + Ω(z.Spec.Image.ToString()).To(Equal("pravega/zookeeper:0.2.15")) }) }) diff --git a/charts/zookeeper-operator/Chart.yaml b/charts/zookeeper-operator/Chart.yaml index 9fafe472a..5ed411662 100644 --- a/charts/zookeeper-operator/Chart.yaml +++ b/charts/zookeeper-operator/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v2 name: zookeeper-operator description: Zookeeper Operator Helm chart for Kubernetes -version: 0.2.14 -appVersion: 0.2.14 +version: 0.2.15 +appVersion: 0.2.15 keywords: - zookeeper - storage diff --git a/charts/zookeeper-operator/README.md b/charts/zookeeper-operator/README.md index 3175a2ceb..4497ecf29 100644 --- a/charts/zookeeper-operator/README.md +++ b/charts/zookeeper-operator/README.md @@ -55,7 +55,7 @@ The following table lists the configurable parameters of the zookeeper-operator | `hooks.image.tag` | Image tag for batch jobs | `"v1.16.10"` | | `image.pullPolicy` | Image pull policy | `IfNotPresent` | | `image.repository` | Image repository | `pravega/zookeeper-operator` | -| `image.tag` | Image tag | `0.2.14` | +| `image.tag` | Image tag | `0.2.15` | | `labels` | Operator pod labels | `{}` | | `nodeSelector` | Map of key-value pairs to be present as labels in the node in which the pod should run | `{}` | | `rbac.create` | Create RBAC resources | `true` | diff --git a/charts/zookeeper-operator/values.yaml b/charts/zookeeper-operator/values.yaml index eeef7645a..afc8397e3 100644 --- a/charts/zookeeper-operator/values.yaml +++ b/charts/zookeeper-operator/values.yaml @@ -9,7 +9,7 @@ global: image: repository: pravega/zookeeper-operator - tag: 0.2.14 + tag: 0.2.15 pullPolicy: IfNotPresent securityContext: {} diff --git a/charts/zookeeper/Chart.yaml b/charts/zookeeper/Chart.yaml index 3ba08e5a7..594d7de3d 100644 --- a/charts/zookeeper/Chart.yaml +++ b/charts/zookeeper/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v2 name: zookeeper description: Zookeeper Helm chart for Kubernetes -version: 0.2.14 -appVersion: 0.2.14 +version: 0.2.15 +appVersion: 0.2.15 keywords: - zookeeper - storage diff --git a/charts/zookeeper/README.md b/charts/zookeeper/README.md index 8d0417bdb..95027a3ad 100644 --- a/charts/zookeeper/README.md +++ b/charts/zookeeper/README.md @@ -57,7 +57,7 @@ The following table lists the configurable parameters of the zookeeper chart and | `maxUnavailableReplicas` | Max unavailable replicas in pdb | `1` | | `triggerRollingRestart` | If true, the zookeeper cluster is restarted. After the restart is triggered, this value is auto-reverted to false. | `false` | | `image.repository` | Image repository | `pravega/zookeeper` | -| `image.tag` | Image tag | `0.2.14` | +| `image.tag` | Image tag | `0.2.15` | | `image.pullPolicy` | Image pull policy | `IfNotPresent` | | `domainName` | External host name appended for dns annotation | | | `kubernetesClusterDomain` | Domain of the kubernetes cluster | `cluster.local` | diff --git a/charts/zookeeper/values.yaml b/charts/zookeeper/values.yaml index d7977ec75..8a449f0b9 100644 --- a/charts/zookeeper/values.yaml +++ b/charts/zookeeper/values.yaml @@ -3,7 +3,7 @@ maxUnavailableReplicas: image: repository: pravega/zookeeper - tag: 0.2.14 + tag: 0.2.15 pullPolicy: IfNotPresent triggerRollingRestart: false diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index 718a8b499..18163b4c5 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -16,7 +16,7 @@ spec: containers: - name: zookeeper-operator # Replace this with the built image name - image: pravega/zookeeper-operator:0.2.14 + image: pravega/zookeeper-operator:0.2.15 ports: - containerPort: 60000 name: metrics diff --git a/config/samples/ECS/zookeeper_v1beta1_zookeepercluster_cr.yaml b/config/samples/ECS/zookeeper_v1beta1_zookeepercluster_cr.yaml index 26faab41d..8130f7533 100644 --- a/config/samples/ECS/zookeeper_v1beta1_zookeepercluster_cr.yaml +++ b/config/samples/ECS/zookeeper_v1beta1_zookeepercluster_cr.yaml @@ -6,7 +6,7 @@ spec: replicas: 3 image: repository: pravega/zookeeper - tag: 0.2.14 + tag: 0.2.15 storageType: persistence persistence: reclaimPolicy: Retain diff --git a/config/samples/pravega/zookeeper_v1beta1_zookeepercluster_cr.yaml b/config/samples/pravega/zookeeper_v1beta1_zookeepercluster_cr.yaml index b28a34fda..d3520411c 100644 --- a/config/samples/pravega/zookeeper_v1beta1_zookeepercluster_cr.yaml +++ b/config/samples/pravega/zookeeper_v1beta1_zookeepercluster_cr.yaml @@ -6,7 +6,7 @@ spec: replicas: 3 image: repository: pravega/zookeeper - tag: 0.2.14 + tag: 0.2.15 storageType: persistence persistence: reclaimPolicy: Delete From 281f6f8f417bd01f1d301c7ac6197036db85a604 Mon Sep 17 00:00:00 2001 From: Nishant Gupta <90177384+nishant-yt@users.noreply.github.com> Date: Wed, 8 Jun 2022 19:10:09 +0530 Subject: [PATCH 11/22] Issue 482: Reevaluating number of client connections dynamically in the teardown script (#483) Signed-off-by: Nishant Gupta Signed-off-by: Marco Moscher --- docker/bin/zookeeperTeardown.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/bin/zookeeperTeardown.sh b/docker/bin/zookeeperTeardown.sh index da361b8db..9237dafa5 100755 --- a/docker/bin/zookeeperTeardown.sh +++ b/docker/bin/zookeeperTeardown.sh @@ -20,8 +20,8 @@ LOG4J_CONF=/conf/log4j-quiet.properties # Wait for client connections to drain. Kubernetes will wait until the confiugred # "terminationGracePeriodSeconds" before focibly killing the container -for (( i = 0; i < 6; i++ )); do - CONN_COUNT=`echo cons | socat stdio tcp:localhost:$CLIENT_PORT | grep -v "^$" |grep -v "/127.0.0.1:" | wc -l` +for ((i = 0; i < 6; i++)); do + CONN_COUNT=$(echo cons | socat stdio tcp:localhost:$CLIENT_PORT | grep -v "^$" | grep -v "/127.0.0.1:" | wc -l) if [[ "$CONN_COUNT" -gt 0 ]]; then echo "$CONN_COUNT non-local connections still connected." sleep 5 @@ -35,10 +35,10 @@ done set +e ZKURL=$(zkConnectionString) set -e -MYID=`cat $MYID_FILE` +MYID=$(cat $MYID_FILE) ZNODE_PATH="/zookeeper-operator/$CLUSTER_NAME" -CLUSTERSIZE=`java -Dlog4j.configuration=file:"$LOG4J_CONF" -jar /opt/libs/zu.jar sync $ZKURL $ZNODE_PATH` +CLUSTERSIZE=$(java -Dlog4j.configuration=file:"$LOG4J_CONF" -jar /opt/libs/zu.jar sync $ZKURL $ZNODE_PATH) echo "CLUSTER_SIZE=$CLUSTERSIZE, MyId=$MYID" if [[ -n "$CLUSTERSIZE" && "$CLUSTERSIZE" -lt "$MYID" ]]; then # If ClusterSize < MyId, this server is being permanantly removed. From 5a2ac6d75247a2f8734fdcb1663ed8f2a7ab5ce2 Mon Sep 17 00:00:00 2001 From: Marco Moscher Date: Tue, 4 Oct 2022 23:14:49 +0200 Subject: [PATCH 12/22] use arm64 for go Signed-off-by: Marco Moscher --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0fbd405b8..7fdfe1b9e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,7 +26,7 @@ COPY api/ api/ COPY controllers/ controllers/ # Build -RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o /src/${PROJECT_NAME} \ +RUN GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o /src/${PROJECT_NAME} \ -ldflags "-X ${REPO_PATH}/pkg/version.Version=${VERSION} -X ${REPO_PATH}/pkg/version.GitSHA=${GIT_SHA}" main.go FROM ${DISTROLESS_DOCKER_REGISTRY:-gcr.io/}distroless/static-debian11:nonroot AS final From 0af3fd704d2ae5f9de3614924c836ba8db406206 Mon Sep 17 00:00:00 2001 From: Marco Moscher Date: Wed, 12 Oct 2022 21:59:32 +0200 Subject: [PATCH 13/22] adds docker multiarch builds and use it in push Signed-off-by: Marco Moscher --- .github/workflows/ci.yaml | 106 ++++++++++++++++++++------------------ Dockerfile | 7 ++- Makefile | 21 +++++++- 3 files changed, 80 insertions(+), 54 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c9d351141..35313b294 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,62 +15,66 @@ on: # jobs to run jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Set up Go 1.17 - uses: actions/setup-go@v2 - with: - go-version: 1.17 - id: go - - name: Set up Go for root - run: | - sudo ln -sf `which go` `sudo which go` || true - sudo go version - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - name: get go version - run: go version - - name: Gofmt and License checks - run: make check - - name: unit tests - run: make test - - name: Codecov - uses: codecov/codecov-action@v1.0.12 - - name: Set env - run: | - echo "KUBERNETES_VERSION=v1.23.1" >> $GITHUB_ENV - echo "MINIKUBE_VERSION=v1.25.2" >> $GITHUB_ENV - echo "KUBERNETES_CONFIG_FILE=$HOME/.kube/config" >> $GITHUB_ENV - echo "CHANGE_MINIKUBE_NONE_USER=true" >> $GITHUB_ENV - - name: minikube setup - run: | - curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$KUBERNETES_VERSION/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ - curl -Lo minikube https://storage.googleapis.com/minikube/releases/$MINIKUBE_VERSION/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/ - sudo mount --make-rshared / - sudo apt-get install -y conntrack - CHANGE_MINIKUBE_NONE_USER=true - export KUBERNETES_CONFIG_FILE=$HOME/.kube/config - export KUBERNETES_CONFIG_FILE=$HOME/.kube/config;export CHANGE_MINIKUBE_NONE_USER=true;sudo minikube start --vm-driver=none --bootstrapper=kubeadm --kubernetes-version=$KUBERNETES_VERSION - echo "minikube started, updating context" - export KUBERNETES_CONFIG_FILE=$HOME/.kube/config;export CHANGE_MINIKUBE_NONE_USER=true; sudo minikube update-context - echo "context is updated" - #JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done - sleep 60 - sudo kubectl create clusterrolebinding add-on-cluster-admin --clusterrole=cluster-admin --serviceaccount=kube-system:default - echo "created cluster role" - sudo kubectl cluster-info - echo "cluster info" - sudo kubectl -n kube-system get pod -o wide - sudo kubectl create secret docker-registry regcred --docker-server=https://index.docker.io/v1/ --docker-username="testanisha" --docker-password="123456789" --docker-email=testimage456@gmail.com - - name: E2E - run: sudo make test-e2e + # build: + # runs-on: ubuntu-latest + # steps: + # - name: Set up Go 1.17 + # uses: actions/setup-go@v2 + # with: + # go-version: 1.17 + # id: go + # - name: Set up Go for root + # run: | + # sudo ln -sf `which go` `sudo which go` || true + # sudo go version + # - name: Check out code into the Go module directory + # uses: actions/checkout@v2 + # - name: get go version + # run: go version + # - name: Gofmt and License checks + # run: make check + # - name: unit tests + # run: make test + # - name: Codecov + # uses: codecov/codecov-action@v1.0.12 + # - name: Set env + # run: | + # echo "KUBERNETES_VERSION=v1.23.1" >> $GITHUB_ENV + # echo "MINIKUBE_VERSION=v1.25.2" >> $GITHUB_ENV + # echo "KUBERNETES_CONFIG_FILE=$HOME/.kube/config" >> $GITHUB_ENV + # echo "CHANGE_MINIKUBE_NONE_USER=true" >> $GITHUB_ENV + # - name: minikube setup + # run: | + # curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$KUBERNETES_VERSION/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ + # curl -Lo minikube https://storage.googleapis.com/minikube/releases/$MINIKUBE_VERSION/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/ + # sudo mount --make-rshared / + # sudo apt-get install -y conntrack + # CHANGE_MINIKUBE_NONE_USER=true + # export KUBERNETES_CONFIG_FILE=$HOME/.kube/config + # export KUBERNETES_CONFIG_FILE=$HOME/.kube/config;export CHANGE_MINIKUBE_NONE_USER=true;sudo minikube start --vm-driver=none --bootstrapper=kubeadm --kubernetes-version=$KUBERNETES_VERSION + # echo "minikube started, updating context" + # export KUBERNETES_CONFIG_FILE=$HOME/.kube/config;export CHANGE_MINIKUBE_NONE_USER=true; sudo minikube update-context + # echo "context is updated" + # #JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done + # sleep 60 + # sudo kubectl create clusterrolebinding add-on-cluster-admin --clusterrole=cluster-admin --serviceaccount=kube-system:default + # echo "created cluster role" + # sudo kubectl cluster-info + # echo "cluster info" + # sudo kubectl -n kube-system get pod -o wide + # sudo kubectl create secret docker-registry regcred --docker-server=https://index.docker.io/v1/ --docker-username="testanisha" --docker-password="123456789" --docker-email=testimage456@gmail.com + # - name: E2E + # run: sudo make test-e2e publish: name: Publish docker image runs-on: ubuntu-latest - needs: build + #needs: build if: github.event_name == 'release' && github.event.action == 'created' steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 - name: Pushing docker images run: sudo make push - name: Uploading binary files diff --git a/Dockerfile b/Dockerfile index 7fdfe1b9e..0f61b3221 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ ARG DOCKER_REGISTRY ARG DISTROLESS_DOCKER_REGISTRY ARG ALPINE_VERSION=3.17 -FROM ${DOCKER_REGISTRY:+$DOCKER_REGISTRY/}golang:1.19-alpine${ALPINE_VERSION} as go-builder +FROM --platform=$BUILDPLATFORM ${DOCKER_REGISTRY:+$DOCKER_REGISTRY/}golang:1.19-alpine${ALPINE_VERSION} as go-builder ARG PROJECT_NAME=zookeeper-operator ARG REPO_PATH=github.com/pravega/$PROJECT_NAME @@ -10,6 +10,9 @@ ARG REPO_PATH=github.com/pravega/$PROJECT_NAME ARG VERSION=0.0.0-localdev ARG GIT_SHA=0000000 +ARG TARGETOS=linux +ARG TARGETARCH=amd64 + WORKDIR /src COPY pkg ./pkg COPY cmd ./cmd @@ -26,7 +29,7 @@ COPY api/ api/ COPY controllers/ controllers/ # Build -RUN GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o /src/${PROJECT_NAME} \ +RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 go build -o /src/${PROJECT_NAME} \ -ldflags "-X ${REPO_PATH}/pkg/version.Version=${VERSION} -X ${REPO_PATH}/pkg/version.GitSHA=${GIT_SHA}" main.go FROM ${DISTROLESS_DOCKER_REGISTRY:-gcr.io/}distroless/static-debian11:nonroot AS final diff --git a/Makefile b/Makefile index 0017afbb1..c353474b0 100644 --- a/Makefile +++ b/Makefile @@ -138,6 +138,25 @@ build-zk-image: docker build --build-arg VERSION=$(VERSION) --build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) --build-arg GIT_SHA=$(GIT_SHA) -t $(APP_REPO):$(VERSION) ./docker docker tag $(APP_REPO):$(VERSION) $(APP_REPO):latest +build-multiarch-image: + docker buildx build \ + --build-arg VERSION=$(VERSION) \ + --build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) \ + --build-arg GIT_SHA=$(GIT_SHA) \ + --platform=linux/amd64,linux/arm64 \ + -t $(REPO):$(VERSION) . + docker tag $(REPO):$(VERSION) $(REPO):latest + +build-multiarch-zk-image: + docker buildx build \ + --build-arg VERSION=$(VERSION) \ + --build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) \ + --build-arg GIT_SHA=$(GIT_SHA) \ + --platform=linux/amd64,linux/arm64 \ + -t $(APP_REPO):$(VERSION) \ + ./docker + docker tag $(APP_REPO):$(VERSION) $(APP_REPO):latest + build-zk-image-swarm: docker build --build-arg VERSION=$(VERSION)-swarm --build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) --build-arg GIT_SHA=$(GIT_SHA) \ -f ./docker/Dockerfile-swarm -t $(APP_REPO):$(VERSION)-swarm ./docker @@ -169,7 +188,7 @@ login: test-login: echo "$(DOCKER_TEST_PASS)" | docker login -u "$(DOCKER_TEST_USER)" --password-stdin -push: build-image build-zk-image login +push: build-multiarch-image build-multiarch-zk-image login docker push $(REPO):$(VERSION) docker push $(REPO):latest docker push $(APP_REPO):$(VERSION) From 0dd8f0206a73bc39be62ce0876f454ae44f9e5f1 Mon Sep 17 00:00:00 2001 From: Marco Moscher Date: Wed, 12 Oct 2022 22:05:17 +0200 Subject: [PATCH 14/22] change repo for testing Signed-off-by: Marco Moscher --- Makefile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index c353474b0..36b915cb8 100644 --- a/Makefile +++ b/Makefile @@ -13,9 +13,9 @@ CRD_OPTIONS ?= "crd" PROJECT_NAME=zookeeper-operator EXPORTER_NAME=zookeeper-exporter APP_NAME=zookeeper -REPO=pravega/$(PROJECT_NAME) +REPO=mmoscher/$(PROJECT_NAME) TEST_REPO=testzkop/$(PROJECT_NAME) -APP_REPO=pravega/$(APP_NAME) +APP_REPO=mmoscher/$(APP_NAME) ALTREPO=emccorp/$(PROJECT_NAME) APP_ALTREPO=emccorp/$(APP_NAME) VERSION=$(shell git describe --always --tags --dirty | tr -d "v" | sed "s/\(.*\)-g`git rev-parse --short HEAD`/\1/") @@ -193,14 +193,14 @@ push: build-multiarch-image build-multiarch-zk-image login docker push $(REPO):latest docker push $(APP_REPO):$(VERSION) docker push $(APP_REPO):latest - docker tag $(REPO):$(VERSION) $(ALTREPO):$(VERSION) - docker tag $(REPO):$(VERSION) $(ALTREPO):latest - docker tag $(APP_REPO):$(VERSION) $(APP_ALTREPO):$(VERSION) - docker tag $(APP_REPO):$(VERSION) $(APP_ALTREPO):latest - docker push $(ALTREPO):$(VERSION) - docker push $(ALTREPO):latest - docker push $(APP_ALTREPO):$(VERSION) - docker push $(APP_ALTREPO):latest + # docker tag $(REPO):$(VERSION) $(ALTREPO):$(VERSION) + # docker tag $(REPO):$(VERSION) $(ALTREPO):latest + # docker tag $(APP_REPO):$(VERSION) $(APP_ALTREPO):$(VERSION) + # docker tag $(APP_REPO):$(VERSION) $(APP_ALTREPO):latest + # docker push $(ALTREPO):$(VERSION) + # docker push $(ALTREPO):latest + # docker push $(APP_ALTREPO):$(VERSION) + # docker push $(APP_ALTREPO):latest clean: rm -f bin/$(PROJECT_NAME) From 0d04dcfd6835eecabbd1accdc1bf765e2fcdabc2 Mon Sep 17 00:00:00 2001 From: Marco Moscher Date: Wed, 12 Oct 2022 22:29:36 +0200 Subject: [PATCH 15/22] minor rework, push mutliarch directly Signed-off-by: Marco Moscher --- .github/workflows/ci.yaml | 8 ++------ Makefile | 31 ++++++++++++++++++------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 35313b294..36b2caa42 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -76,9 +76,5 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Pushing docker images - run: sudo make push - - name: Uploading binary files - uses: actions/upload-artifact@v2 - with: - name: zookeeper-exporter - path: bin/zookeeper-exporter* + run: | + make push-multiarch diff --git a/Makefile b/Makefile index 36b915cb8..f03f39f0f 100644 --- a/Makefile +++ b/Makefile @@ -140,22 +140,25 @@ build-zk-image: build-multiarch-image: docker buildx build \ + --push \ --build-arg VERSION=$(VERSION) \ --build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) \ --build-arg GIT_SHA=$(GIT_SHA) \ --platform=linux/amd64,linux/arm64 \ - -t $(REPO):$(VERSION) . - docker tag $(REPO):$(VERSION) $(REPO):latest + -t $(REPO):$(VERSION) + -t $(REPO):latest \ + . build-multiarch-zk-image: docker buildx build \ + --push \ --build-arg VERSION=$(VERSION) \ --build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) \ --build-arg GIT_SHA=$(GIT_SHA) \ --platform=linux/amd64,linux/arm64 \ -t $(APP_REPO):$(VERSION) \ + -t $(APP_REPO):latest \ ./docker - docker tag $(APP_REPO):$(VERSION) $(APP_REPO):latest build-zk-image-swarm: docker build --build-arg VERSION=$(VERSION)-swarm --build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) --build-arg GIT_SHA=$(GIT_SHA) \ @@ -183,24 +186,26 @@ run-local: go run ./main.go login: - @docker login -u "$(DOCKER_USER)" -p "$(DOCKER_PASS)" + echo "$(DOCKER_PASS)" | docker login -u "$(DOCKER_USER)" --password-stdin test-login: echo "$(DOCKER_TEST_PASS)" | docker login -u "$(DOCKER_TEST_USER)" --password-stdin -push: build-multiarch-image build-multiarch-zk-image login +push-multiarch: login build-multiarch-image build-multiarch-zk-image + +push: build-image build-zk-image login docker push $(REPO):$(VERSION) docker push $(REPO):latest docker push $(APP_REPO):$(VERSION) docker push $(APP_REPO):latest - # docker tag $(REPO):$(VERSION) $(ALTREPO):$(VERSION) - # docker tag $(REPO):$(VERSION) $(ALTREPO):latest - # docker tag $(APP_REPO):$(VERSION) $(APP_ALTREPO):$(VERSION) - # docker tag $(APP_REPO):$(VERSION) $(APP_ALTREPO):latest - # docker push $(ALTREPO):$(VERSION) - # docker push $(ALTREPO):latest - # docker push $(APP_ALTREPO):$(VERSION) - # docker push $(APP_ALTREPO):latest + docker tag $(REPO):$(VERSION) $(ALTREPO):$(VERSION) + docker tag $(REPO):$(VERSION) $(ALTREPO):latest + docker tag $(APP_REPO):$(VERSION) $(APP_ALTREPO):$(VERSION) + docker tag $(APP_REPO):$(VERSION) $(APP_ALTREPO):latest + docker push $(ALTREPO):$(VERSION) + docker push $(ALTREPO):latest + docker push $(APP_ALTREPO):$(VERSION) + docker push $(APP_ALTREPO):latest clean: rm -f bin/$(PROJECT_NAME) From 59223d4d5af0c60493811e5c47f81cf192c66aa3 Mon Sep 17 00:00:00 2001 From: Marco Moscher Date: Wed, 12 Oct 2022 22:35:01 +0200 Subject: [PATCH 16/22] adds checkout to ci.yaml Signed-off-by: Marco Moscher --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 36b2caa42..24dda4746 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -71,6 +71,8 @@ jobs: #needs: build if: github.event_name == 'release' && github.event.action == 'created' steps: + - name: Check out code + uses: actions/checkout@v3 - name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx From cee55ee1b4652d42ba5336c5af8492415cf66c38 Mon Sep 17 00:00:00 2001 From: Marco Moscher Date: Wed, 12 Oct 2022 22:35:18 +0200 Subject: [PATCH 17/22] fixes job naming Signed-off-by: Marco Moscher --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 24dda4746..3acc2bb52 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -77,6 +77,6 @@ jobs: uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Pushing docker images + - name: Build and publish docker images run: | make push-multiarch From 11f9caf105bc1b7991a2c5904ef20d9f5f4bffb6 Mon Sep 17 00:00:00 2001 From: Marco Moscher Date: Wed, 12 Oct 2022 22:42:30 +0200 Subject: [PATCH 18/22] reworks ci Signed-off-by: Marco Moscher --- .github/workflows/ci.yaml | 6 +++++- Makefile | 6 ++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3acc2bb52..368010735 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -77,6 +77,10 @@ jobs: uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 + - name: Run docker login + run: | + echo "${{ secrets.DOCKER_PASS }}" | docker login -u "${{ secrets.DOCKER_PASS }}" --password-stdin - name: Build and publish docker images run: | - make push-multiarch + make build-and-push-multiarch-image + make build-and-push-multiarch-zk-image diff --git a/Makefile b/Makefile index f03f39f0f..40cc0e1b0 100644 --- a/Makefile +++ b/Makefile @@ -138,7 +138,7 @@ build-zk-image: docker build --build-arg VERSION=$(VERSION) --build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) --build-arg GIT_SHA=$(GIT_SHA) -t $(APP_REPO):$(VERSION) ./docker docker tag $(APP_REPO):$(VERSION) $(APP_REPO):latest -build-multiarch-image: +build-and-push-multiarch: docker buildx build \ --push \ --build-arg VERSION=$(VERSION) \ @@ -149,7 +149,7 @@ build-multiarch-image: -t $(REPO):latest \ . -build-multiarch-zk-image: + build-and-push-multiarch-zk-image: docker buildx build \ --push \ --build-arg VERSION=$(VERSION) \ @@ -191,8 +191,6 @@ login: test-login: echo "$(DOCKER_TEST_PASS)" | docker login -u "$(DOCKER_TEST_USER)" --password-stdin -push-multiarch: login build-multiarch-image build-multiarch-zk-image - push: build-image build-zk-image login docker push $(REPO):$(VERSION) docker push $(REPO):latest From 58128935470ca9b1f346cc1a2e4cb9a7b55d0b9e Mon Sep 17 00:00:00 2001 From: Marco Moscher Date: Wed, 12 Oct 2022 22:45:19 +0200 Subject: [PATCH 19/22] fixes variable name Signed-off-by: Marco Moscher --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 368010735..84e36aa80 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -79,7 +79,7 @@ jobs: uses: docker/setup-buildx-action@v2 - name: Run docker login run: | - echo "${{ secrets.DOCKER_PASS }}" | docker login -u "${{ secrets.DOCKER_PASS }}" --password-stdin + echo "${{ secrets.DOCKER_PASS }}" | docker login -u "${{ secrets.DOCKER_USER }}" --password-stdin - name: Build and publish docker images run: | make build-and-push-multiarch-image From 835e7479a8e539df424ae48cf932de5f96617d8d Mon Sep 17 00:00:00 2001 From: Marco Moscher Date: Wed, 12 Oct 2022 22:46:45 +0200 Subject: [PATCH 20/22] finally... Signed-off-by: Marco Moscher --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 40cc0e1b0..9bc68ff0e 100644 --- a/Makefile +++ b/Makefile @@ -138,7 +138,7 @@ build-zk-image: docker build --build-arg VERSION=$(VERSION) --build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) --build-arg GIT_SHA=$(GIT_SHA) -t $(APP_REPO):$(VERSION) ./docker docker tag $(APP_REPO):$(VERSION) $(APP_REPO):latest -build-and-push-multiarch: +build-and-push-multiarch-image: docker buildx build \ --push \ --build-arg VERSION=$(VERSION) \ From 217aa0eaedf0b4413ea8fdf8c3db2b103d4f6b07 Mon Sep 17 00:00:00 2001 From: Marco Moscher Date: Wed, 12 Oct 2022 22:48:37 +0200 Subject: [PATCH 21/22] fixed missing slash Signed-off-by: Marco Moscher --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9bc68ff0e..c663eb1a1 100644 --- a/Makefile +++ b/Makefile @@ -145,7 +145,7 @@ build-and-push-multiarch-image: --build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) \ --build-arg GIT_SHA=$(GIT_SHA) \ --platform=linux/amd64,linux/arm64 \ - -t $(REPO):$(VERSION) + -t $(REPO):$(VERSION) \ -t $(REPO):latest \ . From 952137e6913a60ace84d2b7fc4a8e3effbc7e0d4 Mon Sep 17 00:00:00 2001 From: Marco Moscher Date: Wed, 12 Oct 2022 23:01:20 +0200 Subject: [PATCH 22/22] undo changes for testing Signed-off-by: Marco Moscher --- .github/workflows/ci.yaml | 102 +++++++++++++++++++------------------- Dockerfile | 1 + Makefile | 4 +- 3 files changed, 54 insertions(+), 53 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 84e36aa80..809e76b00 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,60 +15,60 @@ on: # jobs to run jobs: - # build: - # runs-on: ubuntu-latest - # steps: - # - name: Set up Go 1.17 - # uses: actions/setup-go@v2 - # with: - # go-version: 1.17 - # id: go - # - name: Set up Go for root - # run: | - # sudo ln -sf `which go` `sudo which go` || true - # sudo go version - # - name: Check out code into the Go module directory - # uses: actions/checkout@v2 - # - name: get go version - # run: go version - # - name: Gofmt and License checks - # run: make check - # - name: unit tests - # run: make test - # - name: Codecov - # uses: codecov/codecov-action@v1.0.12 - # - name: Set env - # run: | - # echo "KUBERNETES_VERSION=v1.23.1" >> $GITHUB_ENV - # echo "MINIKUBE_VERSION=v1.25.2" >> $GITHUB_ENV - # echo "KUBERNETES_CONFIG_FILE=$HOME/.kube/config" >> $GITHUB_ENV - # echo "CHANGE_MINIKUBE_NONE_USER=true" >> $GITHUB_ENV - # - name: minikube setup - # run: | - # curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$KUBERNETES_VERSION/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ - # curl -Lo minikube https://storage.googleapis.com/minikube/releases/$MINIKUBE_VERSION/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/ - # sudo mount --make-rshared / - # sudo apt-get install -y conntrack - # CHANGE_MINIKUBE_NONE_USER=true - # export KUBERNETES_CONFIG_FILE=$HOME/.kube/config - # export KUBERNETES_CONFIG_FILE=$HOME/.kube/config;export CHANGE_MINIKUBE_NONE_USER=true;sudo minikube start --vm-driver=none --bootstrapper=kubeadm --kubernetes-version=$KUBERNETES_VERSION - # echo "minikube started, updating context" - # export KUBERNETES_CONFIG_FILE=$HOME/.kube/config;export CHANGE_MINIKUBE_NONE_USER=true; sudo minikube update-context - # echo "context is updated" - # #JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done - # sleep 60 - # sudo kubectl create clusterrolebinding add-on-cluster-admin --clusterrole=cluster-admin --serviceaccount=kube-system:default - # echo "created cluster role" - # sudo kubectl cluster-info - # echo "cluster info" - # sudo kubectl -n kube-system get pod -o wide - # sudo kubectl create secret docker-registry regcred --docker-server=https://index.docker.io/v1/ --docker-username="testanisha" --docker-password="123456789" --docker-email=testimage456@gmail.com - # - name: E2E - # run: sudo make test-e2e + build: + runs-on: ubuntu-latest + steps: + - name: Set up Go 1.17 + uses: actions/setup-go@v2 + with: + go-version: 1.17 + id: go + - name: Set up Go for root + run: | + sudo ln -sf `which go` `sudo which go` || true + sudo go version + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + - name: get go version + run: go version + - name: Gofmt and License checks + run: make check + - name: unit tests + run: make test + - name: Codecov + uses: codecov/codecov-action@v1.0.12 + - name: Set env + run: | + echo "KUBERNETES_VERSION=v1.23.1" >> $GITHUB_ENV + echo "MINIKUBE_VERSION=v1.25.2" >> $GITHUB_ENV + echo "KUBERNETES_CONFIG_FILE=$HOME/.kube/config" >> $GITHUB_ENV + echo "CHANGE_MINIKUBE_NONE_USER=true" >> $GITHUB_ENV + - name: minikube setup + run: | + curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$KUBERNETES_VERSION/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ + curl -Lo minikube https://storage.googleapis.com/minikube/releases/$MINIKUBE_VERSION/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/ + sudo mount --make-rshared / + sudo apt-get install -y conntrack + CHANGE_MINIKUBE_NONE_USER=true + export KUBERNETES_CONFIG_FILE=$HOME/.kube/config + export KUBERNETES_CONFIG_FILE=$HOME/.kube/config;export CHANGE_MINIKUBE_NONE_USER=true;sudo minikube start --vm-driver=none --bootstrapper=kubeadm --kubernetes-version=$KUBERNETES_VERSION + echo "minikube started, updating context" + export KUBERNETES_CONFIG_FILE=$HOME/.kube/config;export CHANGE_MINIKUBE_NONE_USER=true; sudo minikube update-context + echo "context is updated" + #JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done + sleep 60 + sudo kubectl create clusterrolebinding add-on-cluster-admin --clusterrole=cluster-admin --serviceaccount=kube-system:default + echo "created cluster role" + sudo kubectl cluster-info + echo "cluster info" + sudo kubectl -n kube-system get pod -o wide + sudo kubectl create secret docker-registry regcred --docker-server=https://index.docker.io/v1/ --docker-username="testanisha" --docker-password="123456789" --docker-email=testimage456@gmail.com + - name: E2E + run: sudo make test-e2e publish: name: Publish docker image runs-on: ubuntu-latest - #needs: build + needs: build if: github.event_name == 'release' && github.event.action == 'created' steps: - name: Check out code diff --git a/Dockerfile b/Dockerfile index 0f61b3221..2c1b59080 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ ARG DOCKER_REGISTRY ARG DISTROLESS_DOCKER_REGISTRY ARG ALPINE_VERSION=3.17 +ARG BUILDPLATFORM=linux/amd64 FROM --platform=$BUILDPLATFORM ${DOCKER_REGISTRY:+$DOCKER_REGISTRY/}golang:1.19-alpine${ALPINE_VERSION} as go-builder ARG PROJECT_NAME=zookeeper-operator diff --git a/Makefile b/Makefile index c663eb1a1..55e0d9498 100644 --- a/Makefile +++ b/Makefile @@ -13,9 +13,9 @@ CRD_OPTIONS ?= "crd" PROJECT_NAME=zookeeper-operator EXPORTER_NAME=zookeeper-exporter APP_NAME=zookeeper -REPO=mmoscher/$(PROJECT_NAME) +REPO=pravega/$(PROJECT_NAME) TEST_REPO=testzkop/$(PROJECT_NAME) -APP_REPO=mmoscher/$(APP_NAME) +APP_REPO=pravega/$(APP_NAME) ALTREPO=emccorp/$(PROJECT_NAME) APP_ALTREPO=emccorp/$(APP_NAME) VERSION=$(shell git describe --always --tags --dirty | tr -d "v" | sed "s/\(.*\)-g`git rev-parse --short HEAD`/\1/")