diff --git a/deploy/addons/registry/registry-proxy.yaml.tmpl b/deploy/addons/registry/registry-proxy.yaml.tmpl index b5ab736e34..2131be3826 100644 --- a/deploy/addons/registry/registry-proxy.yaml.tmpl +++ b/deploy/addons/registry/registry-proxy.yaml.tmpl @@ -2,7 +2,7 @@ apiVersion: extensions/v1beta1 kind: DaemonSet metadata: labels: - kubernetes.io/minikube-addons: registry + kubernetes.io/minikube-addons: registry-proxy addonmanager.kubernetes.io/mode: Reconcile name: registry-proxy namespace: kube-system @@ -10,6 +10,7 @@ spec: template: metadata: labels: + kubernetes.io/minikube-addons: registry-proxy addonmanager.kubernetes.io/mode: Reconcile spec: containers: diff --git a/test/integration/addons_test.go b/test/integration/addons_test.go index 85b56a1c71..629401cf83 100644 --- a/test/integration/addons_test.go +++ b/test/integration/addons_test.go @@ -190,7 +190,57 @@ func testServicesList(t *testing.T) { t.Fatalf(err.Error()) } } +func testRegistry(t *testing.T) { + t.Parallel() + minikubeRunner := NewMinikubeRunner(t) + kubectlRunner := util.NewKubectlRunner(t) + minikubeRunner.RunCommand("addons enable registry", true) + t.Log("wait for registry to come up") + if err := util.WaitForDockerRegistryRunning(t); err != nil { + t.Fatalf("waiting for registry to be up: %v", err) + } + + // Check access from outside the cluster on port 5000, validing connectivity via registry-proxy + checkExternalAccess := func() error { + t.Log("checking registry access from outside cluster") + expectedStr := "200" + runCmd := fmt.Sprintf("curl -sS -o /dev/null -w '%%{http_code}' http://127.0.0.1:5000") + externalCheckOutput, _ := minikubeRunner.SSH(runCmd) + if !strings.Contains(externalCheckOutput, expectedStr) { + return fmt.Errorf("ExpectedStr externalCheckOutput to be: %s. Output was: %s", expectedStr, externalCheckOutput) + } + return nil + } + + if err := util.Retry(t, checkExternalAccess, 2*time.Second, 5); err != nil { + t.Fatalf(err.Error()) + } + // check access from inside the cluster via a busybox container running inside cluster + t.Log("checking registry access from inside cluster") + expectedStr := "200" + out, _ := kubectlRunner.RunCommand([]string{ + "run", + "registry-test", + "--restart=Never", + "--image=busybox", + "-it", + "--", + "sh", + "-c", + "wget --spider -S 'http://registry.kube-system.svc.cluster.local' 2>&1 | grep 'HTTP/' | awk '{print $2}'"}) + internalCheckOutput := string(out) + if !strings.Contains(internalCheckOutput, expectedStr) { + t.Fatalf("ExpectedStr internalCheckOutput to be: %s. Output was: %s", expectedStr, internalCheckOutput) + } + + defer func() { + if _, err := kubectlRunner.RunCommand([]string{"delete", "pod", "registry-test"}); err != nil { + t.Fatalf("failed to delete pod registry-test") + } + }() + minikubeRunner.RunCommand("addons disable registry", true) +} func testGvisor(t *testing.T) { minikubeRunner := NewMinikubeRunner(t) minikubeRunner.RunCommand("addons enable gvisor", true) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index a8ced7a510..5186eae177 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -36,6 +36,7 @@ func TestFunctional(t *testing.T) { t.Run("DNS", testClusterDNS) t.Run("Logs", testClusterLogs) t.Run("Addons", testAddons) + t.Run("Registry", testRegistry) t.Run("Dashboard", testDashboard) t.Run("ServicesList", testServicesList) t.Run("Provisioning", testProvisioning) diff --git a/test/integration/util/util.go b/test/integration/util/util.go index 08e1cebb27..056928b6cb 100644 --- a/test/integration/util/util.go +++ b/test/integration/util/util.go @@ -359,6 +359,28 @@ func WaitForIngressControllerRunning(t *testing.T) error { return nil } +// WaitForDockerRegistryRunning waits until docker registry pod to be running +func WaitForDockerRegistryRunning(t *testing.T) error { + client, err := commonutil.GetClient() + if err != nil { + return errors.Wrap(err, "getting kubernetes client") + } + + if err := commonutil.WaitForRCToStabilize(client, "kube-system", "registry", time.Minute*10); err != nil { + return errors.Wrap(err, "waiting for registry replicacontroller to stabilize") + } + + registrySelector := labels.SelectorFromSet(labels.Set(map[string]string{"kubernetes.io/minikube-addons": "registry"})) + if err := commonutil.WaitForPodsWithLabelRunning(client, "kube-system", registrySelector); err != nil { + return errors.Wrap(err, "waiting for registry pods") + } + proxySelector := labels.SelectorFromSet(labels.Set(map[string]string{"kubernetes.io/minikube-addons": "registry-proxy"})) + if err := commonutil.WaitForPodsWithLabelRunning(client, "kube-system", proxySelector); err != nil { + return errors.Wrap(err, "waiting for registry-proxy pods") + } + return nil +} + // WaitForIngressDefaultBackendRunning waits until ingress default backend pod to be running func WaitForIngressDefaultBackendRunning(t *testing.T) error { client, err := commonutil.GetClient()