Ensures Envoy ClusterIP is parameterized consistently

Signed-off-by: irbekrm <irbekrm@gmail.com>
This commit is contained in:
irbekrm 2022-05-10 11:32:39 +01:00
parent 66aef8d582
commit 6cb826833e
7 changed files with 62 additions and 78 deletions

View File

@ -1,20 +1,13 @@
# This file is generated from the individual YAML files by generate-gateway-deployment.sh. Do not
# edit this file directly but instead edit the source files and re-render.
#
# Generated from:
# examples/contour/00-common.yaml
# examples/contour/01-contour-config.yaml
# examples/contour/01-crds.yaml
# examples/contour/02-job-certgen.yaml
# examples/contour/02-rbac.yaml
# examples/contour/02-role-contour.yaml
# examples/contour/02-service-contour.yaml
# examples/contour/02-service-envoy.yaml
# examples/contour/03-contour.yaml
# examples/contour/03-envoy.yaml
# examples/gateway/00-crds.yaml
# examples/gateway/01-gatewayclass.yaml
# examples/gateway/02-gateway.yaml
#! This file comes from https://github.com/projectcontour/contour/blob/v1.20.1/examples/render/contour-gateway.yaml
#! with a few changes:
#! - envoyService's type changed LoadBalancer -> ClusterIP and externalTrafficPolicy removed
#! - envoyService's ClusterIP's value parameterized (ytt)
#! - some ytt related changes (load("@ytt:data", "data") to load ytt data schema, comment format changed # -> #!
#! - confusing comments regarding file's origin removed
#! - Deployment replicas changed 2 -> 1
#! - Gateway and GatewayClass resources removed
#@ load("@ytt:data", "data")
---
apiVersion: v1
@ -4893,10 +4886,6 @@ subjects:
name: contour
namespace: projectcontour
# The following ClusterRole is generated from kubebuilder RBAC tags by
# generate-rbac.sh. Do not edit this file directly but instead edit the source
# files and re-render.
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
@ -5034,7 +5023,7 @@ spec:
selector:
app: envoy
type: ClusterIP
clusterIP: 10.0.0.14
clusterIP: #@ data.values.gateway_ip
---
apiVersion: apps/v1
@ -5049,8 +5038,8 @@ spec:
strategy:
type: RollingUpdate
rollingUpdate:
# This value of maxSurge means that during a rolling update
# the new ReplicaSet will be created first.
#! This value of maxSurge means that during a rolling update
#! the new ReplicaSet will be created first.
maxSurge: 50%
selector:
matchLabels:

View File

@ -0,0 +1,21 @@
kind: GatewayClass
apiVersion: gateway.networking.k8s.io/v1alpha2
metadata:
name: acmesolver
spec:
controllerName: projectcontour.io/projectcontour/contour
---
kind: Gateway
apiVersion: gateway.networking.k8s.io/v1alpha2
metadata:
name: acmesolver
namespace: projectcontour
spec:
gatewayClassName: acmesolver
listeners:
- name: http
protocol: HTTP
port: 80
allowedRoutes:
namespaces:
from: All

View File

@ -23,32 +23,14 @@ set -o pipefail
SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
source "${SCRIPT_ROOT}/../../lib/lib.sh"
# Ensure ytt is available
bazel build //hack/bin:ytt
bindir="$(bazel info bazel-bin)"
export PATH="${bindir}/hack/bin/:$PATH"
check_tool kubectl
check_tool ytt
kubectl apply -f "${SCRIPT_ROOT}/contour-gateway.yaml"
cat <<EOYAML | kubectl apply -f -
---
kind: GatewayClass
apiVersion: gateway.networking.k8s.io/v1alpha2
metadata:
name: acmesolver
spec:
controllerName: projectcontour.io/projectcontour/contour
---
kind: Gateway
apiVersion: gateway.networking.k8s.io/v1alpha2
metadata:
name: acmesolver
namespace: projectcontour
spec:
gatewayClassName: acmesolver
listeners:
- name: http
protocol: HTTP
port: 80
allowedRoutes:
namespaces:
from: All
EOYAML
ytt --data-value gateway_ip="${GATEWAY_IP}" \
--file "${SCRIPT_ROOT}/contour-gateway.yaml" \
--file "${SCRIPT_ROOT}/gateway-resources.yaml" | kubectl apply -f -

View File

@ -34,6 +34,7 @@ export OPENSHIFT_VERSION="${OPENSHIFT_VERSION:-"3.11"}"
export SERVICE_IP_PREFIX="${SERVICE_IP_PREFIX:-10.0.0}"
export DNS_SERVER="${SERVICE_IP_PREFIX}.16"
export INGRESS_IP="${SERVICE_IP_PREFIX}.15"
export GATEWAY_IP="${SERVICE_IP_PREFIX}.14"
# setup_tools will build and set up the environment to use bazel-provided
# versions of the tools required for development

