Difficulty: beginner
Estimated Time: 40 minutes

Oracle Kubernetes Engine (OKE). Using the cluster

INTRO

Oracle Kubernetes Engine is the Oracle offering for a Kubernetes cluster. It is a pure Kubernetes offering with integration with the Oracle Cloud Infrastructure components, such as:

  • Load Balancer
  • OCI Compute
  • OCI Storage
  • OCI Network
  • OCI Security

If you are an Oracle Cloud Infrastructure customer that is looking for an alternative to deploy Kubernetes, OKE is a good option for that. You can use the Quick Create option, and in less than 20 minutes you will have a full Kubernetes cluster formed by:

  • Three (3) nodes
  • VCN
  • Internet Gateway
  • NAT Gateway

Plus the option to provision Kubernetes Administration Dashboard, as well as Tiller.

Scenario Pre-requisites

  • For this scenario you need to finalize the scenario: https://www.katacoda.com/redexpertalliance/courses/oci-course/oke-redis-cache-and-functions-oci_part1

  • You need to execute the scenario https://www.katacoda.com/redexpertalliance/courses/oci-course/oke-redis-api-server-reverse-proxy before trying this one. Because there you will create the OCI compute instance that will server as a reverse proxy to connect the Katacoda environment (through standard port 443) to the Kubernetes cluster (that listens at port 6443). That scenario will give you an IP address (for the NGINX server) that you will use in this one to make kubectl connect to.

  • Some understanding of kubectl and Kubernetes concepts are desirable in order to follow this scenario, but if you do not yet have those, you can follow it as well.

  • The user that you will use to manage the cluster using kubectl will be the tenant administrator that you will get after provisioning your 30 days free trial instance

  • The user that we are going to use to publish the docker image into OCIR (Oracle Container Registry) is your tenant administrator created in the OCI Lab Preparation scenario

Scenario Description

Once you have your cluster (Part 1 https://www.katacoda.com/redexpertalliance/courses/oci-course/oke-redis-cache-and-functions-oci_part1) we will deploy an application based on Redis and Go. It consists of two Pods - each with a single container. One based on the standard Redis container image and the other one on a custom container image with a Go application.

You will also learn:

  • How to configure your Oracle Cloud Infrastructure Command Line Interface (OCI CLI) to create the Kubernetes config file in order to manage your cluster using kubectl
  • How to push a Docker image to OCIR (Oracle Cloud Infrastructure Registry).
  • How to configure a Load Balancer on the Kubernetes Cluster for external services access
  • How to deploy an application to the K8S Cluster
  • How to publish the application through a K8S Service - to make it accessible outside the cluster
  • How to configure replicas for your application - to make it scale out to multiple pod-instances
  • How to dynamically scale your replicas, based on CPU consumption

Summary

This completes the Oracle Kubernetes scenario.

In this scenario, you've learned:

  • How to use the OCI web console to use the quick create wizard to create your first OKE cluster
  • You've also learned how to create a kube config file for an Oracle Kubernets based cluster
  • You've learned how to create namespaces, services, deployments, secrets
  • You've learned how to connect and use Oracle Containers Registry (OCIR)
  • You've learned how to push an image into OCIR
  • You've learned how to deploy a REDIS service and a Golang based API service

Resources

UNDER CONSTRUCTION: Introduction to Oracle Kubernetes Engine - Part 2

Step 1 of 7

Step 1 - Install CLI and set the required environment variables

Wait for OCI CLI to be installed

IMPORTANT NOTE: Do not proceed if you have not perfomed steps of these both scenarios:

You need to provide details on the OCI tenancy you will work in and the OCI user you will work as. Please edit these two files:

  • ~/.oci/config
  • ~/.oci/oci_api_key.pem

If you do not have the OCI config file, nor the oci API key yet, you can go through these steps: https://www.katacoda.com/redexpertalliance/courses/oci-course/oci-lab-preparation-cloud-trial

Once you have the config file and the api key, copy their contents in ~/.oci/config and ~/.oci/oci_api_key.pem respectively. Remember that in this scenario you will be working with a newly created 30 day free trial OCI instance, and you will be using the administrator of your tenant, which is the user you created when the tenant was provisioned

export PATH=/root/bin:$PATH

Do not continue until you see the file /root/allSetInBackground appear. If it appears, then the OCI CLI has been installed and is connected to your tenant.

Try out the following command to get a list of all namespaces you currently have access to - based on the OCI Configuration defined above.

oci os ns get

If you get a proper response, the OCI is configured correctly and you can proceed. If you run into an error, ask for help from your instructor.

Let's also test that kubectl install and working properly, execute the following: kubectl version

You should receive something like this:

Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.5", GitCommit:"e6503f8d8f769ace2f338794c914a96fc335df0f", GitTreeState:"clean", BuildDate:"2020-06-26T03:47:41Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?

Let´s also create the following environment variables, that we will use in the next steps:

export REGION=$(oci iam region-subscription list | jq -r '.data[0]."region-name"')
export REGION_KEY=$(oci iam region-subscription list | jq -r '.data[0]."region-key"')
export USER_OCID=$(oci iam user list --all | jq -r  '.data |sort_by(."time-created")| .[0]."id"')
export TENANT_OCID=$(grep -i 'tenancy' $HOME/.oci/config  | cut -f2 -d'=' | head -1)
cs=$(oci iam compartment list)

export LAB_ID=1

Let's get the compartment ID first: export compartmentId=$(echo $cs | jq -r --arg display_name "lab-compartment" '.data | map(select(."name" == $display_name)) | .[0] | .id')

Let's just echo it: echo "Compartment lab-compartment OCID=$compartmentId"

In Part 1 of the OKE Scenario you wrote down the name of your cluster, if you've followed the instructions your cluster name is MyFirstOKE. Let's set that as an environment variable:

export MY_CLUSTER_NAME=MyFirstOKE

If you've set a different name, please set the variable accordingly.