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

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

Open
silencehe09 opened this issue May 31, 2018 · 3 comments

Comments

@silencehe09
Copy link

silencehe09 commented May 31, 2018

Dear author:
I need your help. I have commented the condition "apb should not be run as root" in apb-docker-run.sh , because I have to run docker with root user (without considering about security in my experimental env). And I have run "apb init apb-demo && cd apb-demo && apb build " successfully. But I got exception when executing "apb list", "apb bootstrap" and so on. I have already logged in openshift with cluster-admin role . The following are some shell cmds and output:

[root@localhost data]# apb init apb-demo
Running APB image: ansibleplaybookbundle/apb-tools:latest
groupadd: GID '0' already exists
usermod: group 'apb' does not exist
Initializing /mnt/apb-demo for an APB.
Generating playbook files
Successfully initialized project directory at: /mnt/apb-demo
Please run *apb prepare* inside of this directory after editing files.
[root@localhost data]# cd apb-demo
[root@localhost apb-demo]# apb build
Running APB image: ansibleplaybookbundle/apb-tools:latest
groupadd: GID '0' already exists
usermod: group 'apb' does not exist
Finished writing dockerfile.
Building APB using tag: [apb-demo]
Successfully built APB image: apb-demo
[root@localhost apb-demo]# docker images | grep apb-demo
apb-demo                                             latest              7c7fb3baf209        14 seconds ago      603.8 MB
[root@localhost apb-demo]# apb list
Running APB image: ansibleplaybookbundle/apb-tools:latest
groupadd: GID '0' already exists
usermod: group 'apb' does not exist
Exception occurred! [Errno 2] No such file or directory: '/root/.kube/config'
[root@localhost apb-demo]# oc whoami
XXXXX(my user name)
[root@localhost apb-demo]# cat /root/.kube/config
apiVersion: v1
clusters:
- cluster:
    insecure-skip-tls-verify: true
    server: xxx
  name: xxxx
...

The Linux version is CentOS7 (Linux localhost.localdomain 3.10.0-514.el7.x86_64).

@rgolangh
Copy link

rgolangh commented Jul 3, 2018

Edit the script again, and in the place where it says -u $UID put -u 1000 . If that works well I'll send a patch to fix it, like in this one here

-u $UID $APB_IMAGE "$@"

@ppanero
Copy link

ppanero commented Jul 23, 2018

I run into the same problem, and I can confirm this fixed the issue.

Cheers

@rgolangh
Copy link

The more elegant solution is just add the KUBECONFIG variable to match the volume path

-e KUBECONFIG=/.kube/config

And that will work with any $UID and will prevent errors like if the $HOME/.kube dir ownership is by uid
which is not 1000.

rgolangh added a commit to rgolangh/ansible-playbook-bundle that referenced this issue Jul 23, 2018
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]>
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 a pull request may close this issue.

3 participants