diff --git a/examples/setup-rbac.sh b/examples/setup-rbac.sh index 088796690..eb200eb62 100755 --- a/examples/setup-rbac.sh +++ b/examples/setup-rbac.sh @@ -1,7 +1,11 @@ #!/bin/bash +ROLE_NAME="${ROLE_NAME:-arangodb-operator}" +ROLE_BINDING_NAME="${ROLE_BINDING_NAME:-arangodb-operator}" +NAMESPACE="${NAMESPACE:-default}" + function usage { - echo "$(basename "$0") - Create Kubernetes RBAC role and bindings for ArangoDB operator +echo "$(basename "$0") - Create Kubernetes RBAC role and bindings for ArangoDB operator Usage: $(basename "$0") [options...] Options: --role-name=STRING Name of ClusterRole to create @@ -13,12 +17,8 @@ Options: " >&2 } -ROLE_NAME="${ROLE_NAME:-arangodb-operator}" -ROLE_BINDING_NAME="${ROLE_BINDING_NAME:-arangodb-operator}" -NAMESPACE="${NAMESPACE:-default}" - function setupRole { - yaml=$(cat << EOYAML +kubectl apply -f - << EOYAML apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRole metadata: @@ -54,12 +54,10 @@ rules: verbs: - "*" EOYAML -) - echo "$yaml" | kubectl apply -f - } function setupRoleBinding { - yaml=$(cat << EOYAML +kubectl apply -f - << EOYAML apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRoleBinding metadata: @@ -73,31 +71,28 @@ subjects: name: default namespace: ${NAMESPACE} EOYAML -) - echo "$yaml" | kubectl apply -f - } -for i in "$@" -do -case $i in - --role-name=*) - ROLE_NAME="${i#*=}" - ;; - --role-binding-name=*) - ROLE_BINDING_NAME="${i#*=}" - ;; - --namespace=*) - NAMESPACE="${i#*=}" - ;; - -h|--help) - usage - exit 0 - ;; - *) - usage - exit 1 - ;; -esac +for i in "$@"; do + case $i in + --role-name=*) + ROLE_NAME="${i#*=}" + ;; + --role-binding-name=*) + ROLE_BINDING_NAME="${i#*=}" + ;; + --namespace=*) + NAMESPACE="${i#*=}" + ;; + -h|--help) + usage + exit 0 + ;; + *) + usage + exit 1 + ;; + esac done setupRole diff --git a/scripts/kube_create_operator.sh b/scripts/kube_create_operator.sh index ca5c54dcd..a8d511c3c 100755 --- a/scripts/kube_create_operator.sh +++ b/scripts/kube_create_operator.sh @@ -14,7 +14,7 @@ if [ -z $IMAGE ]; then exit 1 fi -yaml=$(cat << EOYAML +kubectl --namespace=$NS create -f - << EOYAML apiVersion: extensions/v1beta1 kind: Deployment metadata: @@ -41,5 +41,3 @@ spec: fieldPath: metadata.name EOYAML -) -echo "$yaml" | kubectl --namespace=$NS create -f - \ No newline at end of file