Skip to content

Instantly share code, notes, and snippets.

@chanjarster
Created October 11, 2019 06:43
Show Gist options
  • Save chanjarster/d5116cad45e8643c2675f541b0aa1939 to your computer and use it in GitHub Desktop.
Save chanjarster/d5116cad45e8643c2675f541b0aa1939 to your computer and use it in GitHub Desktop.
Initialize Tiller Service Account For Each Namespace
#!/bin/bash
if [ -z "$1" ]; then
echo 'usage: init-tiller-sa.sh <namespace>'
exit 1
fi
namespace=$1
cat <<EOF | kubectl apply -f -
kind: ServiceAccount
apiVersion: v1
metadata:
name: tiller
namespace: $namespace
EOF
cat <<EOF | kubectl apply -f -
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: tiller-manager
namespace: $namespace
rules:
- apiGroups: ["", "batch", "extensions", "apps"]
resources: ["*"]
verbs: ["*"]
EOF
cat <<EOF | kubectl apply -f -
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: tiller-binding
namespace: $namespace
subjects:
- kind: ServiceAccount
name: tiller
namespace: $namespace
roleRef:
kind: Role
name: tiller-manager
apiGroup: rbac.authorization.k8s.io
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment