This guide walks you, step by step, through the process of provisioning a new Kubernetes cluster using Amazon EKS and then deploying WordPress to the cluster using a Bitnami Helm chart.

Overview

This guide will introduce you to Amazon EKS by provisioning a Kubernetes cluster and deploying the Bitnami WordPress Helm chart on it. This will give you a pre-configured WordPress blog that you can start using right away. But WordPress is just an example: there are hundreds of other Bitnami applications to choose from, and they're all equally easy to set up.

You have installed the latest version of aws, the AWS command-line interface (CLI), to a location in your system path. In case you haven't, install it using these instructions.

You have installed the latest version of heptio-authenticator-aws, the Heptio Authenticator for AWS, to a location in your system path. In case you haven't, install it using these instructions.

You have installed the latest version of kubectl, the Kubernetes command-line tool, to a location in your system path. In case you haven't, install it using these instructions.

NOTE: You must use kubectl v1.10 or later with Amazon EKS.

IMPORTANT: At the time of writing, Amazon EKS is only available in the us-west-2 and us-east-1 regions. Therefore, before proceeding with the remainder of this guide, select one of these two regions in the AWS console and perform the operations listed below in that region alone.

Step 1: Generate an AWS Access Key ID and Secret Access Key

At the end of this step, you will have generated an AWS Access Key ID and Secret Access Key and created a local AWS profile to hold these credentials. If you already have an AWS Access Key ID and Secret Access Key and a local AWS profile, you can skip this step.

The first step is to generate an AWS Access Key ID and Secret Access Key, which will be used to authenticate your interaction with the Amazon EKS service. To do this:

Select the "Users" section in the left navigation bar and search for your IAM user record.

Within the user record, select the "Security credentials" tab and find the "Access keys" section.

Click the "Create access key" button.

A new key pair, consisting of an "Access Key ID" and "Secret Access Key", will be generated and displayed. The "Secret Access Key" value will not be displayed again, so accurately down the "Access Key ID" and "Secret Access Key" values displayed.

On your local system, run the following command to create an AWS profile. Enter the AWS Access Key ID, Secret Access Key and selected region when prompted.

$ aws configure

This will create a profile file in your home directory on your local system named ~/.aws/credentials. Typically, this file contains a default profile named default with your credentials. These credentials will be used when interacting with your Amazon EKS cluster.

Step 2: Create an AWS IAM service role

At the end of this step, you will have created an AWS IAM service role to handle operations related to your Amazon EKS cluster.

The next step is to create a service role that will interact with the Amazon EKS cluster. To do this:

Navigate to the AWS IAM console and log in (if you're not already logged in).

Select the "Roles" section in the left navigation bar and click the "Create role" button.

Select "AWS service" as the type of entity and "EKS" as the service. Click the "Next: Permissions" button to proceed.

Click the "Next: Review" button to proceed.

Enter a name for the service role and click "Create role" to create the role. Note the name of the service role.

Step 3: Generate an AWS key pair for the worker nodes

At the end of this step, you will have generated an SSH key pair to access your EC2 instances. If you already have an SSH key pair for the AWS region you are operating in, you can skip this step.

To generate an SSH key pair, which you will need to log in to your EC2 instances, follow the steps below:

On the "Specify Details" page, enter a name for the new stack. Click "Next" to proceed.

On the "Options" page, leave all values at their defaults. Click "Next" to proceed.

On the "Review" page, review and confirm the details of the stack. Click "Create" to proceed.

Stack creation will take a few minutes. Once complete, select the stack name in the list of available stacks and select the "Outputs" section in the lower left pane. Note the identifiers of the security group, VPC and VPC subnets.

Step 5: Create and connect to an Amazon EKS cluster

At the end of this step, you will have created an Amazon EKS cluster and configured kubectl to connect to its control plane.

At this point, you are ready to create a new Amazon EKS cluster. To do this:

At this point, your nodes are configured to join the cluster. You can check the status of each node using the command below:

$ kubectl get nodes

Step 7: Add a storage class to the Amazon EKS cluster

At the end of this step, you will have added a storage class to your Amazon EKS cluster, to enable provisioning of EBS volumes for your applications.

By default, Amazon EKS does not create a storage class for a cluster. However, many Kubernetes applications (including the Bitnami WordPress Helm chart) request persistent volumes for storage, so a storage class is required to provide EBS volumes to applications. To do this:

On your local system, create a file named storage-class.yaml and fill it with the definition below:

Get the credentials for the application by executing the commands shown in the output of helm install:

Browse to the load balancer's external IP address and you should see WordPress running. Here's what it should look like:

Step 10: Log in and start using WordPress

At the end of this step, you will have logged in to WordPress and created a new blog post.

To log in to the WordPress dashboard, follow these steps:

Browse to the WordPress dashboard, usually at the URL http://SERVER-IP/wp-admin.

Log in with the administrator credentials from the previous step.

You should now arrive at the WordPress dashboard, which allows you to manage posts, pages and comments; customize your blog with themes and plugins; import and export content; manage navigation menus; add or delete new user accounts; and much more.

You can now add a new post using the following steps:

Select the "Posts -> Add New" menu option to create a new post.

Enter a title and content for the post. You can use the formatting tools at the top of the content area to format your post and add hyperlinks or images.

Optionally, choose the format and category for your post.

Publish it immediately using the "Publish" button.

And now, when you visit your blog's front page, you should see your new post.

Congratulations! You now have a working, fully-functional WordPress blog in the cloud.

You can keep your WordPress installation up-to-date with the WordPress automatic update feature. To access this:

Log in to WordPress using the administrator account.

Select the "Dashboard -> Updates" menu item.

Review the resulting page to see if WordPress needs an update. If an update is available, you can install it by clicking the "Update Now" button. You can also re-install WordPress if needed with the "Re-install Now" button.

Useful links

To learn more about the topics discussed in this tutorial, use the links below: