Deploy Kubernetes Cluster On-Premises

Objectives

  1. Deploy simple master (single) and worker node (single) Kubernetes cluster for demo purposes
  2. Configure kubectl
  3. Use Helm to deploy WordPress to a cluster

Before you get started

To use Kublr, you’ll need to download and install Kublr Demo/Installer at https://kublr.com/demo/

Prerequisites

System Requirements for the cluster nodes

  1. x86 64-bit hardware

  2. Hardware recommendation

  3. Supported OS on nodes:

    • RHEL 7.2+ or Ubuntu 16.04 LTS
    • RHEL 8 is supported only in Kubernetes v.1.17 and selinux must be in permissive mode
  4. Root access to each node

  5. Nodes are connected in your network and Kublr Demo/Installer configured IP is accessible from these nodes (ping)

  6. From your nodes, firewall rules should allow traffic to Kublr Demo/Installer on ports 9080 / 9443

  7. 100Mbs stable internet connection

  8. Kublr Demo/Installer should be correctly configured to be accessible in your local network. It is critical that you provide the correct IP address during the virtual machine startup. If you skipped this step, please re-run provisioning and configure your firewall rules to allow traffic to your computer.

Re-provisioning Kublr Demo/Installer

If you would like to install clusters on-premises, but you have already started Kublr Demo/Installer without option KUBLR_HOST or your IP address has been changed (for example switch network), please correct KUBLR_HOST to access your computer from the network. Typically, it is your computer’s IP address, but it may be different if you use NAT:

docker exec -i kublr /bin/bash -c 'echo "KUBLR_HOST=HOST_IP:HOST_PORT" > /ip.external'
docker restart kublr

This will reconfigure Kublr to use a proper DNS/IP address for the installation scripts used on your nodes.

Determine Your Own IP Address

Creating a cluster in your machine’s network is simple. Use your machine’s IP address for this network. If you don’t know how to get the IP address, contact your system administrator or read your OS manual.

To install Kublr clusters in a different network on complex network topologies, provide the IP address of your machine from that network.

Creating On-Premises Cluster in Kublr

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

See some cluster parameters description here.

To add a new on-premises 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 “Bring Your Own Infrastructure”.

  6. Specify Cluster Name.

  7. Select Kubernetes Version. On-Premises-Add Cluster-General Settings

  8. If necessary, expand the Advanced Options and set them.

  9. Scroll to the Master Configuration section.

  10. Specify the parameters of the master node(s) of your cluster as described below.

  11. From the Masters list, select the number of master or management nodes.

  12. If more than one master is selected, set the Load Balancer Address.

  13. Select Installation Type:

    • Automated using SSH: for this type, set User Name, SSH Key Name and, for each master, IP/DNS of Matster X.
    • Manual: for this type, set IP/DNS of Matster X for each master. Additionally, for this type of installation, endpoints should be specified on the Settings page. On-Premises-Add Cluster-Master Configuration
  14. If necessary, expand the Advanced Options and set them.

  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 Installation Type:

    • Automated using SSH: for this type, set User Name, SSH Key Name and required number of Node Addresses.
    • Manual: for this type, set the Nodes parameter. Additionally, for this type of installation, endpoints should be specified on the Settings page. On-Premises-Add Cluster-Instance Group Configuration
  18. 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

  19. Optionally, scroll to the Features section.

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

    • Logging
    • Monitoring
    • Ingress Controller On-Premises-Add Cluster-Features Configuration
  21. If necessary, expand the Advanced Options and set them.

  22. 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.”

  23. In the notification window, click OK.

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

  24. Open Terminal and login to the master node machine with ssh:

ssh <user_name>@192.168.31.201

After you login to the machine you may need to change current user to root:

sudo -i

Insert the instruction copied earlier in command line:

curl 'http://192.168.99.106:9080/api/install/5a7a04dc7556e10001193f82/download?nodeGroup=master&nodeOrdinal=0' -o ./kublr-install.sh; chmod a+x ./kublr-install.sh; ./kublr-install.sh

You will see the following message for login Masters setup script

Enter the username and password of the user you are logged into Kublr Demo/Installer Masters setup script

At the end you will see Masters setup script

  1. In Kublr Demo/Installer UI Master Node status should be OK Masters Status
  2. Copy the instructions for Worker Node and do the same as for Master Node Work Nodes script

Open Terminal and login to the worker node ssh:

ssh <user_name>@192.168.31.204

After you login to the machine you may need to change current user to root:

sudo -i

Insert the instruction copied earlier in command line:

curl 'http://192.168.99.106:9080/api/install/5a7a04dc7556e10001193f82/download?nodeGroup=default' -o ./kublr-install.sh; chmod a+x ./kublr-install.sh; ./kublr-install.sh

Enter the username and password of the user. You will be logged into Kublr and should wait until the installation is complete Work Nodes Complete

Go into the Kublr UI and wait until cluster is switched to running status On-premises cluster is Running

kubectl

Install and Configure kubectl

Additional information can be found here

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

Copy Kublr config file

To retrieve config from Kublr */:

  1. Click on the cluster in the cluster list to access the cluster details page
  2. On the overview tab, download the config file Config File
mkdir ~/.kube
cp ~/Downloads/config.yaml ~/.kube/config
kubectl cluster-info

Helm

Install and use Helm to deploy WordPress to your cluster

Install Helm. Click here for detailed guidelines.

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

Install WordPress

By default both WordPress and MariaDB require support for Persistent Volume storage provisioner. Configuration of that goes beyond the scope of the Quickstart, so install Wordpress with persistence disabled. Also, for on-premises installation, use Service with Type = NodePort.

Note: Additional configuration parameters for WordPress and MariaDB are available. See documentation at https://github.com/kubernetes/charts/tree/master/stable/wordpress and https://github.com/kubernetes/charts/tree/master/stable/mariadb, respectively.

helm install stable/wordpress --name wordpress --set persistence.enabled=false,serviceType=NodePort,mariadb.persistence.enabled=false
export SERVICE_PORT=$(kubectl get svc --namespace default wordpress-wordpress -o jsonpath='{.spec.ports[?(@.name=="http")].nodePort}')
export SERVICE_IP=$(kubectl get nodes -o jsonpath='{.items[0].status.addresses[?(@.type=="InternalIP")].address}')
echo http://$SERVICE_IP:$SERVICE_PORT/admin
echo Username: user
echo Password: $(kubectl get secret --namespace default wordpress-wordpress -o jsonpath='{.data.wordpress-password}' | base64 --decode)

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

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