@@ -1,26 +1,26 @@
|
||||
package eks
|
||||
|
||||
#Code: #"""
|
||||
[ -e /cache/bin/kubectl ] || {
|
||||
curl -sfL https://dl.k8s.io/v1.19.9/bin/linux/amd64/kubectl -o /cache/bin/kubectl && chmod +x /cache/bin/kubectl
|
||||
}
|
||||
[ -e /cache/bin/kubectl ] || {
|
||||
curl -sfL https://dl.k8s.io/v1.19.9/bin/linux/amd64/kubectl -o /cache/bin/kubectl && chmod +x /cache/bin/kubectl
|
||||
}
|
||||
|
||||
export KUBECONFIG=/kubeconfig
|
||||
export PATH="$PATH:/cache/bin"
|
||||
export KUBECONFIG=/kubeconfig
|
||||
export PATH="$PATH:/cache/bin"
|
||||
|
||||
# Generate a kube configuration
|
||||
aws eks update-kubeconfig --name "$EKS_CLUSTER"
|
||||
# Generate a kube configuration
|
||||
aws eks update-kubeconfig --name "$EKS_CLUSTER"
|
||||
|
||||
# Figure out the kubernetes username
|
||||
CONTEXT="$(kubectl config current-context)"
|
||||
USER="$(kubectl config view -o json | \
|
||||
jq -r ".contexts[] | select(.name==\"$CONTEXT\") | .context.user")"
|
||||
# Figure out the kubernetes username
|
||||
CONTEXT="$(kubectl config current-context)"
|
||||
USER="$(kubectl config view -o json | \
|
||||
jq -r ".contexts[] | select(.name==\"$CONTEXT\") | .context.user")"
|
||||
|
||||
# Grab a kubernetes access token
|
||||
ACCESS_TOKEN="$(aws eks get-token --cluster-name "$EKS_CLUSTER" | \
|
||||
jq -r .status.token)"
|
||||
# Grab a kubernetes access token
|
||||
ACCESS_TOKEN="$(aws eks get-token --cluster-name "$EKS_CLUSTER" | \
|
||||
jq -r .status.token)"
|
||||
|
||||
# Remove the user config and replace it with the token
|
||||
kubectl config unset "users.${USER}"
|
||||
kubectl config set-credentials "$USER" --token "$ACCESS_TOKEN"
|
||||
"""#
|
||||
# Remove the user config and replace it with the token
|
||||
kubectl config unset "users.${USER}"
|
||||
kubectl config set-credentials "$USER" --token "$ACCESS_TOKEN"
|
||||
"""#
|
||||
|
Reference in New Issue
Block a user