FreeKB - OpenShift oc login command
OpenShift - oc login command

If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.

The oc login command is used to authenticate against the API service in the master node. In this example, oc.example.com:8443 is the hostname and port for the API service in the master node.

oc login oc.example.com:8443

 

If you provide a bogus host to connect to, something like this will be displayed.

~]# oc login bogus.example.com
error: dial tcp: lookup bogus.example.com on 10.14.155.57:53: no such host - verify you have provided the correct host and port and that the server is currently running.

 

On the other hand, after providing a valid hostname, you should be prompted to provide your username . . .

Authentication required for https://oc.example.com:8443 (openshift)
Username:

 

. . . and password.

Password:

 

Or, your username and password can be included.

oc login oc.example.com:8443 -u=<username> -p=<password>

 

Or, a token can be used, so that you don't need to authenticate with a username and password. Obviously, replace "abc123" with the actual token.

oc login oc.example.com:8443 --token=abc123

 

If the authentication attempt fails, something like this should be displayed.

Login failed (401 Unauthorized)
Verify you have provided correct credentials.

 

If you are authenticated, something like this should be displayed.

Login successful.

You have access to 193 projects, the list has been suppressed. You can list all projects with 'oc projects'

Using project "default".
Welcome! See 'oc help' to get started.

 

If the /home/your_username/.kube/confilg does not exist, it will be created after the first successful log in. Here is an example of the ~/.kube/config file.

apiVersion: v1
clusters:
- cluster:
    server: https://os.example.com:6443
  name: os.example.com:6443
contexts:
- context:
    cluster: os.example.com:6443
    namespace: default
    user: john.doe
  name: default/os.example.com:6443/john.doe
current-context: default/os.example.com:6443/john.doe
kind: Config
preferences: {}
users:
- name: john.doe
  user:
    token: Mn8cvscRkYgEUo_DcoUHUk3Z7Cu8W2RQikRBwmglet8

 

The --kubeconfig option can be used to specify the ~/.kube/config file to use, like this.

oc login oc.example.com:8443 --kubeconfig /home/john.doe/.kube/config

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 8fe84 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |