Skip to content

Commit 41ac037

Browse files
committed
Use official secretreader access provider
Signed-off-by: kahirokunn <okinakahiro@gmail.com>
1 parent 614220c commit 41ac037

5 files changed

Lines changed: 28 additions & 83 deletions

File tree

docs/development/e2e-multicluster.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,13 @@ Apply the operator from source:
5454
ko apply -Rf config/
5555
```
5656

57-
Generate a spoke bootstrap token and mount the access provider plumbing. The
58-
helper script does this end to end:
57+
Generate a spoke bootstrap token, store it as `knative-operator/${SPOKE_CLUSTER_NAME}`,
58+
and mount the official `secretreader` image as the access provider. The helper
59+
script does this end to end:
5960

6061
```bash
6162
source test/e2e-common.sh
62-
install_access_provider_config # builds and installs the token-exec-plugin
63+
install_access_provider_config # installs the secretreader access provider
6364
apply_cluster_profile default # creates the ClusterProfile on the hub
6465
```
6566

@@ -70,11 +71,11 @@ A minimal provider config (written by the helper to
7071
{
7172
"providers": [
7273
{
73-
"name": "e2e-static-token",
74+
"name": "secretreader",
7475
"execConfig": {
7576
"apiVersion": "client.authentication.k8s.io/v1",
76-
"command": "/etc/cluster-inventory/plugin/ko-app/token-exec-plugin",
77-
"args": ["/etc/cluster-inventory/access/token"],
77+
"command": "/etc/cluster-inventory/plugin/bin/secretreader-plugin",
78+
"provideClusterInfo": true,
7879
"interactiveMode": "Never"
7980
}
8081
}
@@ -205,8 +206,8 @@ which reuses the same helpers this guide calls manually:
205206
`AccessProviderFailed`, exec into the operator and run the plugin manually:
206207
```bash
207208
kubectl -n knative-operator exec deploy/knative-operator -- \
208-
/etc/cluster-inventory/plugin/ko-app/token-exec-plugin \
209-
/etc/cluster-inventory/access/token
209+
env KUBERNETES_EXEC_INFO="{\"apiVersion\":\"client.authentication.k8s.io/v1\",\"kind\":\"ExecCredential\",\"spec\":{\"cluster\":{\"server\":\"https://debug.invalid\",\"config\":{\"clusterName\":\"${SPOKE_CLUSTER_NAME}\"}}}}" \
210+
/etc/cluster-inventory/plugin/bin/secretreader-plugin
210211
```
211212

212213
## 8. Cleanup

test/cmd/token-exec-plugin/main.go

Lines changed: 0 additions & 49 deletions
This file was deleted.

test/config/multicluster/clusterprofile-status.yaml.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ status:
66
cluster:
77
server: "${SPOKE_INTERNAL_ENDPOINT}"
88
certificate-authority-data: "${SPOKE_CA_DATA_B64}"
9+
extensions:
10+
- name: client.authentication.k8s.io/exec
11+
extension:
12+
clusterName: "${SPOKE_CLUSTER_NAME}"
913
conditions:
1014
- type: ControlPlaneHealthy
1115
status: "True"

test/e2e-common.sh

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ export KO_FLAGS="${KO_FLAGS:-}"
4242
export INGRESS_CLASS=${INGRESS_CLASS:-istio.ingress.networking.knative.dev}
4343
export TIMEOUT_CI=30m
4444

45+
: "${MC_PROVIDER_CONFIGMAP:=clusterprofile-provider-file}"
46+
: "${MC_PROVIDER_MOUNT_PATH:=/etc/cluster-inventory}"
47+
: "${MC_PROVIDER_PLUGIN_MOUNT_PATH:=/etc/cluster-inventory/plugin}"
48+
: "${MC_PROVIDER_PLUGIN_IMAGE:=registry.k8s.io/cluster-inventory-api/secretreader:v0.1.3}"
49+
: "${MC_PROVIDER_NAME:=secretreader}"
50+
4551
# Boolean used to indicate whether to generate serving YAML based on the latest code in the branch KNATIVE_SERVING_REPO_BRANCH.
4652
GENERATE_SERVING_YAML=0
4753

@@ -464,8 +470,9 @@ function apply_cluster_profile() {
464470
SPOKE_INTERNAL_ENDPOINT="${spoke_endpoint}" \
465471
SPOKE_CA_DATA_B64="${spoke_ca_b64}" \
466472
MC_PROVIDER_NAME="${MC_PROVIDER_NAME}" \
473+
SPOKE_CLUSTER_NAME="${SPOKE_CLUSTER_NAME}" \
467474
TRANSITION="$(date -u +%FT%TZ)" \
468-
envsubst '${SPOKE_INTERNAL_ENDPOINT} ${SPOKE_CA_DATA_B64} ${MC_PROVIDER_NAME} ${TRANSITION}' \
475+
envsubst '${SPOKE_INTERNAL_ENDPOINT} ${SPOKE_CA_DATA_B64} ${MC_PROVIDER_NAME} ${SPOKE_CLUSTER_NAME} ${TRANSITION}' \
469476
< test/config/multicluster/clusterprofile-status.yaml.tmpl \
470477
> "${status_file}" || return 1
471478

@@ -477,23 +484,14 @@ function apply_cluster_profile() {
477484
}
478485

479486
function install_access_provider_config() {
480-
echo ">> Building token-exec-plugin image via ko"
481-
local plugin_image
482-
plugin_image="$(ko build ./test/cmd/token-exec-plugin)" || return 1
483-
if [[ -z "${plugin_image}" ]]; then
484-
echo "ERROR: ko build did not emit an image reference for token-exec-plugin" >&2
485-
return 1
486-
fi
487-
echo ">> token-exec-plugin image: ${plugin_image}"
488-
489487
echo ">> Installing access provider ConfigMap/Secret and patching operator deployment"
490488
local tmpdir
491489
tmpdir="$(mktemp -d)" || return 1
492490
add_trap "rm -rf ${tmpdir}" EXIT
493491
local token_file="${tmpdir}/token"
494492
_spoke_bootstrap_token "${token_file}" || return 1
495493

496-
local plugin_command="${MC_PROVIDER_PLUGIN_MOUNT_PATH}/ko-app/token-exec-plugin"
494+
local plugin_command="${MC_PROVIDER_PLUGIN_MOUNT_PATH}/bin/secretreader-plugin"
497495
cat > "${tmpdir}/provider-config.json" <<EOF
498496
{
499497
"providers": [
@@ -502,7 +500,7 @@ function install_access_provider_config() {
502500
"execConfig": {
503501
"apiVersion": "client.authentication.k8s.io/v1",
504502
"command": "${plugin_command}",
505-
"args": ["${MC_PROVIDER_TOKEN_MOUNT_PATH}/token"],
503+
"provideClusterInfo": true,
506504
"interactiveMode": "Never"
507505
}
508506
}
@@ -514,24 +512,21 @@ EOF
514512
--from-file=config.json="${tmpdir}/provider-config.json" \
515513
--dry-run=client -o yaml | kubectl apply -f - || return 1
516514

517-
kubectl -n "${TEST_OPERATOR_NAMESPACE}" create secret generic "${MC_PROVIDER_TOKEN_SECRET}" \
515+
kubectl -n "${TEST_OPERATOR_NAMESPACE}" create secret generic "${SPOKE_CLUSTER_NAME}" \
518516
--from-file=token="${token_file}" \
519517
--dry-run=client -o yaml | kubectl apply -f - || return 1
520518

521-
# 0444
522519
kubectl -n "${TEST_OPERATOR_NAMESPACE}" patch deployment knative-operator \
523520
--type=json \
524521
-p "$(cat <<EOF
525522
[
526523
{"op": "add", "path": "/spec/template/spec/containers/0/args", "value": ["--clusterprofile-provider-file=${MC_PROVIDER_MOUNT_PATH}/config.json"]},
527524
{"op": "add", "path": "/spec/template/spec/volumes", "value": [
528525
{"name": "access-config", "configMap": {"name": "${MC_PROVIDER_CONFIGMAP}"}},
529-
{"name": "provider-token", "secret": {"secretName": "${MC_PROVIDER_TOKEN_SECRET}", "defaultMode": 292}},
530-
{"name": "access-plugin", "image": {"reference": "${plugin_image}", "pullPolicy": "IfNotPresent"}}
526+
{"name": "access-plugin", "image": {"reference": "${MC_PROVIDER_PLUGIN_IMAGE}", "pullPolicy": "IfNotPresent"}}
531527
]},
532528
{"op": "add", "path": "/spec/template/spec/containers/0/volumeMounts", "value": [
533529
{"name": "access-config", "mountPath": "${MC_PROVIDER_MOUNT_PATH}", "readOnly": true},
534-
{"name": "provider-token", "mountPath": "${MC_PROVIDER_TOKEN_MOUNT_PATH}", "readOnly": true},
535530
{"name": "access-plugin", "mountPath": "${MC_PROVIDER_PLUGIN_MOUNT_PATH}", "readOnly": true}
536531
]}
537532
]

test/e2e-tests-multicluster.sh

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,11 @@ source "$(dirname "$0")/e2e-common.sh"
3232
: "${SPOKE_KUBECONFIG:=/tmp/spoke.kubeconfig}"
3333
: "${SPOKE_HOST_KUBECONFIG:=/tmp/spoke-host.kubeconfig}"
3434
: "${CLUSTER_INVENTORY_CRD_URL:=https://raw.githubusercontent.com/kubernetes-sigs/cluster-inventory-api/v0.1.3/config/crd/bases/multicluster.x-k8s.io_clusterprofiles.yaml}"
35-
: "${MC_PROVIDER_CONFIGMAP:=clusterprofile-provider-file}"
36-
: "${MC_PROVIDER_TOKEN_SECRET:=clusterprofile-provider-token}"
37-
: "${MC_PROVIDER_MOUNT_PATH:=/etc/cluster-inventory}"
38-
: "${MC_PROVIDER_TOKEN_MOUNT_PATH:=/etc/cluster-inventory/access}"
39-
: "${MC_PROVIDER_PLUGIN_MOUNT_PATH:=/etc/cluster-inventory/plugin}"
40-
: "${MC_PROVIDER_NAME:=e2e-static-token}"
4135
: "${SPOKE_GATEWAY_API_CRD_URL:=https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.4.1/experimental-install.yaml}"
4236
export SPOKE_CLUSTER_NAME SPOKE_KUBECONFIG SPOKE_HOST_KUBECONFIG
43-
export CLUSTER_INVENTORY_CRD_URL MC_PROVIDER_CONFIGMAP MC_PROVIDER_TOKEN_SECRET
44-
export MC_PROVIDER_MOUNT_PATH MC_PROVIDER_TOKEN_MOUNT_PATH
45-
export MC_PROVIDER_PLUGIN_MOUNT_PATH MC_PROVIDER_NAME
37+
export CLUSTER_INVENTORY_CRD_URL MC_PROVIDER_CONFIGMAP
38+
export MC_PROVIDER_MOUNT_PATH MC_PROVIDER_PLUGIN_MOUNT_PATH
39+
export MC_PROVIDER_PLUGIN_IMAGE MC_PROVIDER_NAME
4640
export SPOKE_GATEWAY_API_CRD_URL
4741

4842
function knative_setup() {

0 commit comments

Comments
 (0)