Skip to content

Commit

Permalink
examples: setting RAMIdentityMapping for test
Browse files Browse the repository at this point in the history
  • Loading branch information
mozillazg committed Jan 9, 2024
1 parent 7671f4a commit dc955b9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions examples/credential-plugin/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,36 @@ function get_kubeconfig() {
bar_tip "get kubeconfig"

ack-ram-tool credential-plugin get-kubeconfig -m ${MODE} --cluster-id ${CLUSTER_ID} > ${KUBECONFIG_PATH}

if echo ${MODE} |grep token; then
Arn=$(aliyun sts GetCallerIdentity | jq .Arn -r)
UserId=$(aliyun sts GetCallerIdentity | jq .UserId -r)
ack-ram-tool credential-plugin get-kubeconfig --cluster-id ${CLUSTER_ID} > ${KUBECONFIG_PATH}.crt.yaml
cat <<EOF | kubectl --kubeconfig=${KUBECONFIG_PATH}.crt.yaml apply -f -
apiVersion: ramauthenticator.k8s.alibabacloud/v1alpha1
kind: RAMIdentityMapping
metadata:
name: "${UserId}"
spec:
arn: ${Arn}
username: "${UserId}"
EOF
fi
}

function exec_auth() {
bar_tip "exec auth plugin"

kubectl --kubeconfig=${KUBECONFIG_PATH} get ns
kubectl --kubeconfig=${KUBECONFIG_PATH} auth whoami
}

function cleanup() {
set +e
bar_tip "cleanup"

rm ${KUBECONFIG_PATH}
rm ${KUBECONFIG_PATH}.crt.yaml
rm ${CACHE_DIR}/*
rm -r ${CACHE_DIR}

Expand Down

0 comments on commit dc955b9

Please sign in to comment.