Part 5 – Accessing a Kubernetes Cluster on OKE

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.

  1. Install kubectl based on the OS you are running on your desktop (see the kubectl documentation).
  2. Install and configure the Oracle Cloud Infrastructure CLI
    1. Install the Oracle Cloud Infrastructure See Installing the CLI.
    2. Configure the Oracle Cloud Infrastructure See Configuring the CLI.
    3. Upload the public key of the API signing key pair
      1. In the top-right corner of the Console, click on API username, and then click User Settings to view the details.
      2. Click Add Public Key.
      3. 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).
  3. Get the get-kubeconfig.sh file and run it to download the kubeconfig file
    1. In the Console, click Containers, and then click Clusters.
    2. 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.
    3. Click the Access Kubeconfig button to display the How to Access Kubeconfig dialog box.
    4. The How to Access Kubeconfig dialog box provides the code to include in the get-kubeconfig.sh file. (Please use Google-Chrome browser)
    5. Open a new file in a text editor.
    6. Copy the code for the get-kubeconfig.sh file from the How to Access Kubeconfig dialog box and paste it into the text editor.
    7. 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.
    8. Make the get-kubeconfig.sh file executable.
    9. 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
    10. 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

    11. 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.

 

About Prasenjit Sarkar

Prasenjit Sarkar is a Product Manager at Oracle for their Public Cloud with primary focus on Cloud Strategy, Cloud Native Applications and API Platform. His primary focus is driving Oracle’s Cloud Computing business with commercial and public sector customers; helping to shape and deliver on a strategy to build broad use of Oracle’s Infrastructure as a Service (IaaS) offerings such as Compute, Storage, Network & Database as a Service. He is also responsible for developing public/private cloud integration strategies, customer’s Cloud Computing architecture vision, future state architectures, and implementable architecture roadmaps in the context of the public, private, and hybrid cloud computing solutions Oracle can offer.

Leave a Reply