diff --git a/deploy/addons/ambassador/ambassador-operator.yaml b/deploy/addons/ambassador/ambassador-operator.yaml index a6a6babe89e0..a0327a8f2f66 100644 --- a/deploy/addons/ambassador/ambassador-operator.yaml +++ b/deploy/addons/ambassador/ambassador-operator.yaml @@ -166,7 +166,7 @@ spec: containers: - name: ambassador-operator # Replace this with the built image name - image: quay.io/datawire/ambassador-operator:v1.2.3 + image: quay.io/datawire/ambassador-operator:v1.2.8 command: - ambassador-operator imagePullPolicy: Always diff --git a/deploy/addons/ambassador/ambassadorinstallation.yaml b/deploy/addons/ambassador/ambassadorinstallation.yaml index befbf897f20e..29c4f2a728af 100644 --- a/deploy/addons/ambassador/ambassadorinstallation.yaml +++ b/deploy/addons/ambassador/ambassadorinstallation.yaml @@ -7,3 +7,5 @@ spec: installOSS: true helmValues: deploymentTool: amb-oper-minikube + deploymentStrategy: + type: Recreate diff --git a/pkg/minikube/assets/addons.go b/pkg/minikube/assets/addons.go index e557a96b2c28..efe80028043f 100644 --- a/pkg/minikube/assets/addons.go +++ b/pkg/minikube/assets/addons.go @@ -416,7 +416,7 @@ var Addons = map[string]*Addon{ MustBinAsset( "deploy/addons/ambassador/ambassadorinstallation.yaml", vmpath.GuestAddonsDir, - "ambassadorinstallation.yaml.yaml", + "ambassadorinstallation.yaml", "0640", false), }, false, "ambassador"), diff --git a/test/integration/addons_test.go b/test/integration/addons_test.go index e90336b54a0f..c5f03aa61e57 100644 --- a/test/integration/addons_test.go +++ b/test/integration/addons_test.go @@ -40,10 +40,12 @@ func TestAddons(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), Minutes(40)) defer Cleanup(t, profile, cancel) - args := append([]string{"start", "-p", profile, "--wait=false", "--memory=2600", "--alsologtostderr", "--addons=registry", "--addons=metrics-server", "--addons=helm-tiller", "--addons=olm"}, StartArgs()...) - if !NoneDriver() { // none doesn't support ingress + args := append([]string{"start", "-p", profile, "--wait=false", "--memory=2800", "--alsologtostderr", "--addons=ingress", "--addons=registry", "--addons=metrics-server", "--addons=helm-tiller", "--addons=olm", "--addons=ambassador"}, StartArgs()...) + + if !NoneDriver() { // none doesn't support ingress args = append(args, "--addons=ingress") } + rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) if err != nil { t.Fatalf("%s failed: %v", rr.Command(), err) @@ -60,6 +62,7 @@ func TestAddons(t *testing.T) { {"MetricsServer", validateMetricsServerAddon}, {"HelmTiller", validateHelmTillerAddon}, {"Olm", validateOlmAddon}, + {"Ambassador", validateAmbassadorAddon}, } for _, tc := range tests { tc := tc @@ -104,7 +107,7 @@ func validateIngressAddon(ctx context.Context, t *testing.T, profile string) { t.Errorf("failed waiting for ingress-controller deployment to stabilize: %v", err) } if _, err := PodWait(ctx, t, profile, "kube-system", "app.kubernetes.io/name=ingress-nginx", Minutes(12)); err != nil { - t.Fatalf("failed waititing for nginx-ingress-controller : %v", err) + t.Fatalf("failed waiting for nginx-ingress-controller : %v", err) } createIngress := func() error { @@ -164,6 +167,79 @@ func validateIngressAddon(ctx context.Context, t *testing.T, profile string) { } } +func validateAmbassadorAddon(ctx context.Context, t *testing.T, profile string) { + defer PostMortemLogs(t, profile) + + client, err := kapi.Client(profile) + if err != nil { + t.Fatalf("failed to get Kubernetes client: %v", client) + } + + // Let's wait for the operator to come up + if err := kapi.WaitForDeploymentToStabilize(client, "ambassador", "ambassador-operator", Minutes(6)); err != nil { + t.Errorf("failed waiting for ambassador-operator deployment to stabilize: %v", err) + } + + if _, err := PodWait(ctx, t, profile, "ambassador", "getambassador.io/installer=operator", Minutes(12)); err != nil { + t.Errorf("failed waiting for ambassador pods : %v", err) + } + + // Let's wait for the operator to spin up Ambassador pods + if err := kapi.WaitForDeploymentToStabilize(client, "ambassador", "ambassador", Minutes(6)); err != nil { + t.Errorf("failed waiting for ambassador deployment to stabilize: %v", err) + } + + if _, err := PodWait(ctx, t, profile, "ambassador", "app.kubernetes.io/name=ambassador", Minutes(12)); err != nil { + t.Errorf("failed waiting for ambassador pods : %v", err) + } + + // Create echoserver for testing ingress + deploymentName := "hello-minikube" + rrDeployment, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "create", "deployment", deploymentName, "--image=k8s.gcr.io/echoserver:1.4")) + if err != nil { + t.Errorf("failed to create echoserver deployment, args %q. %v", rrDeployment.Command(), err) + } + + rrService, err := Run(t, exec.CommandContext(ctx, "kubectl", "expose", "deployment", deploymentName, "--port=8080")) + if err != nil { + t.Errorf("failed to expose echoserver deployment, args %q. %v", rrService.Command(), err) + } + + if _, err := PodWait(ctx, t, profile, "default", "app=hello-minikube", Minutes(4)); err != nil { + t.Errorf("failed waiting for echoserver pod: %v", err) + } + + // Create an ingress resource + rrIngress, err := Run(t, exec.CommandContext(ctx, "kubectl", "apply", "-f", filepath.Join(*testdataDir, "ambassador-ingress.yaml"))) + if err != nil { + t.Errorf("failed to create ingress, args %q. %v", rrIngress.Command(), err) + } + + checkAmbassadorIngress := func() error { + rrStatus, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "run", "--rm", "ambassador-test", "--restart=Never", "--image=busybox", "-i", "--", "sh", "-c", "wget --spider -S http://ambassador.ambassador.svc.cluster.local/hello/")) + if err != nil { + t.Errorf("failed to hit ambassador.ambassador.svc.cluster.local/hello/, args %q failed: %v", rrStatus.Command(), err) + return err + } + + stderr := rrStatus.Stderr.String() + if stderr != "" { + t.Errorf("debug: unexpected stderr for %v:\n%s", rrStatus.Command(), stderr) + } + + want := "HTTP/1.1 200 OK" + stdout := rrStatus.Stdout.String() + if !strings.Contains(stdout, want) { + t.Errorf("expected curl response be %q, but got *%s*", want, stdout) + } + return nil + } + + if err := retry.Expo(checkAmbassadorIngress, 500*time.Millisecond, Seconds(90)); err != nil { + t.Errorf("failed to get expected response: %v", err) + } +} + func validateRegistryAddon(ctx context.Context, t *testing.T, profile string) { defer PostMortemLogs(t, profile) diff --git a/test/integration/testdata/ambassador-ingress.yaml b/test/integration/testdata/ambassador-ingress.yaml new file mode 100644 index 000000000000..58dd12253788 --- /dev/null +++ b/test/integration/testdata/ambassador-ingress.yaml @@ -0,0 +1,14 @@ +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + annotations: + kubernetes.io/ingress.class: ambassador + name: test-ambassador-ingress +spec: + rules: + - http: + paths: + - path: /hello/ + backend: + serviceName: hello-minikube + servicePort: 8080