Section 1: Steps to set up a K8s cluster using Platform9

1.1 Pre-Requisites for PMK Cluster


  • 1. Platform9 Account
  • 2. To create a K8s Cluster on AWS using Platform9, you require an AWS Account with the following prerequisites.
  • 3. DockerHub Account

1.2 K8s Cluster creation on AWS


Steps to create a Kubernetes cluster on Amazon AWS using Platform9

  • 1. Login to Platform9 using your account credentials.
  • 2. A dashboard page opens up after you login to Platform9 account as shown here

    Continuous delivery containers


  • 3. Before you proceed with creating a cluster on AWS, you need to add a CloudProvider in Platform9 by clicking the Infrastructure section on the left side panel and providing your AWS accesskey and secretkey.

    cloud native architecture


  • 4. Then create the cluster by clicking Add Cluster from the Clusters tab

    kubernetes cluster


  • 5. Select Amazon AWS option and then click Deploy with AWS

    cloud native


  • 6. Fill in the details by providing a name for your cluster and selecting the Cloud Provider already created in Step 3

    go cloud native


  • 7. Complete the cluster addition with information regarding Network Info, Advanced Configuration and then Review the completed details before you click on the Complete button.


  • 8. After successful cluster creation, you should see the following screen with the details of the newly created cluster. This page shows resource usage metrics of all the created clusters.

    AWS deployment


Section 2: Steps to configure your client machine

2.1 Download the kubeconfig file of the newly created K8s cluster from the Platform9 Console

  • a. Click Access your cluster and then Api Access in the dashboard panel.

    kubernetes cluster

  • b. Select your cluster in the list and then download the kubeconfig

    kubernetes configuration



2.2 Place the kubeconfig file in ~/.kube/config in the client machine (create ~/.kube if it does not exist)

  • a. Try to access the K8s cluster using kubectl command and verify successful cluster creation.
    For example “kubectl get ns” should show you the list of namespaces in the cluster .

    kubernetes



2.3 Create a storage class via Platform9 console in order to deploy stateful services. Here are the steps needed to create a default storage class using Platform9

  • a. Navigate to the Storage Classes section in the left side panel.
  • Click +Add Storage Class.
  • Make sure you enable the checkbox "Use as Default Storage Class".

    K8s

Section 3: App Deployment through HyScale onto the PMK K8s cluster

You can use the same client machine for the sample application deployment using HyScale

3.1 Prerequisites

In order to deploy your service to K8s, you must have the following configurations and installations in place on your machine from which you wish to deploy your application.

  • a. Docker 18.09.x or above. Your Linux user should be part of the docker group and docker.sock should be present at /var/run/docker.sock (Default location)
  • b. Kubernetes authentication credentials kubeconfig file having the cluster token should be placed at $HOME/.kube/config
  • Image registry credentials should be at $HOME/.docker/config.json . Make sure config.json has the latest auth creds by logging into the image registry using ‘docker login’ prior to deployment.

3.2 Installation of HyScale

For Linux users open your terminal and enter the following command.


$ curl -sSL https://get.hyscale.io | bash

For Mac and Windows users follow these instructions



3.3 Clone the hyscale github repository which contains sample applications in the examples folder:


$ git clone https://github.com/hyscale/hyscale


3.4 Change directory to the ‘hrms’ application in the examples folder as shown below


$ cd hyscale/examples/hrms


3.5 Here in this hrms examples directory you can find the HyScale specification (hspec) of the two services of the HRMS sample application.

In order to deploy your service to K8s, you must have the following configurations and installations in place on your machine from which you wish to deploy your application.

  • hrdatabase
    • a. hrdatabase is a stateful service (mysql) which persists data to /var/lib/mysql. For this, we need a PV, PVC (volume related resources) in Kubernetes.
    • b. Hyscale automatically does this using the default storage class existing in the K8s cluster. So make sure you have a default storage class with kubernetes.io/aws-ebs provisioner as mentioned above.
  • frontend
    • a. frontend is a Java based web service that runs on Tomcat application server.


3.6 Make sure you login to the dockerhub registry in the client machine using "docker login registry.hub.docker.com" with your dockerhub credentials.



3.7 Replace {{username}} with your dockerhub username in the hspec files found at frontend/frontend.hspec and hrdatabase/hrdatabase.hspec



3.8 Deploy the HRMS application. Inside the hrms folder on your client machine execute the hyscale deploy command


$ hyscale deploy service -f hrdatabase/hrdatabase.hspec -f frontend/frontend.hspec -n hrms-dev -a hrms

-n indicates the namespace to be used.
       HyScale will create the namespace if not present
-a indicates the application name

Here is how the output might look.


app deployment

3.9 After successful deployment you should be able to see the URL at the end of the output as Server IP. Access the sample application at this URL by appending /hrms as the context path: http:///hrms


Section 4: Some additional useful commands

4.1 Here is the command to check the app status using HyScale


$ hyscale get app status -a hrms -n hrms-dev
cloud deployment

4.2 Command to get logs using HyScale.


$ hyscale get service logs -s hrdatabase -a hrms -n hrms-dev
delivering cloud-native applications

Summary

The combination of Platform9 and HyScale offers teams a simple and fast way to spin up a cluster on any infrastructure taking advantage of Platform9’s SaaS management and then leverage HyScale to automatically containerize & deploy apps to kubernetes in an app-centric approach without K8s jargon or long manifests.


NOTE: The commands, services, configurations and examples shown in this document are only for demonstration purposes. Security aspects relating to the services, example database, passwords, etc should be considered before deploying.

Try HyScale



References

HyScale Tutorials
HyScale Command Reference
Platform9 AWS Cluster setup