Skip to content

Commit dcd9b81

Browse files
committed
Simplify the passing of KUBECONFIG
According to `man podman run` if we simply pass `-e KUBECONFIG` to the podman invocation: "If an environment variable is spec‐ ified without a value, Podman checks the host environment for a value and set the variable only if it is set on the host" So let's just do that and drop the current more complex fragile logic. Tested with: * No KUBECONFIG set unset KUBECONFIG; ./pattern.sh make install make -f common/Makefile operator-deploy make[1]: Entering directory '/home/michele/Engineering/cloud-patterns/multicloud-gitops' Checking prerequisites: Check for 'git helm oc ansible': OK Check for python-kubernetes: OK Check for kubernetes.core collection: OK Checking repository: https://github.com/mbaldessari/multicloud-gitops.git - branch script-fix: Running inside a container: Skipping git ssh checks Running helm: Error: Kubernetes cluster unreachable: Get "https://localhos:6443/version" * With KUBECONFIG set export KUBECONFIG=~/sno1-kubeconfig ./pattern.sh make install make -f common/Makefile operator-deploy make[1]: Entering directory '/home/michele/Engineering/cloud-patterns/multicloud-gitops' Checking prerequisites: Check for 'git helm oc ansible': OK Check for python-kubernetes: OK Check for kubernetes.core collection: OK Checking repository: https://github.com/mbaldessari/multicloud-gitops.git - branch script-fix: Running inside a container: Skipping git ssh checks Running helm: WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /home/michele/sno1-kubeconfig Release "multicloud-gitops" does not exist. Installing it now. NAME: multicloud-gitops LAST DEPLOYED: Mon Sep 4 07:04:16 2023 NAMESPACE: default STATUS: deployed REVISION: 1 TEST SUITE: None make[1]: Leaving directory '/home/michele/Engineering/cloud-patterns/multicloud-gitops' make load-secrets make[1]: Entering directory '/home/michele/Engineering/cloud-patterns/multicloud-gitops' make -f common/Makefile load-secrets ...
1 parent 344d037 commit dcd9b81

1 file changed

Lines changed: 1 addition & 8 deletions

File tree

scripts/pattern-util.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,12 @@ fi
2525
# $HOME is mounted as itself for any files that are referenced with absolute paths
2626
# $HOME is mounted to /root because the UID in the container is 0 and that's where SSH looks for credentials
2727

28-
# We must pass -e KUBECONFIG *only* if it is set, otherwise we end up passing
29-
# KUBECONFIG="" which then will confuse ansible
30-
KUBECONF_ENV=""
31-
if [ -n "$KUBECONFIG" ]; then
32-
KUBECONF_ENV="-e KUBECONFIG=${KUBECONFIG}"
33-
fi
34-
3528
# Do not quote the ${KUBECONF_ENV} below, otherwise we will pass '' to podman
3629
# which will be confused
3730
podman run -it --rm \
3831
--security-opt label=disable \
3932
-e EXTRA_HELM_OPTS \
40-
${KUBECONF_ENV} \
33+
-e KUBECONFIG \
4134
-v "${HOME}":"${HOME}" \
4235
-v "${HOME}":/pattern-home \
4336
-v "${HOME}":/root \

0 commit comments

Comments
 (0)