When you create a cluster, Container Engine for Kubernetes creates a Kubernetes configuration file for the cluster called kubeconfig. The kubeconfig file provides the necessary details to access the cluster using kubectl and the Kubernetes Dashboard.
You have to follow a number of steps to download the kubeconfig file and set an environment variable to point to it. Having completed the steps, you can start using kubectl and the Kubernetes Dashboard to manage the cluster.
You can use the Kubernetes command line tool kubectl to perform operations on a cluster you’ve created with Container Engine for Kubernetes. Before you can use kubectl, you need to specify the cluster on which to perform operations.
- Install kubectl based on the OS you are running on your desktop (see the kubectl documentation).
- Install and configure the Oracle Cloud Infrastructure CLI
- Install the Oracle Cloud Infrastructure See Installing the CLI.
- Configure the Oracle Cloud Infrastructure See Configuring the CLI.
- Upload the public key of the API signing key pair
- In the top-right corner of the Console, click on API username, and then click User Settings to view the details.
- Click Add Public Key.
- Paste the public key’s value into the window and click Add. The key is uploaded and its fingerprint is displayed (for example, d1:b2:32:53:d3:5f:cf:68:2d:6f:8b:5f:77:8f:07:13).
- Get the get-kubeconfig.sh file and run it to download the kubeconfig file
- In the Console, click Containers, and then click Clusters.
- On the Cluster List page, click the name of the cluster you want to access using kubectl and the Kubernetes Dashboard – in this case it is oke-cluster. The Cluster page shows details of the cluster.
- Click the Access Kubeconfig button to display the How to Access Kubeconfig dialog box.
- The How to Access Kubeconfig dialog box provides the code to include in the get-kubeconfig.sh file. (Please use Google-Chrome browser)
- Open a new file in a text editor.
- Copy the code for the get-kubeconfig.sh file from the How to Access Kubeconfig dialog box and paste it into the text editor.
- Save the file as get-kubeconfig.sh in a convenient location on the machine where you installed the Oracle Cloud Infrastructure CLI (for example, your home directory), and close the text editor.
- Make the get-kubeconfig.sh file executable.
- For example, on Linux, if you saved the file to your home directory, enter the following command in a terminal window (or copy and paste it from the How to Access Kubeconfig dialog box):
# chmod +x ~/get-kubeconfig.sh
- Set the ENDPOINT environment variable to point to the region in which you created the cluster. Use one of us-phoenix-1, us-ashburn-1, eu-frankfurt-1, or uk-london-1 to specify the region. For example, if you created the cluster in the Ashburn region, enter the following command in a terminal window (or copy and paste it from the How to Access Kubeconfig dialog box):
# export ENDPOINT=containerengine.us-ashburn-1.oraclecloud.com
- Run the get-kubeconfig.sh file to download the kubeconfig file and save it in a location accessible to kubectl and the Kubernetes Dashboard. For example, enter the following command (or copy and paste it from the How to Access Kubeconfig dialog box):
# ~/get-kubeconfig.sh ocid1.cluster.oc1.phx.aaaaaaaaae… > ~/kubeconfig
Where ocid1.cluster.oc1.phx.aaaaaaaaae… is the OCID of the current cluster. For convenience, the command in the How to Access Kubeconfig dialog box already includes the cluster’s OCID.
At this point, you should be able to launch the Kubernetes Dashboard and access it. Kubernetes Dashboard is a web-based user interface that you can use as an alternative to the Kubernetes kubectl command line tool to:
- Deploy containerized applications to a Kubernetes cluster
- Troubleshoot your containerized applications
You use the Kubernetes Dashboard to get an overview of applications running on a cluster, as well as to create or modify individual Kubernetes resources. The Kubernetes Dashboard also reports the status of Kubernetes resources in the cluster, and any errors that have occurred. Note that to use the Kubernetes Dashboard, it must have been enabled when the cluster was initially created.
In contrast to the Kubernetes Dashboard, Container Engine for Kubernetes enables you to create and delete Kubernetes clusters and node pools, and to manage the associated compute, network, and storage resources.
To start the Kubernetes Dashboard:
- If you haven’t done so already, download the cluster’s kubeconfig configuration file and set the KUBECONFIG environment variable.
- In a terminal window, enter kubectl proxy to start the Kubernetes Dashboard
- Open a browser and go to http://localhost:8001/ui to display the Kubernetes Dashboard. Browse to the kubeconfig file for authentication.
- Click Overview to see the applications deployed on the cluster.