Create a Kubernetes cluster on AWS with Kublr

Prerequisites

To deploy a cluster in your AWS account with Kublr, you need to create an AWS policy and an AWS API Access Key. Please refer to Register AWS Policy, create User and Create API Credentials.

Overview

This document describes the steps necessary to show how Kublr works by creating a cluster in an Amazon Web Services infrastructure and deploying a simple application (WordPress). It contains the following steps:

  1. Deploy Kublr Cluster to AWS infrastructure.
  2. Open deployed Kublr Cluster.
  3. Configure kubectl.
  4. Use Helm to deploy WordPress to the cluster.

Connect Kublr and create a Cluster AWS

Connect 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. Click Save Credentials. The “Credentials have been successfully created.” popup will be displayed.
  9. 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 will be displayed. Verify Credentials Success
  10. Click Ok.

Create a Kubernetes Cluster in Kublr

Powered by Kublr, Vanilla Kubernetes Cluster does not include any advanced Kublr features, suitable for running workloads.

To add a new cluster:

  1. On the left menu, click Clusters.
  2. Click Add Cluster. Add New Cluster The Select Intallation Type dialog is displayed.
  3. In the Select Intallation Type dialog, click Cluster.
  4. Click Continue Setup. Installation Type - Cluster The ADD CLUSTER dialog is displayed.
  5. In the ADD CLUSTER dialog, set Provider to “Amazon Web Services”.
  6. From the Credentials list, select previosly created AWS credentials.
  7. Specify Cluster Name.
  8. Set:
    • Region
    • Kubernetes Version AWS-Add Cluster-General Settings
  9. Scroll to the Master Configuration section.
  10. Specify the parameters of the master node(s) of your cluster as described below.
  11. Select Instance Type from the list.
  12. From the Masters list, select the number of master or management nodes in correspondence with the selected Instance Type.
  13. From the Operating System list, select the host OS for virtual machines in the cluster. AWS-Add Cluster-Master Configuration
  14. Optionally, select Public SSH Key from the list.

  15. Scroll to the Instance Group section (default name group1).

  16. Specify the parameters of the work node(s) in your group as described below.

  17. Select Instance Type from the list.

  18. To select the number of work nodes in a group, do one of the following:

    • In the Nodes field, set the number of work nodes.
    • Select the Auto-Scaling option, and then set the Min Nodes and Max Nodes limitations.
  19. From the Operating System list, select the host OS for virtual machines in the cluster.

  20. If necessary, set your own name for the instance group.

    Note You can also clone or delete the current instance group, or add another one. Instance Group-Operations

  21. Optionally, scroll to the Features section.

  22. If necessary, add features to your cluster, specifying parameters under:

    • Centralized Logging
    • Centralized Monitoring
    • Ingress Controller AWS-Add Cluster-Features Configuration
  23. At the bottom of the ADD CLUSTER dialog, click Confirm and Install.

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

  24. In the notification window, click OK.

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

kubectl

Install and Configure kubectl

For more details, please refer to the official 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. Download https://storage.googleapis.com/kubernetes-release/release/v1.10.3/bin/windows/amd64/kubectl.exe
  2. Include the path with the kubectl executable to PATH environment variable. More details: https://msdn.microsoft.com/en-us/library/office/ee537574(v=office.14).aspx
  3. See additional information here

Copy 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 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

Helm

Install and Use Helm to Deploy WordPress to Your Cluster

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 v2.9.1

For Windows users:

  1. Download helm version 2.9.1 from here: https://github.com/kubernetes/helm/releases:
  2. Extract helm-v2.9.1-windows-amd64.zip to the directory where kubectl is saved

Initiate and test Helm installation:

helm init

Install WordPress

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

helm install stable/wordpress --name wordpress

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}
  2. Navigate to http://%hostname%/admin, where %hostname% is the hostname you got from the kubectl

  3. Decode admin password with https://www.base64decode.org/

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