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.
Oracle Linux Cloud Native Environment allows you to create multiple environments from the operator node. With this in mind, it is recommended that you use the kubectl command on a master node in the Kubernetes cluster. If you use the kubectl command from the operator node, and you have multiple environments deployed, you may inadvertently manage an unexpected Kubernetes cluster. If you do want to set up the kubectl command to run it the operator node, you need to configure it.
The kubectl command is not set up by default to connect to Kubernetes from the operator node. To set up the kubectl command on the operator node, create a local copy of the Kubernetes configuration file, and use that to connect to the cluster.
To use the kubectl command as a regular user, perform the following steps on the operator node.
To setup kubectl on an operator node:
Get the Kubernetes configuration and copy it to a local file on the operator node. Use the olcnectl module property get command to get the Kubernetes configuration from the
kubecfgproperty of thekubernetesmodule. For example:$
olcnectl --api-server 127.0.0.1:8091 module property get \ --environment-name myenvironment --name mycluster \ --property kubecfg | base64 -d > kubeconfig.yamlYou can use the
kubeconfig.yamlfile directly when running kubectl commands using the--kubeconfigoption. For example:$
kubectl get pods -n kube-system --kubeconfig kubeconfig.yamlYou can also save the Kubernetes configuration so you do not need to use the
--kubeconfigoption. Create the.kubesubdirectory in your home directory:$
mkdir -p $HOME/.kubeCopy the Kubernetes
kubeconfig.yamlfile to the.kubedirectory:$
cp kubeconfig.yaml $HOME/.kube/configExport the path to the file for the
KUBECONFIGenvironment variable:$
export KUBECONFIG=$HOME/.kube/configTo permanently set this environment variable, add it to your
.bashrcfile.$
echo 'export KUBECONFIG=$HOME/.kube/config' >> $HOME/.bashrcVerify 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-systemNAME 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

