Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 46 lines (34 sloc) 1.41 KB
#!/usr/bin/env bash
set -o errexit
set -o errtrace
set -o nounset
set -o pipefail
NAMESPACE="${1:-default}"
RESOURCES="${2:-pods,deploy,svc}"
### Set permissions
kubectl -n $NAMESPACE delete clusterrole resreader
kubectl -n $NAMESPACE create sa krs --dry-run --output=yaml > /tmp/krs-perm.yaml
printf "\n---\n" >> /tmp/krs-perm.yaml
kubectl create clusterrole resreader \
--verb=get --verb=list \
--resource=pods --resource=deployments --resource=services \
--resource=replicationcontroller --resource=daemonsets.apps \
--resource=deployments.apps --resource=replicasets.apps \
--resource=statefulsets.apps \
--resource=horizontalpodautoscalers.autoscaling \
--resource=jobs.batch --resource=cronjobs.batch \
--resource=persistentvolumes --resource=persistentvolumeclaims \
--dry-run --output=yaml >> /tmp/krs-perm.yaml
printf "\n---\n" >> /tmp/krs-perm.yaml
kubectl -n $NAMESPACE create rolebinding allowresprobes \
--clusterrole=resreader \
--serviceaccount=$NAMESPACE:krs \
--namespace=$NAMESPACE \
--dry-run --output=yaml >> /tmp/krs-perm.yaml
kubectl -n $NAMESPACE apply -f /tmp/krs-perm.yaml
### launch tool
kubectl -n $NAMESPACE run krs \
--image=quay.io/mhausenblas/krs:0.2 \
--serviceaccount=krs \
--command -- /app/krs --namespace $NAMESPACE --resources "$RESOURCES"
# rm /tmp/krs-perm.yaml