Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fabiogomezdiaz/b5afafea1ce845d413afc6cd5f5c16ea to your computer and use it in GitHub Desktop.
Save fabiogomezdiaz/b5afafea1ce845d413afc6cd5f5c16ea to your computer and use it in GitHub Desktop.
Kubernetes: Delete Service Account
#!/bin/bash
#set -e
#set -o pipefail
# Add user to k8s using service account, no RBAC (must create RBAC after this script)
if [[ -z "$1" ]] || [[ -z "$2" ]]; then
echo "usage: $0 <service_account_name> <namespace>"
exit 1
fi
SERVICE_ACCOUNT_NAME=$1
NAMESPACE="$2"
kubectl --namespace ${NAMESPACE} delete sa ${SERVICE_ACCOUNT_NAME};
kubectl --namespace ${NAMESPACE} delete clusterrolebinding ${SERVICE_ACCOUNT_NAME}-binding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment