Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If running in pod use the ca from the pod #68

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion admission-webhook/deploy/deploy-gmsa-webhook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,21 @@ main() {
effect: NoSchedule'
fi

if [ -f "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" ]; then
info 'using pod based authentication'
BUNDLE=$(cat /var/run/secrets/kubernetes.io/serviceaccount/ca.crt | base64 | tr -d '\n')
else
info 'using config file authentication'
BUNDLE=$($KUBECTL config view --raw --minify --flatten -o jsonpath='{.clusters[].cluster.certificate-authority-data}')
fi

if [[ -z "$BUNDLE" ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if this will ever happen

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you didn't have a context set and you were not in a pod this could happen though unlikely

fatal_error "Not able to determine CA bundle for depoloyment"
fi

TLS_PRIVATE_KEY=$(cat "$SERVER_KEY" | base64 -w 0) \
TLS_CERTIFICATE="$TLS_CERTIFICATE" \
CA_BUNDLE="$($KUBECTL config view --raw --minify --flatten -o jsonpath='{.clusters[].cluster.certificate-authority-data}')" \
CA_BUNDLE="$BUNDLE" \
RBAC_ROLE_NAME="$NAMESPACE-$NAME-rbac-role" \
NAME="$NAME" \
NAMESPACE="$NAMESPACE" \
Expand Down