diff --git a/build/dev-env.sh b/build/dev-env.sh index 3b2874434c..c5c7ea176b 100755 --- a/build/dev-env.sh +++ b/build/dev-env.sh @@ -47,10 +47,14 @@ make build container docker save "${DEV_IMAGE}" | (eval $(minikube docker-env --shell bash) && docker load) || true -for tool in kubectl kustomize; do - echo "[dev-env] installing $tool" - $tool version || brew install $tool -done +# kubectl >= 1.14 includes Kustomize via "apply -k". Makes it easier to use on Linux as well, assuming kubectl installed +KUBE_CLIENT_VERSION=$(kubectl version --client --short | awk '{print $3}' | cut -d. -f2) || true +if [[ ${KUBE_CLIENT_VERSION} -lt 14 ]]; then + for tool in kubectl kustomize; do + echo "[dev-env] installing $tool" + $tool version || brew install $tool + done +fi if ! kubectl get namespace "${NAMESPACE}"; then kubectl create namespace "${NAMESPACE}" @@ -58,10 +62,18 @@ fi ROOT=./deploy/minikube -pushd $ROOT -kustomize edit set namespace "${NAMESPACE}" -kustomize edit set image "quay.io/kubernetes-ingress-controller/nginx-ingress-controller=${DEV_IMAGE}" -popd +if [[ ${KUBE_CLIENT_VERSION} -lt 14 ]]; then + pushd $ROOT + kustomize edit set namespace "${NAMESPACE}" + kustomize edit set image "quay.io/kubernetes-ingress-controller/nginx-ingress-controller=${DEV_IMAGE}" + popd + + echo "[dev-env] deploying NGINX Ingress controller in namespace $NAMESPACE" + kustomize build $ROOT | kubectl apply -f - +else + sed -i "\\|^namespace:|c \\namespace: ${NAMESPACE}" "${ROOT}/kustomization.yaml" + sed -i "\\|^- name: quay.io|c \\- name: quay.io/kubernetes-ingress-controller/nginx-ingress-controller=${DEV_IMAGE}" "${ROOT}/kustomization.yaml" -echo "[dev-env] deploying NGINX Ingress controller in namespace $NAMESPACE" -kustomize build $ROOT | kubectl apply -f - + echo "[dev-env] deploying NGINX Ingress controller in namespace $NAMESPACE" + kubectl apply -k "${ROOT}" +fi