How to get started with Charmed Kubernetes
Key | Value |
---|---|
Summary | Learn how to operate a production-ready Kubernetes cluster. Kubernetes is a great open-source orchestration system for cloud native infrastructure. |
Categories | deploy-applications |
Difficulty | 3 |
Author | Canonical Web Team webteam@canonical.com |
Overview
Duration: 1:00
Kubernetes is a platform for automatic deployment, scaling, and management of containerised applications. It is open source and rapidly growing in capabilities, reputation, and influence.
Charmed Kubernetes packages Canonical’s operational expertise alongside the same upstream binaries as Kubernetes, making it easily re-deployable across public clouds (AWS, GCE, Azure or Rackspace), private infrastructure (OpenStack, VMware), and even bare metal - from your laptop to the lab.
Below we will use Charmed Kubernetes to build a highly available (HA) production ready Kubernetes cluster—with 2 control plane nodes, 3 worker nodes, 3 etcd nodes, and a load balancer for the HA control plane, as well as with logging, monitoring, scaling, and all the operational tools to automate the deployment and lifecycle management of your cluster.
In this tutorial you’ll learn how to…
- Get your Kubernetes cluster up and running
- Open the K8s dashboard
- Control your cluster from the kubectl CLI client
- Deploy your first container workload
- Add extra features to your Kubernetes cluster
You will need…
- An Ubuntu One account
- An SSH key. More on using SSH keys in Juju.
- Credentials for either AWS, GCE or Azure
Deploy Charmed Kubernetes with JAAS
Duration: 8:00
To kick off the deployment, open a Charmed Kubernetes at JAAS.
The deployment is made via JAAS - Juju-as-a-Service solution from Canonical. You will need to login or create JAAS account. Make sure to add your credentials if you have not already done so before. The deployment will then take several minutes, as Juju creates new instances in the cloud and sets up the Kubernetes cluster components. Pending units are outlined in orange. Up and running ones are outlined in black.
Install client software
Duration: 3:00
Install the Juju client
In order to operate the deployment you will need to have Juju client installed locally. If you have it already installed, you may skip this step.
The Juju client is available on many platforms and distributions. If you are running Ubuntu, you can install the Juju client by running the following command:
sudo snap install juju --classic
If you are using a different Linux distribution, you have to install snapd
first. See the Snapd documentation for more information on how to install snapd
on your Linux distribution.
If you are using macOS or Windows, see Install Juju.
To verify your installation, try running the juju
command. It should prompt you to type help
, and doing so should allow you to list a list of all the Juju commands that you can use to manage your cluster.
Learn more about deploying with Juju by visiting the official documentation.
Install the Kubernetes client
In order to deploy and manage applications on Kubernetes, you will need to have the kubectl
client installed locally. If you have it already installed, you may skip this step.
Kubectl
is available on many platforms and distributions. If you are running Ubuntu, you can install kubectl
by running the following command:
sudo snap install kubectl --classic
If you are using a different Linux distribution, you have to install snapd
first. See the Snapd documentation for more information on how to install snapd
on your Linux distribution.
If you are using macOS, run: brew install kubectl
If you are using Windows, use Chocolatey:
choco install kubectl
To verify your installation, try running the kubectl
command. You should see a list of commands to control your Kubernetes cluster.
Learn more about kubectl
by visiting the official documentation.
Operate your cluster
Duration: 7:00
To operate your cluster with kubectl
you need to download the configuration needed to speak to your cluster. The first step to getting the config is to make sure you have an SSH key in your JAAS deployment of your cluster.
- To connect to JAAS from the command line you will need to register with the JAAS controller. You will only need to do this the first time:
juju register jimm.jujucharms.com
- This command will open a new window in your browser. Use Ubuntu SSO to log in and authorise your account.
- You will then be asked to enter a descriptive name for the JAAS controller. We suggest using “
jaas
”. - You can now import your SSH key from Launchpad or Github into your cluster (if you have not already done it). For instance, a user with the Github username “ghuser” would use the following command:
juju import-ssh-key gh:ghuser
- Verify your SSH key is working by running the
date
command on the first machine:
juju run --machine 0 -- date
With SSH operating properly you can now set up kubectl
.
- Fetch the credentials from the Kubernetes control plane node. First, make a directory:
mkdir -p ~/.kube
Then copy the config file:
juju scp kubernetes-control-plane/0:config ~/.kube/config
This might open a separate modal window, in which you should enter the passphrase for your SSH key you added in step 4:
- Establish a secure proxy to the Kubernetes apiserver with the following command:
kubectl proxy
-
Navigate to the Kubernetes dashboard UI through the proxy
http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
.Note: The browser may warn you that the connection is not private or secure. Bypass the warnings (via the ‘Advanced’) option. The browser will then ask you to login. The default username and password are both admin.
-
You can now use the Kubernetes Dashboard to drive your cluster:
Run your first workload
Duration: 10:00
Spin up a simple static website in your Kubernetes cluster.
-
You can run a charm action to create an example microbot web application, deploying 5 replicas inside the Kubernetes cluster:
juju run-action kubernetes-worker/0 microbot replicas=5
-
This action creates a deployment titled microbots comprised of 5 replicas defined during the run of the action. It also creates a service named microbots which binds an endpoint, using all 5 of the microbots pods. Finally, it will create an ingress resource, which points at a xip.io domain to simulate a proper DNS service
-
To see the result of this action, run:
juju show-action-output [id above]
You should get a similar response to:Note: Your FQDN will be different and contains the address of the cloud instance.
-
Copy and paste the microbot address into your web browser: microbot.xxx.xxx.xxx.xip.io. It is normal to see a 502 / 503 errors during initial application turnup.
-
You have successfully connected to a microbot container! Within a few seconds your microbot example application will be online, and load balanced across the 5 pods running the microbot application. Refresh and the hostname at the bottom should change with each request
To learn more about this, go to the Running the packaged example section in the bundle details.
That’s all folks!
Duration: 1:00
Congratulations! You have made it!
By now you should have your Kubernetes cluster up and running.
Next steps
Now that you have your production cluster, you can put it to work:
- The easy way to commoditise GPUs for Kubernetes
- Build a transcoding platform in minutes
- Transform your solution into a private PaaS
Further reading
- Experiment with the Charmed Kubernetes bundle
- Discover Kubernetes opportunities with Canonical
- Try MicroK8s for local testing
- Talk to our Kubernetes experts
Last updated a month ago.