Oracle Developers
Published in

Oracle Developers

Oracle Managed Kubernetes Cloud– First Steps with Automated Deployment using Wercker Pipelines

Oracle announced a managed Kubernetes Cloud service during Oracle OpenWorld 2017. Early December, I had an opportunity to work with this new container native cloud offering. It is quite straightforward:

Through the Wercker console

a new Cluster can be created on a Oracle BareMetal Cloud (aka Oracle Cloud Infrastructure) environment. The cloud credentials are provided

Name and K8S version are specified:

The Cluster Size is configured:

And the node configuration is indicated:

Subsequently, Oracle will rollout a Kubernetes cluster to the designated Cloud Infrastructure — according to these specifications.

The Cluster’s Address us highlighted in this screenshot. This endpoint will be required later on to configure the automated deployment pipeline.

This cluster can be managed through the Kubernetes Dashboard. Deployments to the cluster can be done using the normal means — such as the kubectl command line tool. Oracle recommends automating all deployments, using the Wercker pipelines. I will illustrate how that is done in this article.

The source code can be found on GitHub: https://github.com/lucasjellema/the-simple-app. Be warned — the code is extremely simple.

The steps are: (assuming one already has a GitHub account as well as a Wercker account and a local kubectl installation)

  1. generate a personal token in the Wercker account (to be used for Wercker’s direct interactions with the Kubernetes cluster)
  2. prepare (local) Kubernetes configuration file — in order to work against the cluster using local kubectl commandline
  3. implement the application that is to be deployed onto the Kubernetes cluster — for example a simple Node application
  4. create the wercker.yml file (along with templates for Kubernetes deployment files) that describes the build steps that apply to the application and its deployment to Kubernetes
  5. push the application to a GitHub repository
  6. create a release in the Wercker console — associated with the GitHub Repository
  7. define the Wercker Pipelines for the application — using the Pipelines from the wercker.yml file
  8. define the automation pipeline — a chain of the pipelines defined in the previous step, triggered by event such as a commit in the GitHub repo
  9. define environment variables — specifically the Kubernetes endpoint and the user token to use for connecting to the Kubernetes cluster from the automated pipeline
  10. trigger the automation pipeline — for example through a commit to GitHub
  11. verify in Kubernetes — dashboard or command line — that the application is deployed and determine the public endpoint
  12. access the application
  13. iterate through steps 10..12 while evolving the application

Generate Wercker Token

Prepare local Kubernetes Configuration file

Create a config file in the users/<current user>/.kube directory which contains the server address for the Kubernetes cluster and the token generated in the Wercker user settings. The file looks something like this screenshot:

Verify the correctness of the config file by running for example:

kubectl version

Or any other kubectl command.

Implement the application that is to be deployed onto the Kubernetes cluster

In this example the application is a very simple Node/Express application that handles two types of HTTP requests: a GET request to the url path /about and a POST request to /simple-app. There is nothing special about the aplication — in fact it is thoroughly underwhelming. The functionality consists of returning a result that proves that application has been invoked successfully — and not much more.

The application source is found in https://github.com/lucasjellema/the-simple-app — mainly in the file app.js.

After implementing the app.js I can run and invoke the application locally:

Create the wercker.yml file for the application

The wercker.yml file provides instructions to the Wercker engine on how to execute the build and deploy steps. This step makes use of parameters the values for which are provided by the Wercker build engine at run time, partially from the values defined for environment variables at organization, application or pipeline level.

Here three pipelines are shown:

The build pipeline use the node:6.10 base Docker container image as its starting point. It adds the source code, executes npm install and generates TLS key and certificate. The push-to-releases pipeline stores the build outcome (the container image) in the configured container registry. The deploy-to-oke (oke == Oracle Kubernetes Engine) pipeline takes the container image and deploys it to the Kubernetes cluster — using the Kubernetes template files, as indicated in this screenshot.

Along with the wercker.yml file we get templates for Kubernetes deployment files that describe the deployment to Kubernetes.

Originally published at technology.amis.nl on December 2, 2017.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Lucas Jellema

Lucas Jellema

Lucas Jellema is solution architect and CTO at AMIS, The Netherlands. He is Oracle ACE Director, Groundbreaker Ambassador, JavaOne Rockstar and programmer