diff --git a/.changelog/187.txt b/.changelog/187.txt new file mode 100644 index 000000000..8a758c791 --- /dev/null +++ b/.changelog/187.txt @@ -0,0 +1,3 @@ +```release-note:bug +k8s/reconciler: gateway addresses have invalid empty string when LoadBalancer services use a hostname for ExternalIP (like EKS) +``` diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 09ba41ff9..8a25bac31 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -116,3 +116,5 @@ jobs: arch: ${{matrix.arch}} tags: | docker.io/hashicorp/${{env.repo}}:${{env.version}} + dev_tags: | + docker.io/hashicorppreview/${{env.repo}}:${{env.version}} diff --git a/.release/ci.hcl b/.release/ci.hcl index 81628d17c..2cd172c97 100644 --- a/.release/ci.hcl +++ b/.release/ci.hcl @@ -94,6 +94,20 @@ event "verify" { } } +event "promote-dev-docker" { + depends = ["verify"] + action "promote-dev-docker" { + organization = "hashicorp" + repository = "crt-workflows-common" + workflow = "promote-dev-docker" + depends = ["verify"] + } + + notification { + on = "fail" + } +} + ## These are promotion and post-publish events ## they should be added to the end of the file after the verify event stanza. diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f896af13..7c5410ce0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ ## UNRELEASED +IMPROVEMENTS: + +* go: build with Go 1.18 [[GH-167](https://github.com/hashicorp/consul-api-gateway/issues/167)] + +BUG FIXES: + +* k8s/reconciler: gateway addresses have invalid empty string when LoadBalancer services use a hostname for ExternalIP (like EKS) [[GH-187](https://github.com/hashicorp/consul-api-gateway/issues/187)] + ## 0.2.0 (April 27, 2022) BREAKING CHANGES: diff --git a/config/deployment/deployment.yaml b/config/deployment/deployment.yaml index ab57079da..265f1cfd9 100644 --- a/config/deployment/deployment.yaml +++ b/config/deployment/deployment.yaml @@ -20,7 +20,7 @@ spec: spec: serviceAccountName: consul-api-gateway-controller containers: - - image: hashicorp/consul-api-gateway:0.2.0 + - image: hashicorp/consul-api-gateway:0.2.1 command: ["consul-api-gateway", "server", "-consul-address", "$(HOST_IP):8501", "-ca-file", "/ca/tls.crt", "-sds-server-host", "$(IP)", "-k8s-namespace", "$(CONSUL_K8S_NAMESPACE)", "-log-level", "$(LOG_LEVEL)"] name: consul-api-gateway-controller ports: diff --git a/dev/docs/example-setup.md b/dev/docs/example-setup.md index e38064d1f..48dea6f8a 100644 --- a/dev/docs/example-setup.md +++ b/dev/docs/example-setup.md @@ -72,8 +72,8 @@ We have provided a set of `kustomize` manifests for installing the Consul API Ga Apply them to your cluster using the following commands. ```bash -kubectl apply -k "github.com/hashicorp/consul-api-gateway/config/crd?ref=v0.2.0" -kubectl apply -k "github.com/hashicorp/consul-api-gateway/config?ref=v0.2.0" +kubectl apply -k "github.com/hashicorp/consul-api-gateway/config/crd?ref=v0.2.1" +kubectl apply -k "github.com/hashicorp/consul-api-gateway/config?ref=v0.2.1" ``` ## Installing the demo Gateway and Mesh Service @@ -116,7 +116,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- github.com/hashicorp/consul-api-gateway/config/example?ref=v0.2.0 +- github.com/hashicorp/consul-api-gateway/config/example?ref=v0.2.1 patches: - target: diff --git a/internal/k8s/builder/testdata/clusterip.deployment.golden.yaml b/internal/k8s/builder/testdata/clusterip.deployment.golden.yaml index 7dce2c3fc..0ab2ee669 100644 --- a/internal/k8s/builder/testdata/clusterip.deployment.golden.yaml +++ b/internal/k8s/builder/testdata/clusterip.deployment.golden.yaml @@ -79,7 +79,7 @@ spec: - cp - /bin/consul-api-gateway - /bootstrap/consul-api-gateway - image: hashicorp/consul-api-gateway:0.2.0 + image: hashicorp/consul-api-gateway:0.2.1 name: consul-api-gateway-init resources: {} volumeMounts: diff --git a/internal/k8s/builder/testdata/loadbalancer.deployment.golden.yaml b/internal/k8s/builder/testdata/loadbalancer.deployment.golden.yaml index 3f95ab414..b466b8233 100644 --- a/internal/k8s/builder/testdata/loadbalancer.deployment.golden.yaml +++ b/internal/k8s/builder/testdata/loadbalancer.deployment.golden.yaml @@ -79,7 +79,7 @@ spec: - cp - /bin/consul-api-gateway - /bootstrap/consul-api-gateway - image: hashicorp/consul-api-gateway:0.2.0 + image: hashicorp/consul-api-gateway:0.2.1 name: consul-api-gateway-init resources: {} volumeMounts: diff --git a/internal/k8s/builder/testdata/static-mapping.deployment.golden.yaml b/internal/k8s/builder/testdata/static-mapping.deployment.golden.yaml index cc9979351..45be6ee36 100644 --- a/internal/k8s/builder/testdata/static-mapping.deployment.golden.yaml +++ b/internal/k8s/builder/testdata/static-mapping.deployment.golden.yaml @@ -82,7 +82,7 @@ spec: - cp - /bin/consul-api-gateway - /bootstrap/consul-api-gateway - image: hashicorp/consul-api-gateway:0.2.0 + image: hashicorp/consul-api-gateway:0.2.1 name: consul-api-gateway-init resources: {} volumeMounts: diff --git a/internal/k8s/builder/testdata/tls-cert.deployment.golden.yaml b/internal/k8s/builder/testdata/tls-cert.deployment.golden.yaml index 8a6574c1e..1739e0ea7 100644 --- a/internal/k8s/builder/testdata/tls-cert.deployment.golden.yaml +++ b/internal/k8s/builder/testdata/tls-cert.deployment.golden.yaml @@ -82,7 +82,7 @@ spec: - cp - /bin/consul-api-gateway - /bootstrap/consul-api-gateway - image: hashicorp/consul-api-gateway:0.2.0 + image: hashicorp/consul-api-gateway:0.2.1 name: consul-api-gateway-init resources: {} volumeMounts: diff --git a/internal/k8s/controller.go b/internal/k8s/controller.go index 28a8016fc..4f97ea46b 100644 --- a/internal/k8s/controller.go +++ b/internal/k8s/controller.go @@ -200,6 +200,7 @@ func (k *Kubernetes) Start(ctx context.Context) error { } err = (&controllers.TCPRouteReconciler{ + Context: ctx, Client: gwClient, Log: k.logger.Named("TCPRoute"), Manager: reconcileManager, diff --git a/internal/k8s/reconciler/gateway.go b/internal/k8s/reconciler/gateway.go index baf242104..0b81fbcfb 100644 --- a/internal/k8s/reconciler/gateway.go +++ b/internal/k8s/reconciler/gateway.go @@ -187,8 +187,14 @@ func (g *K8sGateway) assignGatewayIPFromServiceIngress(ctx context.Context, serv } for _, ingress := range updated.Status.LoadBalancer.Ingress { - g.serviceReady = true - g.addresses = append(g.addresses, ingress.IP) + if ingress.IP != "" { + g.serviceReady = true + g.addresses = append(g.addresses, ingress.IP) + } + if ingress.Hostname != "" { + g.serviceReady = true + g.addresses = append(g.addresses, ingress.Hostname) + } } return nil diff --git a/internal/k8s/reconciler/gateway_test.go b/internal/k8s/reconciler/gateway_test.go index b651b10c8..825dd2b1e 100644 --- a/internal/k8s/reconciler/gateway_test.go +++ b/internal/k8s/reconciler/gateway_test.go @@ -103,6 +103,9 @@ func TestGatewayValidateGatewayIP(t *testing.T) { { IP: "4.4.4.4", }, + { + Hostname: "this.is.a.hostname", + }, }, }, }, @@ -110,7 +113,7 @@ func TestGatewayValidateGatewayIP(t *testing.T) { for _, tc := range []struct { // What IP address do we expect the Gateway to be assigned? - expectedIP string + expectedIPs []string // Should the mock client expect a request for the Service? // If false, the mock client expects a request for the Pod instead. @@ -120,22 +123,22 @@ func TestGatewayValidateGatewayIP(t *testing.T) { serviceType *core.ServiceType }{ { - expectedIP: pod.Status.PodIP, + expectedIPs: []string{pod.Status.PodIP}, expectedIPFromSvc: false, serviceType: nil, }, { - expectedIP: pod.Status.HostIP, + expectedIPs: []string{pod.Status.HostIP}, expectedIPFromSvc: false, serviceType: serviceType(core.ServiceTypeNodePort), }, { - expectedIP: svc.Status.LoadBalancer.Ingress[0].IP, + expectedIPs: []string{svc.Status.LoadBalancer.Ingress[0].IP, svc.Status.LoadBalancer.Ingress[1].Hostname}, expectedIPFromSvc: true, serviceType: serviceType(core.ServiceTypeLoadBalancer), }, { - expectedIP: svc.Spec.ClusterIP, + expectedIPs: []string{svc.Spec.ClusterIP}, expectedIPFromSvc: true, serviceType: serviceType(core.ServiceTypeClusterIP), }, @@ -163,8 +166,8 @@ func TestGatewayValidateGatewayIP(t *testing.T) { } assert.NoError(t, gateway.validateGatewayIP(context.Background())) - require.Len(t, gateway.addresses, 1) - assert.Equal(t, tc.expectedIP, gateway.addresses[0]) + require.Len(t, gateway.addresses, len(tc.expectedIPs)) + assert.Equal(t, tc.expectedIPs, gateway.addresses) assert.True(t, gateway.serviceReady) }) diff --git a/internal/testing/conformance/consul-config.yaml b/internal/testing/conformance/consul-config.yaml index 83acb2864..7a7903547 100644 --- a/internal/testing/conformance/consul-config.yaml +++ b/internal/testing/conformance/consul-config.yaml @@ -1,5 +1,4 @@ global: - image: "hashicorp/consul:1.12.0" # TODO Remove once 1.12.0 is consumed in consul-k8s tls: enabled: true server: diff --git a/internal/version/version.go b/internal/version/version.go index 063c4d26e..826d4df8a 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -14,7 +14,7 @@ var ( // // Version must conform to the format expected by // github.com/hashicorp/go-version for tests to work. - Version = "0.2.0" + Version = "0.2.1" // A pre-release marker for the version. If this is "" (empty string) // then it means that it is a final release. Otherwise, this is a pre-release