Note:

Connect to an Oracle Cloud Infrastructure Kubernetes Engine cluster using Local Access

Introduction

In this tutorial, we will guide you through connecting to an Oracle Cloud Infrastructure Kubernetes Engine (OCI Kubernetes Engine or OKE) cluster using Local Access. By the end of this tutorial, you will be able to configure your local machine to interact with your OKE cluster securely and efficiently. This connection method is essential for managing your cluster resources, deploying applications, and troubleshooting runs from your local environment. Whether you are a beginner or experienced with Kubernetes, this step-by-step approach will ensure a smooth and straightforward setup.

When you look at the networking part of the Kubernetes cluster you have different Kubernetes network architectures that can be used for deployment. For more information, see Example Network Resource Configurations.

Sometimes you want to deploy the API endpoint with a private IP address and when you do this the Kubernetes cluster cannot be managed using OCI Cloud Shell application, and also not from another machine connected to the internet. You need to select Local Access, but before we can connect with the local access we first need to set up an instance that can act as a bastion.

image

Objectives

Task 1: Verify a Kubernetes Cluster

Make sure you have a deployed Kubernetes cluster on OCI OKE.

Task 2: Create a new Linux Instance to act as Bastion

In this task, we will deploy a bastion instance in a public subnet, but when using the OCI Bastion service and session (later in this tutorial) it is better to deploy the bastion instance on a private subnet. In this tutorial, we are not doing this because we want to showcase the flexibility and various different options.

Task 2.1: Create a bastion-private-sec-list Security List with Ingress and Egress Rule

Determine the new subnet where the new bastion instance is going to be in 10.0.5.0/24. We need this to create the security lists properly.

Task 2.2: Create a bastion-public-sec-list Security with Ingress and Egress Rules

Task 2.3: Create the bastion-route-table with Internet Gateway to Add to the Bastion Instance for Internet Access

Note: Make sure that you have created an internet gateway in the VCN.

Task 2.4: Create a Regional Public Subnet (bastion-subnet) for the Bastion Instance 

Task 2.5: Add the bastion-private-sec-list to the Worker Private Subnet to Access the Worker Nodes by Bastion Instances

Task 2.6: Create OCI Compute Instance

Create the bastion instance.

Task 2.7: Get the Public IP Address of the Bastion Instance (BastionHost) to SSH

Task 2.8: Log in to the Bastion Host

Task 3: Create a Bastion Session

We can use the bastion instance as a standalone host, but we can also make use of the bastion service or bastion session. To do this we need to install the bastion plugin and create a bastion session.

What are the benefits of a bastion session?

When you deploy an instance within a private subnet, it is not directly accessible from the internet. However, by setting up a bastion and initiating a bastion session, you can make the private instance accessible. This allows the instance to act as a stepping stone for managing other resources within your OCI environment.

Task 3.1: Install the Bastion Plugin on the Instance

Task 3.2: Create the Bastion Session

Task 3.3: Get the SSH Command of the Bastion Session

Task 3.4: Log in to Bastion Host

  1. Run the following copied SSH command in the terminal.
  2. Enter yes to continue for the bastion SSH session.
  3. Enter yes to continue for the instance SSH session.
  4. Note that you are now logged in to the instance through a bastion session.

image

Note: This is a different way of connecting to the bastion instance that we showed. Now we are connecting to the bastion instance through a bastion session, and earlier we connected directly with SSH to the bastion instance.

Task 4: Set up OCI Command Line Interface (CLI)

We have successfully set up the bastion instance, the bastion, and the bastion session and we have verified connectivity, we now need to set up OCI CLI so we are able to perform CRUD (create, read, update, and delete) operations inside our OCI environment.

Task 5: Configure OCI CLI

We need to add some configuration to make sure the OCI CLI is able to authenticate on your OCI tenant so you are able to perform CRUD operations.

Task 6: Use OCI CLI in Interactive Mode

Task 7: Access the Kubernetes Cluster using OCI CLI

Next Steps

Connecting to your OKE cluster using the local access allows you to manage and interact with your cluster resources from your local environment with ease. By following the tasks outlined in this tutorial, you have set up a secure connection and can now deploy, monitor, and maintain applications on your OKE cluster. With this set up, you are equipped to handle administrative tasks, troubleshoot runs, and optimize your workflows efficiently. Keep these configurations handy for future reference, and feel free to explore further customization options to suit your specific needs.

Acknowledgments

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.