Skip to content

Commit

Permalink
simplify net-gateway-api install
Browse files Browse the repository at this point in the history
- we can reuse net-istio's third_party istio install yaml
- use the gateway api crds in third_party - the prior download url didn't work
  • Loading branch information
dprotaso committed Dec 3, 2021
1 parent 50e4b64 commit c68cb55
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 23 deletions.
22 changes: 6 additions & 16 deletions test/e2e-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,9 @@ function knative_setup() {
fi
fi

# Install gateway-api and istio. Gateway API CRD must be installed before Istio.
# Install gateway-api and istio. Gateway API CRD must be installed before Istio.
if is_ingress_class gateway-api; then
# TODO: Do not use fixed Gateway API version and Istio version.
kubectl apply -k 'github.com/kubernetes-sigs/gateway-api/config/crd?ref=v0.3.0'
export ISTIO_VERSION=1.11.4 && curl -sL https://istio.io/downloadIstioctl | sh -
if (( KIND )); then
$HOME/.istioctl/bin/istioctl install -y --set values.gateways.istio-ingressgateway.type=NodePort --set values.global.proxy.clusterDomain="${CLUSTER_DOMAIN}"
else
$HOME/.istioctl/bin/istioctl install -y --set values.global.proxy.clusterDomain="${CLUSTER_DOMAIN}"
fi
stage_gateway_api_resources
fi

stage_test_resources
Expand Down Expand Up @@ -265,8 +258,11 @@ function install() {
)

if is_ingress_class istio; then
# Istio - see cluster_setup for how the files are staged
# We use the staged net-istio file since we can install different versions
YTT_FILES+=("${E2E_YAML_DIR}/istio/${ingress_version}/install")
elif is_ingress_class gateway-api; then
YTT_FILES+=("${E2E_YAML_DIR}/gateway-api/${ingress_version}/install")
YTT_FILES+=("${REPO_ROOT_DIR}/third_party/${ingress}-latest")
else
YTT_FILES+=("${REPO_ROOT_DIR}/third_party/${ingress}-latest")
fi
Expand Down Expand Up @@ -339,12 +335,6 @@ function install() {
# kubectl -n ${SYSTEM_NAMESPACE} delete leases --all
wait_for_leader_controller || return 1
fi

# Due to https://github.com/vmware-tanzu/carvel-kapp/issues/381, deploy svc by kubectl instead of kapp.
if is_ingress_class gateway-api; then
kubectl delete -f ${REPO_ROOT_DIR}/third_party/gateway-api-latest/istio-gateway.yaml
kubectl apply -f ${REPO_ROOT_DIR}/third_party/gateway-api-latest/istio-gateway.yaml
fi
}

# Check if we should use --resolvabledomain. In case the ingress only has
Expand Down
35 changes: 28 additions & 7 deletions test/e2e-networking-library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,37 @@ function is_ingress_class() {
[[ "${INGRESS_CLASS}" == *"${1}"* ]]
}

function stage_gateway_api_resources() {
header "Staging Gateway API Resources"

local gateway_dir="${E2E_YAML_DIR}/gateway-api/install"
mkdir -p "${gateway_dir}"

# TODO: if we switch to istio 1.12 we can reuse stage_istio_head
curl -sL https://istio.io/downloadIstioctl | ISTIO_VERSION=1.11.4 sh -

local params="--set values.global.proxy.clusterDomain=\"${CLUSTER_DOMAIN}\""

if (( KIND )); then
params="${params} --set values.gateways.istio-ingressgateway.type=NodePort"
fi

$HOME/.istioctl/bin/istioctl manifest generate $params > "${gateway_dir}/istio.yaml"
}

function stage_istio_head() {
header "Staging Istio YAML (HEAD)"
local istio_head_dir="${E2E_YAML_DIR}/istio/HEAD/install"
local net_istio_head_dir="${E2E_YAML_DIR}/net-istio/HEAD/install"
mkdir -p "${istio_head_dir}"
download_net_istio_yamls "${REPO_ROOT_DIR}/third_party/istio-latest/net-istio.yaml" "${istio_head_dir}"
download_net_istio_yamls "${REPO_ROOT_DIR}/third_party/istio-latest/net-istio.yaml" \
"${istio_head_dir}" \
}

function stage_istio_latest() {
header "Staging Istio YAML (${LATEST_NET_ISTIO_RELEASE_VERSION})"
local istio_latest_dir="${E2E_YAML_DIR}/istio/latest-release/install"
local net_istio_latest_dir="${E2E_YAML_DIR}/net-istio/latest-release/install"
mkdir -p "${istio_latest_dir}"

download_net_istio_yamls \
Expand All @@ -37,17 +58,17 @@ function stage_istio_latest() {

function download_net_istio_yamls() {
local net_istio_yaml="$1"
local target_dir="$2"
local istio_dir="$2"

if [[ "${net_istio_yaml}" == "http"* ]]; then
wget "${net_istio_yaml}" -P "${target_dir}" \
wget "${net_istio_yaml}" -P "${istio_dir}" \
|| fail_test "Unable to download istio file ${net_istio_yaml}"
else
cp "${net_istio_yaml}" "${target_dir}"
cp "${net_istio_yaml}" "${istio_dir}"
fi

# Point to our local copy
net_istio_yaml="${target_dir}/$(basename "${net_istio_yaml}")"
net_istio_yaml="${istio_dir}/$(basename "${net_istio_yaml}")"

local sha=$(head -n 1 ${net_istio_yaml} | grep "# Generated when HEAD was" | sed 's/^.* //')
if [[ -z "${sha:-}" ]]; then
Expand All @@ -60,13 +81,13 @@ function download_net_istio_yamls() {
local istio_yaml="$(net_istio_file_url "$sha" istio.yaml)"
local istio_config_yaml="$(net_istio_file_url "$sha" config-istio.yaml)"

wget -P "${target_dir}" "${istio_yaml}" \
wget -P "${istio_dir}" "${istio_yaml}" \
|| fail_test "Unable to get istio install file ${istio_yaml}"

# Some istio profiles don't have a config-istio so do a HEAD request to check
# before downloading
if wget -S --spider "${istio_config_yaml}" &> /dev/null; then
wget -P "${target_dir}" "${istio_config_yaml}" \
wget -P "${istio_dir}" "${istio_config_yaml}" \
|| fail_test "Unable to get istio install file ${istio_config_yaml}"
else
echo "istio profile does not have a config-istio.yaml upstream"
Expand Down

0 comments on commit c68cb55

Please sign in to comment.