Search code examples
securitykubernetesaccountopenshift-origin

Openshift: How to test kubernetes features without manually managing administrative accounts/permissions?


I'm attempting to test a single node dev cluster for openshift which I've created. I cannot run any basic commands on the cluster, because I haven't set up properly privliged accounts.

In particular I need to:

  • run pods which make containers which query service endpoints
  • query the apiserver through an insecure endpoint
  • run commands like kubectl get pods

Is there a default account somewhere I can use which can do all of these things? I'd prefer not to manually set up a bunch of complicated user accounts for a low-level development task such as this.

Below are a few, somewhat silly attempts I've made to do this, just as examples

First, I created an "admin" account like this:

sudo -u vagrant $oc login https://localhost:8443 -u=admin -p=admin --config=/data/src/github.com/openshift/origin/openshift.local.config/master/openshift-registry.kubeconfig

Then, I went ahead and hacked around in a few attempts to login as an admin:

[vagrant@localhost ~]$ sudo chmod 777 /openshift.local.config/master/admin.kubeconfig
[vagrant@localhost ~]$ oc login
Server [https://localhost:8443]:
The server uses a certificate signed by an unknown authority.
You can bypass the certificate check, but any data you send to the server could be intercepted by others.
Use insecure connections? (y/n): y

Authentication required for https://localhost:8443 (openshift)
Username: admin
Password: admin
Login successful.
Using project "project1".
[vagrant@localhost ~]$ oc get nodes --config=/openshift.local.config/master/admin.kubeconfig

This leads to the following error:

Error from server: User "admin" cannot list all nodes in the cluster

I also get this error leaving the config out:

[vagrant@localhost ~]$ oc get nodes
Error from server: User "admin" cannot list all nodes in the cluster

Is there any easy way to list nodes and do basic kube operations in a standalone development cluster for openshift?


Solution

  • You don't login when you are using administrative credentials. You simply set KUBECONFIG=admin.kubeconfig. Login is taking you through a different flow - there is no magic "admin" user.