From 3d95b37fdff0e21323873560baa9838d694a0f7a Mon Sep 17 00:00:00 2001 From: Artem Basalaev Date: Mon, 15 Jul 2024 16:28:29 +0200 Subject: [PATCH 1/2] Replace ReplicationController with Deployment in addons --- deploy/addons/efk/elasticsearch-rc.yaml.tmpl | 11 +++++++---- deploy/addons/efk/fluentd-es-rc.yaml.tmpl | 10 ++++++++-- deploy/addons/efk/kibana-rc.yaml.tmpl | 7 +++++-- deploy/addons/freshpod/freshpod-rc.yaml.tmpl | 11 +++++++---- deploy/addons/registry/registry-rc.yaml.tmpl | 8 +++++--- 5 files changed, 32 insertions(+), 15 deletions(-) diff --git a/deploy/addons/efk/elasticsearch-rc.yaml.tmpl b/deploy/addons/efk/elasticsearch-rc.yaml.tmpl index 466891219f87..ca5a49f283a5 100644 --- a/deploy/addons/efk/elasticsearch-rc.yaml.tmpl +++ b/deploy/addons/efk/elasticsearch-rc.yaml.tmpl @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -apiVersion: v1 -kind: ReplicationController +apiVersion: apps/v1 +kind: Deployment metadata: name: elasticsearch-logging namespace: kube-system @@ -24,12 +24,15 @@ metadata: spec: replicas: 1 selector: - k8s-app: elasticsearch-logging - addonmanager.kubernetes.io/mode: Reconcile + matchLabels: + k8s-app: elasticsearch-logging + kubernetes.io/minikube-addons: efk + addonmanager.kubernetes.io/mode: Reconcile template: metadata: labels: k8s-app: elasticsearch-logging + kubernetes.io/minikube-addons: efk addonmanager.kubernetes.io/mode: Reconcile spec: containers: diff --git a/deploy/addons/efk/fluentd-es-rc.yaml.tmpl b/deploy/addons/efk/fluentd-es-rc.yaml.tmpl index d43282982c5e..8cc1c8fb8eeb 100644 --- a/deploy/addons/efk/fluentd-es-rc.yaml.tmpl +++ b/deploy/addons/efk/fluentd-es-rc.yaml.tmpl @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -apiVersion: v1 -kind: ReplicationController +apiVersion: apps/v1 +kind: Deployment metadata: name: fluentd-es namespace: kube-system @@ -23,10 +23,16 @@ metadata: addonmanager.kubernetes.io/mode: Reconcile spec: replicas: 1 + selector: + matchLabels: + k8s-app: fluentd-es + kubernetes.io/minikube-addons: efk + addonmanager.kubernetes.io/mode: Reconcile template: metadata: labels: k8s-app: fluentd-es + kubernetes.io/minikube-addons: efk addonmanager.kubernetes.io/mode: Reconcile spec: containers: diff --git a/deploy/addons/efk/kibana-rc.yaml.tmpl b/deploy/addons/efk/kibana-rc.yaml.tmpl index ed541e49b08f..a9d289e641b4 100644 --- a/deploy/addons/efk/kibana-rc.yaml.tmpl +++ b/deploy/addons/efk/kibana-rc.yaml.tmpl @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -apiVersion: v1 -kind: ReplicationController +apiVersion: apps/v1 +kind: Deployment metadata: name: kibana-logging namespace: kube-system @@ -24,12 +24,15 @@ metadata: spec: replicas: 1 selector: + matchLabels: k8s-app: kibana-logging + kubernetes.io/minikube-addons: efk addonmanager.kubernetes.io/mode: Reconcile template: metadata: labels: k8s-app: kibana-logging + kubernetes.io/minikube-addons: efk addonmanager.kubernetes.io/mode: Reconcile spec: containers: diff --git a/deploy/addons/freshpod/freshpod-rc.yaml.tmpl b/deploy/addons/freshpod/freshpod-rc.yaml.tmpl index 70e380794017..30c413776564 100644 --- a/deploy/addons/freshpod/freshpod-rc.yaml.tmpl +++ b/deploy/addons/freshpod/freshpod-rc.yaml.tmpl @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -apiVersion: v1 -kind: ReplicationController +apiVersion: apps/v1 +kind: Deployment metadata: name: freshpod namespace: kube-system @@ -24,12 +24,15 @@ metadata: spec: replicas: 1 selector: - k8s-app: freshpod - addonmanager.kubernetes.io/mode: Reconcile + matchLabels: + k8s-app: freshpod + kubernetes.io/minikube-addons: freshpod + addonmanager.kubernetes.io/mode: Reconcile template: metadata: labels: k8s-app: freshpod + kubernetes.io/minikube-addons: freshpod addonmanager.kubernetes.io/mode: Reconcile spec: containers: diff --git a/deploy/addons/registry/registry-rc.yaml.tmpl b/deploy/addons/registry/registry-rc.yaml.tmpl index eb6d782ba043..7f7e13e2f986 100644 --- a/deploy/addons/registry/registry-rc.yaml.tmpl +++ b/deploy/addons/registry/registry-rc.yaml.tmpl @@ -1,5 +1,5 @@ -apiVersion: v1 -kind: ReplicationController +apiVersion: apps/v1 +kind: Deployment metadata: labels: kubernetes.io/minikube-addons: registry @@ -9,7 +9,9 @@ metadata: spec: replicas: 1 selector: - kubernetes.io/minikube-addons: registry + matchLabels: + kubernetes.io/minikube-addons: registry + addonmanager.kubernetes.io/mode: Reconcile template: metadata: labels: From a90d01cfe6b20254661746dfeeaa77f26965ebdf Mon Sep 17 00:00:00 2001 From: Steven Powell Date: Tue, 16 Jul 2024 18:02:49 -0500 Subject: [PATCH 2/2] fix checking for replica controller --- pkg/kapi/kapi.go | 34 --------------------------------- test/integration/addons_test.go | 4 ++-- 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/pkg/kapi/kapi.go b/pkg/kapi/kapi.go index 2da81dcff6fa..c7f2786017b3 100644 --- a/pkg/kapi/kapi.go +++ b/pkg/kapi/kapi.go @@ -108,40 +108,6 @@ func WaitForPods(c kubernetes.Interface, ns string, selector string, timeOut ... return err } -// WaitForRCToStabilize waits till the RC has a matching generation/replica count between spec and status. used by integration tests -func WaitForRCToStabilize(c kubernetes.Interface, ns, name string, timeout time.Duration) error { - options := meta.ListOptions{FieldSelector: fields.Set{ - "metadata.name": name, - "metadata.namespace": ns, - }.AsSelector().String()} - - ctx, cancel := watchtools.ContextWithOptionalTimeout(context.Background(), timeout) - defer cancel() - - w, err := c.CoreV1().ReplicationControllers(ns).Watch(ctx, options) - if err != nil { - return err - } - _, err = watchtools.UntilWithoutRetry(ctx, w, func(event watch.Event) (bool, error) { - if event.Type == watch.Deleted { - return false, apierr.NewNotFound(schema.GroupResource{Resource: "replicationcontrollers"}, "") - } - - rc, ok := event.Object.(*core.ReplicationController) - if ok { - if rc.Name == name && rc.Namespace == ns && - rc.Generation <= rc.Status.ObservedGeneration && - *(rc.Spec.Replicas) == rc.Status.Replicas { - return true, nil - } - klog.Infof("Waiting for rc %s to stabilize, generation %v observed generation %v spec.replicas %d status.replicas %d", - name, rc.Generation, rc.Status.ObservedGeneration, *(rc.Spec.Replicas), rc.Status.Replicas) - } - return false, nil - }) - return err -} - // WaitForDeploymentToStabilize waits till the Deployment has a matching generation/replica count between spec and status. used by integration tests func WaitForDeploymentToStabilize(c kubernetes.Interface, ns, name string, timeout time.Duration) error { options := meta.ListOptions{FieldSelector: fields.Set{ diff --git a/test/integration/addons_test.go b/test/integration/addons_test.go index f714a434155a..ec3ff2f2a98e 100644 --- a/test/integration/addons_test.go +++ b/test/integration/addons_test.go @@ -326,8 +326,8 @@ func validateRegistryAddon(ctx context.Context, t *testing.T, profile string) { } start := time.Now() - if err := kapi.WaitForRCToStabilize(client, "kube-system", "registry", Minutes(6)); err != nil { - t.Errorf("failed waiting for registry replicacontroller to stabilize: %v", err) + if err := kapi.WaitForDeploymentToStabilize(client, "kube-system", "registry", Minutes(6)); err != nil { + t.Errorf("failed waiting for registry deployment to stabilize: %v", err) } t.Logf("registry stabilized in %s", time.Since(start))