Note:

Leverage SSH Tunneling with Oracle Cloud Infrastructure Kubernetes Engine for Secure Application Development

Introduction

image

When I got SSH tunneling with OKE working with Ali Mukadam’s help, I called it “magic.”

He responded to me with the following message:

“You called it magic, others call it Science. Where I am they are one and the same.”

The original quote is from a Thor movie:

“Your Ancestors Called it Magic, but You Call it Science. I Come From a Land Where They Are One and the Same.”

So what is this magic?

In modern application development, securing connections between local and cloud-based resources is essential, especially when working with Oracle Cloud Infrastructure Kubernetes Engine (OCI Kubernetes Engine or OKE). SSH tunneling offers a simple yet powerful way to securely connect to OKE clusters, enabling developers to manage and interact with resources without exposing them to the public internet. This tutorial explores how to set up SSH tunneling with OKE and how developers can integrate this approach into their workflow for enhanced security and efficiency. From initial configuration to best practices, we will cover everything you need to leverage SSH tunneling effectively in your OKE-based applications.

The following image illustrates the full traffic flows of SSH tunneling two different applications.

image

Objectives

Task 1: Deploy Kubernetes Cluster on OKE (with a Bastion and Operator Instance)

Make sure you have a deployed Kubernetes cluster on OKE.

Task 2: Deploy an NGINX Web Server on the Kubernetes Cluster

The operator cannot directly be accessed from the internet and we have to go through the Bastion host.

Test the New Pod/Application

Task 3: Create an SSH Config Script with Localhost Entries

To allow the SSH tunnel to work we need to add the following entry in our SSH config file located in the /Users/iwhooge/.ssh folder.

Task 4: Set up the SSH Tunnel and Connect to the NGINX Web Server using Localhost

Task 5: Deploy a MySQL Database Service on the Kubernetes Cluster

We can reach the NGINX application through the SSH tunnel, now add a MySQL database service that is running inside the OKE environment.

Task 6: Add Additional Localhost Entries Inside the SSH Config Script

Add additional localhost entries inside the SSH config script to access the new MySQL database service.

Task 7: Set up the SSH Tunnel and Connect to the MySQL Database using Localhost

Task 8: Clean up all Applications and Services

Next Steps

Securing access to OKE clusters is a critical step in modern application development, and SSH tunneling provides a robust and straightforward solution. By implementing the steps in this tutorial, developers can safeguard their resources, streamline their workflows, and maintain control over sensitive connections for multiple applications. Integrating SSH tunneling into your OKE setup not only enhances security but also minimizes the risks associated with exposing resources to the public internet. With these practices in place, you can confidently make use of your OKE clusters and focus on building scalable, secure, and efficient applications.

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.