Deploy to Amazon EKS Using Digital.ai Deploy and Release
This how-to demonstrates how you can leverage the Digital.ai Deploy and Release applications' capabilities and deploy your application to the Amazon EKS test
and prod
namespaces.
This how-to is built using Amazon EKS as the platform of choice for illustrative purposes.
Here's a video walk-through.
Before you begin
This how-to involves working with a variety of tools and technologies such as Digital.ai Deploy and Release, the XL CLI, Digital.ai Deploy's DevOps as code (YAML files), GitHub, Amazon EKS, AWS CLI, kubectl, and so on. You can perform this task by simply following the instructions. However, being familiar with these tools and technologies can help you considerably when you try this out in your test environment.
What's the objective?
The objective is to set up an automated release and deployment pipeline—a pipeline of tools such as GitHub, DockerHub, Digital.ai Release, Digital.ai Deploy, and Amazon EKS—and have your application deployed to the Amazon EKS cluster with little human intervention.
Once you have this setup in place, all you would be doing is pushing a code change to trigger a deployment job in the automated release and deployment pipeline and have your application deployed to your test environment, verify the deployment to the test environment, and then approve the test deployment task to proceed with the deployment to your production environment.
What do you need?
- A Linux or Windows server (with root and Internet access) that has both Digital.ai Deploy and Release version 10.2.1 (or later) installed
- XL CLI
- Kubernetes plugin for Digital.ai Deploy (installed by default when you install Deploy)
- An AWS account
- An Amazon EKS cluster—with two namespaces—
test
andprod
- AWS CLI and kubectl—to create the
test
andprod
namespaces on your EKS cluster - A Docker Hub account—to push every new version of the demo application you generate to the Docker Hub repository
What do you have?
We have created a xebialabs-community/deploy-to-k8s GitHub repository that hosts the following.
- A Flask application for use with this example deployment.
- A build.sh script to create a new image of the Flask application using GitHub Actions.
- Digital.ai As-code YAML file for Deploy and Release to create:
- configuration items such as the Infrastructure, Environment, and Application in Digital.ai Deploy.
- the Digital.ai Release template, Deploy server configuration, webhook trigger, and Digital.ai Release webhook endpoint in Digital.ai Release.
- A build.yml file for use by GitHub Actions for creating new versions of the web application.
- A values.xlvals file—one each for both Deploy and Release—used to pass values for dictionary variables used in the As-code YAML files.
- A
secrets.xlvals
file—one each for both Deploy and Release—used to store and pass values for Amazon EKS, Digital.ai Deploy and Release secrets.
How does it work?
Here's a high-level overview of what you would do to set this up and what happens when you start the deployment process with a simple code commit/merge.
At the end of this exercise you would have:
- forked the xebialabs-community/deploy-to-k8s GitHub repository and cloned the same to your Digital.ai Deploy/Release server.
- installed and configured Digital.ai Deploy and Release 10.2.1 (or later).
- installed XL CLI.
- created and configured an Amazon EKS cluster.
- installed AWS CLI and kubectl.
- configured AWS CLI and kubectl.
- created two namespaces—
test
andprod
—using AWS CLI/kubectl. - created the Digital.ai Deploy configuration items (using the As-code YAML file) such as Infrastructure, Environment (both
test
andprod
deployment environments), and Application. - created the webhook HTTP endpoint (using the As-code YAML file) in Digital.ai Release.
- created the Deploy server configuration, the Digital.ai Release template and the webhook trigger (using As-code YAML files) required for orchestrating your application deployments to the
test
andprod
environments.
The deployment process starts when you make a code change to your web application, create a new pull request, and merge your pull request. Here's what the automated deployment workflow does when you merge your changes.
- You—Commit and merge your Flask application's code changes to GitHub
- Automated deployment workflow—Builds your application to create a new version and adds the new version to the Docker Hub repository
- Automated deployment workflow—Triggers a new release in Digital.ai Release to deploy the new version of the Flask application
- Automated deployment workflow—Deploys the new application version to your
test
environment in Amazon EKS - You—Verify the deployment and mark the verification task complete, which triggers the next phase of the release—deploy to
prod
- Automated deployment workflow—Deploys the new application version to your
prod
environment - You—Verify the deployment to
prod
and complete the release process
Here's a detailed step-by-step.
Step 1—Create an Amazon EKS Cluster
For illustrative purposes, this topic deals with Amazon EKS. You can have your cluster in other cloud platforms such as GKE too.
-
Log on to your AWS account and gather the
AWSAccessKeyId
andAWSSecretKey
.Create an access key if you do not have one already. For more information, see Managing access keys.
It is recommended to download and save the AWS access key file immediately after creating the access key as you cannot retrieve your Secret Access Key later.
-
Create an Amazon EKS Cluster. For more information, see Creating an Amazon EKS cluster.
While there are innumerable configurations possible for your EKS cluster, this topic assumes the EKS cluster is made up of:
- A cluster with three nodes of instance type
t2.medium
- Two namespaces—
test
andprod
. You may choose to create two separate EKS clusters instead of sharing the same cluster with two namespaces. To keep the setup simple, this topic deals with a single cluster with two namespaces.
- A cluster with three nodes of instance type
-
Gather the following information about your Amazon EKS cluster and keep them handy. The values you gather for these properties are added to the
values.xlvals
file and are passed to the As-code YAML files while creating the Deploy configuration items.- Your Amazon account's
AWSAccessKeyId
andAWSSecretKey
- The AWS region code (for example,
eu-west-2
) that hosts the EKS cluster - The EKS cluster's name
- The API server endpoint URL
- The Certificate Authority (CA) cert
Here's an example Amazon EKS cluster and its configuration—
qe-cluster
.Cluster Name:
qe-cluster
Cluster Configuration
- Your Amazon account's
Step 2—Install the NGINX ingress controller
The next step is to install an NGINX ingress controller to provide external access to the Kubernetes services in your Amazon EKS cluster.
For more information about installing the Bitnami/NGINX ingress controller, see INSTALL BITNAMI/NGINX. While this how-to uses the Bitnami/NGINX, you can install any other flavor of NGINX too.