View File

@ -71,6 +71,7 @@ ginkgo -nodes 10 -flakeAttempts ${FLAKE_ATTEMPTS:-1} \
--report-dir="${ARTIFACTS:-$REPO_ROOT/_artifacts}" \
--acme-dns-server="$DNS_SERVER" \
--acme-ingress-ip="$INGRESS_IP" \
--acme-gateway-ip="${GATEWAY_IP}" \
--feature-gates="${FEATURE_GATES}" \
${GINKGO_SKIP:+"$GINKGO_SKIP"} \
${GINKGO_FOCUS:+"$GINKGO_FOCUS"} \

View File

@ -1,20 +1,13 @@
# This file is generated from the individual YAML files by generate-gateway-deployment.sh. Do not
# edit this file directly but instead edit the source files and re-render.
#
# Generated from:
# examples/contour/00-common.yaml
# examples/contour/01-contour-config.yaml
# examples/contour/01-crds.yaml
# examples/contour/02-job-certgen.yaml
# examples/contour/02-rbac.yaml
# examples/contour/02-role-contour.yaml
# examples/contour/02-service-contour.yaml
# examples/contour/02-service-envoy.yaml
# examples/contour/03-contour.yaml
# examples/contour/03-envoy.yaml
# examples/gateway/00-crds.yaml
# examples/gateway/01-gatewayclass.yaml
# examples/gateway/02-gateway.yaml
#! This file comes from https://github.com/projectcontour/contour/blob/v1.20.1/examples/render/contour-gateway.yaml
#! with a few changes:
#! - envoyService's type changed LoadBalancer -> ClusterIP and externalTrafficPolicy removed
#! - envoyService's ClusterIP's value parameterized (ytt)
#! - some ytt related changes (load("@ytt:data", "data") to load ytt data schema, comment format changed # -> #!
#! - confusing comments regarding file's origin removed
#! - Deployment replicas changed 2 -> 1
#! - Gateway and GatewayClass resources removed
#@ load("@ytt:data", "data")
---
apiVersion: v1
@ -4893,10 +4886,6 @@ subjects:
name: contour
namespace: projectcontour
# The following ClusterRole is generated from kubebuilder RBAC tags by
# generate-rbac.sh. Do not edit this file directly but instead edit the source
# files and re-render.
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
@ -5034,7 +5023,7 @@ spec:
selector:
app: envoy
type: ClusterIP
clusterIP: {CLUSTER_IP}
clusterIP: #@ data.values.service_ip_prefix + ".14"
---
apiVersion: apps/v1
@ -5049,8 +5038,8 @@ spec:
strategy:
type: RollingUpdate
rollingUpdate:
# This value of maxSurge means that during a rolling update
# the new ReplicaSet will be created first.
#! This value of maxSurge means that during a rolling update
#! the new ReplicaSet will be created first.
maxSurge: 50%
selector:
matchLabels:

View File

@ -374,10 +374,11 @@ e2e-setup-samplewebhook: load-bin/downloaded/containers/$(CRI_ARCH)/samplewebhoo
samplewebhook make/config/samplewebhook/chart >/dev/null
.PHONY: e2e-setup-projectcontour
e2e-setup-projectcontour: load-$(call image-tar,projectcontour) make/config/projectcontour/contour-gateway.yaml make/config/projectcontour/gateway.yaml bin/scratch/kind-exists bin/tools/kubectl
e2e-setup-projectcontour: load-$(call image-tar,projectcontour) make/config/projectcontour/contour-gateway.yaml make/config/projectcontour/gateway.yaml bin/scratch/kind-exists bin/tools/kubectl bin/tools/ytt
@$(eval SERVICE_IP_PREFIX = $(shell bin/tools/kubectl cluster-info dump | grep -m1 ip-range | cut -d= -f2 | cut -d. -f1,2,3))
sed 's|{CLUSTER_IP}|$(SERVICE_IP_PREFIX).14|' make/config/projectcontour/contour-gateway.yaml | bin/tools/kubectl apply -f- >/dev/null
bin/tools/kubectl apply -f make/config/projectcontour/gateway.yaml >/dev/null
bin/tools/ytt --data-value service_ip_prefix="${SERVICE_IP_PREFIX}" \
--file make/config/projectcontour/contour-gateway.yaml \
--file make/config/projectcontour/gateway.yaml | bin/tools/kubectl apply -f-
.PHONY: e2e-setup-sampleexternalissuer
ifeq ($(CRI_ARCH),amd64)