Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set KUBECONFIG to the $HOME/.kube/config if missing #317

Closed
wants to merge 1 commit into from

Conversation

rgolangh
Copy link

To support root or non-root docker invocations, set the KUBECONFIG
specifically to the passed .kube dir. The reason is that 'oc' incovation
as root is by default looking for the .kube dir uner
/root/.kube/config where as non-root is looking at $HOME/.kube/config.

With this we always set KUBECONFIG, so root invocation of oc commands
will always find the passed in config.

Fixes: #298

To support root or non-root docker invocations, set the KUBECONFIG
specifically to the passed .kube dir. The reason is that 'oc' incovation
as root is by default looking for the .kube dir uner
`/root/.kube/config` where as non-root is looking at $HOME/.kube/config.

With this we always set KUBECONFIG, so root invocation of `oc` commands
will always find the passed in config.

Fixes: ansibleplaybookbundle#298

Signed-off-by: Roy Golan <[email protected]>
@rgolangh
Copy link
Author

@dymurray please review

@dymurray
Copy link
Contributor

Looks good, thanks for submitting.

@@ -16,6 +16,7 @@ if ! [[ -z "${DOCKER_CERT_PATH}" ]] && [[ ${DOCKER_CERT_PATH} = *"minishift"* ]]
fi

KUBECONFIG_ENV="${KUBECONFIG:+-v ${KUBECONFIG}:${KUBECONFIG} -e KUBECONFIG=${KUBECONFIG}}"
[[ -z $KUBECONFIG ]] && KUBECONFIG_ENV="${KUBECONFIG:--v $HOME/.kube:/.kube -e KUBECONFIG=/.kube/config}"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe even better, remove this, and just set KUBECONFIG in line 17, if its not set yet:

KUBECONFIG=${KUBECONFIG:-/.kube/config}

@rgolangh rgolangh closed this May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

“apb list”: Exception occurred! [Errno 2] No such file or directory: '/root/.kube/config'
3 participants