Creating Kubernetes Cluster on AWS with Kublr

Prerequisites

  • The Kublr Demo/Installer must be installed. If you haven’t done that yet, please refer to the Installation Guide for the Kublr Demo/Installer.
  • To deploy a cluster in your AWS account with Kublr, you need to create an AWS policy and API Access Key as described here.

Overview

Steps below describe how to use Kublr to create a cluster in Amazon Web Services (AWS) infrastructure and deploy a simple application (WordPress). The following steps are described:

  1. Connecting AWS and Kublr.
  2. Creating Kubernetes cluster with Kublr.
  3. Installing and configuring kubectl.
  4. Application example: deploying WordPress to cluster using Helm.

Connecting AWS and Kublr

  1. Log into Kublr using your credentials.

  2. On the left menu, click Credentials.

  3. Click Add Credentials. Add Credentials

  4. Set Credentials Type to “AWS Credentials”.

  5. Enter Credentials Name.

  6. Enter Access Key from AWS Management Console / IAM (see above).

  7. Enter Secret Key from AWS Management Console / IAM (see above).

  8. Select AWS partitions. You can select one of the following:

    • “aws” for AWS standard partition
    • “aws-cn” for AWS China partition
    • “aws-us-gov” for AWS GovCloud (US) partition
    • enter a custom partition (this may be used for example to work with AWS US top secret region)

    Note If you do not select any value, the “aws” standard partition is used.

  9. Click Save Credentials. The “Credentials have been successfully created.” popup is displayed.

  10. To verify if credentials are valid and ready to be used, mouse over the created credentials and click the displayed Test button. Verify Credentials Verification success popup is displayed. Verify Credentials Success

  11. Click Ok.

Creating Kubernetes Cluster on AWS with Kublr

To add a new cluster:

  1. On the left menu, click Clusters.

  2. Click Add Cluster. Add New Cluster The Select Installation Type dialog is displayed.

  3. In the Select Installation Type dialog, select Platform or Cluster.

  4. Click Continue Setup. Installation Type - Cluster The add cluster/platform dialog is displayed.

  5. Set Provider to “Amazon Web Services”.

  6. From the Credentials list, select previously created AWS credentials.

    If credentials were not created previously, use Add New Credentials.

  7. Specify Cluster Name.

  8. Set:

    • Region - it is possible to select from the list (with filtering “as you type”) (e.g., “us-gov-west-1” for AWS GovCloud (US), entering the values manually is not supported in the UI, although you can specify any string for the region in the custome cluster spec)
    • Kublr Agent
    • Kubernetes Version AWS-Add Cluster-General Settings
  9. Optionally, set Advanced Options.

  10. Use the INSTANCES tab to set:

  11. Use the FEATURES tab to select and configure FEATURES that you want to include into your cluster. AWS-Add Cluster-Features Configuration

  12. Click the REVIEW & CREATE tab.

  13. Review your cluster parameters.

  14. At the bottom of the dialog, click CONFIRM AND INSTALL.

    A notification is displayed “Your cluster is being created. It might take a few minutes.”

  15. In the notification window, click OK.

    Your new cluster page is displayed on the Events tab showing the cluster creation progress.

kubectl

Installing and Configuring kubectl

For detailed instuctions, see the Install and Set Up kubectl article in Kubernetes documentation.

For Mac users:

curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl

For Windows users:

  1. To download kubectl v.1.10.3, click this link.

  2. Include the path with the kubectl executable to PATH environment variable.

    For more information about adding tool locations to PATH variable, refer to this article in Microsoft documentation.

  3. See additional information in the Install and Set Up kubectl article in Kubernetes documentation.

Copying KubeConfig File

To retrieve the config from Kublr:

  1. Click on cluster in the cluster list to access the cluster details page.
  2. On the overview tab, download the config file.

For Mac users:

mkdir ~/.kube
cp ~/Downloads/config.yaml ~/.kube/config

For Windows users:

cd %HOME%
mkdir .kube
copy %HOME%\Downloads\config.yaml .kube\config

Check that kubectl is working and using the correct config file:

kubectl config view
kubectl cluster-info

Application Deployment Example

Below is the example of how to deploy a simple application (WordPress) into your cluster using Helm.

Installing Helm

Install helm Click here for detailed guidelines.

For Mac users:

curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > get_helm.sh
chmod +x get_helm.sh
./get_helm.sh --version v3.15.4

For Windows users:

  1. Download helm version 3.15.4 from here.
  2. Extract helm-v3.15.4-windows-amd64.zip to the directory where kubectl is saved.

Installing WordPress

helm install bitnami/wordpress --generate-name

NOTE: It may take a few minutes for the LoadBalancer IP to become available.

For Mac users:

export SERVICE_IP=$(kubectl get svc --namespace default wordpress-wordpress -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
echo http://$SERVICE_IP/admin
echo Username: user
echo Password: $(kubectl get secret --namespace default wordpress-wordpress -o jsonpath='{.data.wordpress-password}' | base64 --decode)

Install helm output Open the browser and navigate to the URL from console output.

For Windows users:

  1. Run the following commands to get hostname and password:
kubectl get svc --namespace default wordpress-wordpress -o jsonpath='{.status.loadBalancer.ingress[0].hostname}'
kubectl get secret --namespace default wordpress-wordpress -o jsonpath='{.data.wordpress-password}
  1. Navigate to http://%hostname%/admin, where %hostname% is the hostname you got from the kubectl
  2. Decode admin password with https://www.base64decode.org/

Congrats! You just deployed your first app in a Kubernetes cluster with Kublr.

See Also

Specific AWS Scenarios: