Difficulty: beginner
Estimated Time: 35 minutes

Oracle Kubernetes Engine - Create an OKE Cluster.

INTRO

This scenario is the first part of two. In this scenario you will provision a Kubernetes Engine on Oracle Cloud Infrastructure and in the second part you will start using it. The second part scenario is here: https://www.katacoda.com/redexpertalliance/courses/oci-course/oke-redis-cache-and-functions-oci_part2

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 a solution 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 into the Kubernetes cluster.

Scenario Pre-requisites

  • For this scenario you need to have a 30 days Free Oracle Cloud Infrastructure Trial (or of course a paid account). If you have it, you are ready to go. If not, please follow this instruction to provision your trial: https://docs.oracle.com/en/cloud/get-started/subscriptions-cloud/csgsg/request-trial-subscription.html

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

  • You need to execute the scenario https://www.katacoda.com/redexpertalliance/courses/oci-course/introduction-to-oci before trying this one.

  • 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 - or at least a user in the Administrators group.

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

Scenario Description

In this scenario you will learn how to provision an Oracle Kubernetes Engine using the Quick Create Option. We will use the Oracle OCI Web Console to provision our cluster. Most of the steps will be performed using the Web Console. We will also configure our kube config file to connect to our cluster using the kubectl command line interface for managing a Kubernetes cluster. Once created the kube config file, we will extract the hostname of the

Summary

This completes the first part of 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 Kubernetes based cluster

Resources

UNDER CONSTRUCTION: Introduction to Oracle Kubernetes Engine - Part 1 - Create an OKE Cluster

Step 1 of 3

Step 1 - Create your first OKE Kubernetes Cluster

Wait for OCI CLI to be installed

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

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?

That happened because we have not created a kubeconfig file, yet.

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)

export LAB_ID=1

cs=$(oci iam compartment list)

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"

Oracle Kubernetes Engine Cluster Creation

With your 30-days free trial account you can create an OKE instance, so let's do it. We will use the quick-create wizard, that simplifies the steps. In order to do that, go to your Tenant Dashboard and then go to this menu:

OKE Menu

Once there, click on the Create Cluster blue button:

OKE Create Cluster

Select the Quick Create option, and then Launch Workflow:

OKE Quick Create Option

Once in the workflow window, give MyFirstOKE as the name, select the compartment lab-compartment; for number of nodes select 2 and leave the rest of the fields as default:

OKE Workflow

In the lower part of the window enable Kubernetes Dashboard:

OKE Enable Tiller

Finally, click on Next:

OKE Click on Next

And read the summary for your cluster:

OKE Summary

Click on Create Cluster and wait for the cluster to be created. In the home page for OKE, wait for the status to be Active (it may take around 25 minutes):

OKE Ready

You just have to wait, do not go to any other section of the Web Console, just be patient. Once the status turned into Active, you are about to be able to use it. Do not proceed until the status goes to Active.

Let's set the following variable to identify the cluster name:

export MY_CLUSTER_NAME=MyFirstOKE

Let's go the next step!