Skip to content

Commit 29cf465

Browse files
committed
discovery: add simple e2e for discovery service
1 parent 43fab44 commit 29cf465

File tree

1 file changed

+72
-0
lines changed
  • tests/e2e/scenarios/discovery-service

1 file changed

+72
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2025 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
18+
set -euo pipefail
19+
20+
REPO_ROOT=$(git rev-parse --show-toplevel)
21+
cd ${REPO_ROOT}
22+
23+
CLUSTER_NAME="discovery-test1.k8s.local"
24+
25+
26+
CLOUD_PROVIDER=gce
27+
ZONES=us-east4-a
28+
29+
OVERRIDES="${OVERRIDES-} --node-count=2" # We need at least 2 nodes for CoreDNS to validate
30+
OVERRIDES="${OVERRIDES} --gce-service-account=default" # Use default service account because boskos permissions are limited
31+
OVERRIDES="${OVERRIDES} --discovery-service=https://discovery.kubedisco.com"
32+
33+
34+
# Enable feature flag for Discovery Service support
35+
export KOPS_FEATURE_FLAGS=DiscoveryService
36+
37+
# Build kOps binary
38+
WORKDIR=${REPO_ROOT}/.build/
39+
40+
BINDIR=${WORKDIR}/bin
41+
mkdir -p "${BINDIR}"
42+
go build -o ${BINDIR}/kops ./cmd/kops
43+
export KOPS=${BINDIR}/kops
44+
45+
. hack/dev-build-gce.sh
46+
47+
# Delete cluster when done
48+
function cleanup() {
49+
if [[ -z "${SKIP_CLEANUP:-}" ]]; then
50+
echo "running cleanup"
51+
${KOPS} delete cluster ${CLUSTER_NAME} --yes || true
52+
fi
53+
}
54+
trap cleanup EXIT
55+
56+
# Create kOps cluster
57+
${KOPS} create cluster ${CLUSTER_NAME} --cloud=${CLOUD_PROVIDER} --zones=${ZONES} ${OVERRIDES:-}
58+
${KOPS} update cluster ${CLUSTER_NAME} --yes --admin
59+
${KOPS} validate cluster ${CLUSTER_NAME} --wait=10m
60+
61+
# Verify that the Discovery Service is working as expected
62+
DISCOVERY_SERVICE_URL=$(${KOPS} get cluster discovery-test1.k8s.local -ojson | jq -r .spec.serviceAccountIssuerDiscovery.discoveryService.url)
63+
echo "Discovery Service URL: ${DISCOVERY_SERVICE_URL}"
64+
65+
echo "Fetching OpenID configuration from Discovery Service:"
66+
curl ${DISCOVERY_SERVICE_URL}.well-known/openid-configuration | jq .
67+
68+
JWKS_URI=$(curl -s ${DISCOVERY_SERVICE_URL}.well-known/openid-configuration | jq -r .jwks_uri)
69+
echo "JWKS_URI: ${JWKS_URI}"
70+
71+
echo "Fetching JWKS from ${JWKS_URI}:"
72+
curl ${JWKS_URI} | jq .

0 commit comments

Comments
 (0)