The software described in this documentation is either no longer supported or is in extended support.
Oracle recommends that you upgrade to a current supported release.

2.2.1 Setting up the kubectl Command on a Master Node

To use the kubectl command as a regular user, perform the following steps on the master node.

To setup kubectl on a master node:

  1. Create the .kube subdirectory in your home directory:

    $ mkdir -p $HOME/.kube
  2. Create a copy of the Kubernetes admin.conf file in the .kube directory:

    $ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  3. Change the ownership of the file to match your regular user profile:

    $ sudo chown $(id -u):$(id -g) $HOME/.kube/config
  4. Export the path to the file for the KUBECONFIG environment variable:

    $ export KUBECONFIG=$HOME/.kube/config

    To permanently set this environment variable, add it to your .bashrc file.

    $ echo 'export KUBECONFIG=$HOME/.kube/config' >> $HOME/.bashrc
  5. Verify that you can use the kubectl command.

    Kubernetes runs many of its services to manage the cluster configuration as containers running as Kubernetes pods, which can be viewed by running the following command on a master node:

    $ kubectl get pods -n kube-system
    NAME                                    READY   STATUS    RESTARTS   AGE
    coredns-5bc65d7f4b-qzfcc                1/1     Running   0          23h
    coredns-5bc65d7f4b-z64f2                1/1     Running   0          23h
    etcd-master1.example.com                1/1     Running   0          23h
    kube-apiserver-master1.example.com      1/1     Running   0          23h
    kube-controller-master1.example.com     1/1     Running   0          23h
    kube-flannel-ds-2sjbx                   1/1     Running   0          23h
    kube-flannel-ds-njg9r                   1/1     Running   0          23h
    kube-proxy-m2rt2                        1/1     Running   0          23h
    kube-proxy-tbkxd                        1/1     Running   0          23h
    kube-scheduler-master1.example.com      1/1     Running   0          23h
    kubernetes-dashboard-7646bf6898-d6x2m   1/1     Running   0          23h