Don't pass $KUBECONFIG to kubectl --kubeconfig flag

The $KUBECONFIG variable is like $PATH, and supports multiple files
separated by `:`, but --kubeconfig only takes a single file as a value.
Since kubectl picks up the $KUBECONFIG variable already, don't pass it
to kubectl.

Also, use --namespace instead of -n to support older kubectl versions.
This commit is contained in:
Chance Zibolski
2016-12-30 11:39:25 -08:00
parent 70ab7eb29e
commit c845c3c96b
2 changed files with 5 additions and 5 deletions

View File

@@ -1,17 +1,17 @@
#!/usr/bin/env bash
if [ -z "${KUBECONFIG}" ]; then
KUBECONFIG=~/.kube/config
export KUBECONFIG=~/.kube/config
fi
if [ -z "${NAMESPACE}" ]; then
NAMESPACE=monitoring
fi
kubectl --kubeconfig="$KUBECONFIG" create namespace "$NAMESPACE"
kubectl create namespace "$NAMESPACE"
kctl() {
kubectl --kubeconfig="$KUBECONFIG" -n "$NAMESPACE" "$@"
kubectl --namespace "$NAMESPACE" "$@"
}
kctl create -f manifests/prometheus-operator.yaml

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash
if [ -z "${KUBECONFIG}" ]; then
KUBECONFIG=~/.kube/config
export KUBECONFIG=~/.kube/config
fi
if [ -z "${NAMESPACE}" ]; then
@@ -9,7 +9,7 @@ if [ -z "${NAMESPACE}" ]; then
fi
kctl() {
kubectl --kubeconfig="$KUBECONFIG" -n "$NAMESPACE" "$@"
kubectl --namespace "$NAMESPACE" "$@"
}
kctl delete -f manifests/exporters