Repository: envoyproxy/gateway
Pull request #300 (2022-08-30 23:54:51)

Adds Make Target to Generate Release Manifests
Adds a Make target to generate:

1. The Kube manifests to run EG.
2. The Gateway API manifests that are supported by the EG release.

This will support
```
kubectl apply -f https://github.com/envoyproxy/gateway/releases/download/${ENVOY_GATEWAY_RELEASE_TAG}/gatewayapi-crds.yaml
kubectl apply -f https://github.com/envoyproxy/gateway/releases/download/${ENVOY_GATEWAY_RELEASE_TAG}/install.yaml
```

xref: https://github.com/envoyproxy/gateway/issues/296
xref: https://github.com/envoyproxy/gateway/pull/298
xref: https://github.com/envoyproxy/gateway/issues/297

Signed-off-by: danehans <daneyonhansen@gmail.com>

danehans: cc: @arkodg @AliceProxy @Xunzhuo 
codecov-commenter: # [Codecov](https://codecov.io/gh/envoyproxy/gateway/pull/300?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) Report
> Merging [#300](https://codecov.io/gh/envoyproxy/gateway/pull/300?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (6c24fe8) into [main](https://codecov.io/gh/envoyproxy/gateway/commit/bca9c19ba6205891eade2e66cc0b0ae9f4388802?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (bca9c19) will **decrease** coverage by `0.28%`.
> The diff coverage is `n/a`.

```diff
@@            Coverage Diff             @@
##             main     #300      +/-   ##
==========================================
- Coverage   58.44%   58.16%   -0.29%     
==========================================
  Files          31       31              
  Lines        2835     2835              
==========================================
- Hits         1657     1649       -8     
- Misses       1080     1087       +7     
- Partials       98       99       +1     
```


| [Impacted Files](https://codecov.io/gh/envoyproxy/gateway/pull/300?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | |
|---|---|---|
| [internal/provider/kubernetes/gateway.go](https://codecov.io/gh/envoyproxy/gateway/pull/300/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-aW50ZXJuYWwvcHJvdmlkZXIva3ViZXJuZXRlcy9nYXRld2F5Lmdv) | `77.04% <0.00%> (-6.56%)` | :arrow_down: |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None)

danehans: @arkodg @Xunzhuo i just remembered that the script for this target needs to replace the "gateway-dev" image with "gateway".
Xunzhuo: When releasing an image, we use gateway instead of gateway-dev, right?

arkodg: > When releasing an image, we use gateway instead of gateway-dev, right?

Yeah
arkodg: from the kubebuilder docs, it looks like it supports the `IMG` env https://book.kubebuilder.io/cronjob-tutorial/running.html, unsure if it works or not with all our mods
Xunzhuo: I think if nothing is blocking this PR, we need to merge this first, the release workflow should require this PR.

Patch:
diff --git a/.gitignore b/.gitignore
index 32422d3e1..7dec41b6f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,6 @@ bin/
 
 # Visual Studio Code
 .vscode/
+
+# Release artifacts
+release-artifacts/
diff --git a/internal/gatewayapi/translator.go b/internal/gatewayapi/translator.go
index 53c4bc649..c0ee2e7a6 100644
--- a/internal/gatewayapi/translator.go
+++ b/internal/gatewayapi/translator.go
@@ -428,6 +428,11 @@ func (t *Translator) ProcessListeners(gateways []*GatewayContext, xdsIR *ir.Xds,
 			}
 			if listener.Hostname != nil {
 				irListener.Hostnames = append(irListener.Hostnames, string(*listener.Hostname))
+			} else {
+				// Hostname specifies the virtual hostname to match for protocol types that define this concept.
+				// When unspecified, all hostnames are matched. This field is ignored for protocols that don’t require hostname based matching.
+				// see more https://gateway-api.sigs.k8s.io/references/spec/#gateway.networking.k8s.io/v1beta1.Listener.
+				irListener.Hostnames = append(irListener.Hostnames, "*")
 			}
 			xdsIR.HTTP = append(xdsIR.HTTP, irListener)
 
@@ -692,9 +697,6 @@ func (t *Translator) ProcessHTTPRoutes(httpRoutes []*v1beta1.HTTPRoute, gateways
 				}
 
 				irListener := xdsIR.GetListener(irListenerName(listener))
-				if len(irListener.Hostnames) == 0 {
-					irListener.Hostnames = hosts
-				}
 				irListener.Routes = append(irListener.Routes, perHostRoutes...)
 
 				// Theoretically there should only be one parent ref per
diff --git a/tools/hack/kind-load-image.sh b/tools/hack/kind-load-image.sh
index f58abddce..6645c69aa 100755
--- a/tools/hack/kind-load-image.sh
+++ b/tools/hack/kind-load-image.sh
@@ -13,11 +13,13 @@ readonly TAG="$2"
 
 # Wrap sed to deal with GNU and BSD sed flags.
 run::sed() {
-    local -r vers="$(sed --version < /dev/null 2>&1 | grep -q GNU && echo gnu || echo bsd)"
-    case "$vers" in
-        gnu) sed -i "$@" ;;
-        *) sed -i '' "$@" ;;
-    esac
+  if sed --version </dev/null 2>&1 | grep -q GNU; then
+    # GNU sed
+    sed -i "$@"
+  else
+    # assume BSD sed
+    sed -i '' "$@"
+  fi
 }
 
 kind::cluster::exists() {
diff --git a/tools/hack/release-manifests.sh b/tools/hack/release-manifests.sh
new file mode 100755
index 000000000..32f509a77
--- /dev/null
+++ b/tools/hack/release-manifests.sh
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+readonly KUSTOMIZE=${KUSTOMIZE:-tools/bin/kustomize}
+readonly GATEWAY_API_VERSION="$1"
+readonly TAG="[[ $# == 2 ]]"
+
+mkdir -p release-artifacts/
+
+# Wrap sed to deal with GNU and BSD sed flags.
+run::sed() {
+  if sed --version </dev/null 2>&1 | grep -q GNU; then
+    # GNU sed
+    sed -i "$@"
+  else
+    # assume BSD sed
+    sed -i '' "$@"
+  fi
+}
+
+# Download the supported Gateway API CRDs that will be supported by the release.
+curl -sLo release-artifacts/gatewayapi-crds.yaml https://github.com/kubernetes-sigs/gateway-api/releases/download/"${GATEWAY_API_VERSION}"/experimental-install.yaml
+
+echo "Added:" release-artifacts/gatewayapi-crds.yaml
+
+# Generate the envoy gateway installation manifest supported by the release.
+${KUSTOMIZE} build internal/provider/kubernetes/config/default > release-artifacts/install.yaml
+
+echo "Generated:" release-artifacts/install.yaml
+
+# Update the image in the Envoy Gateway deployment manifest.
+run::sed \
+  "-es|image: envoyproxy/gateway-dev:.*$|image: envoyproxy/gateway:${TAG}|" \
+  "release-artifacts/install.yaml"
+
+echo "Updated the envoy gateway image:" release-artifacts/install.yaml
diff --git a/tools/make/kube.mk b/tools/make/kube.mk
index 3858f3fe9..25c520ee2 100644
--- a/tools/make/kube.mk
+++ b/tools/make/kube.mk
@@ -66,3 +66,7 @@ run-conformance: ## Run Gateway API conformance.
 .PHONY: delete-cluster
 delete-cluster: $(tools/kind) ## Delete kind cluster.
 	$(tools/kind) delete cluster --name envoy-gateway
+
+.PHONY: release-manifests
+release-manifests: $(tools/kustomize)
+	tools/hack/release-manifests.sh $(GATEWAY_API_VERSION) $(VERSION)


Test patch:
diff --git a/internal/gatewayapi/testdata/gateway-allows-same-namespace-with-disallowed-httproute.out.yaml b/internal/gatewayapi/testdata/gateway-allows-same-namespace-with-disallowed-httproute.out.yaml
index 3d0b7588b..2926aea16 100644
--- a/internal/gatewayapi/testdata/gateway-allows-same-namespace-with-disallowed-httproute.out.yaml
+++ b/internal/gatewayapi/testdata/gateway-allows-same-namespace-with-disallowed-httproute.out.yaml
@@ -57,6 +57,8 @@ xdsIR:
   http:
     - name: envoy-gateway-gateway-1-http
       address: 0.0.0.0
+      hostnames:
+      - "*"
       port: 80
 infraIR:
   proxy: