Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #189 from hashicorp/stage-release-to-0.2.x
Browse files Browse the repository at this point in the history
Stage release to 0.2.x
  • Loading branch information
nickethier authored Apr 29, 2022
2 parents 2345c66 + e47da87 commit 0410a0d
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .changelog/187.txt
Original file line number Diff line number Diff line change
@@ -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)
```
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion config/deployment/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions dev/docs/example-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 8 additions & 2 deletions internal/k8s/reconciler/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 10 additions & 7 deletions internal/k8s/reconciler/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,17 @@ func TestGatewayValidateGatewayIP(t *testing.T) {
{
IP: "4.4.4.4",
},
{
Hostname: "this.is.a.hostname",
},
},
},
},
}

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.
Expand All @@ -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),
},
Expand Down Expand Up @@ -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)
})
Expand Down
1 change: 0 additions & 1 deletion internal/testing/conformance/consul-config.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion internal/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0410a0d

Please sign in to comment.