Difference between revisions of "Tutorials:Install the Kubernetes infrastructure"

From Collective Computational Unit
Jump to navigation Jump to search
m
Line 8: Line 8:
 
sudo snap install kubectl --classic
 
sudo snap install kubectl --classic
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
At this point you might need to reboot or at least relog to add snap to your path, if it was not already installed previously. Try out the installation with
 +
 +
<syntaxhighlight lang="bash">
 +
> kubectl version
 +
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.2", GitCommit:"66049e3b21efe110454d67df4fa62b08ea79a19b", GitTreeState:"clean", BuildDate:"2019-05-16T16:23:09Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
 +
The connection to the server localhost:8080 was refused - did you specify the right host or port?
 +
</syntaxhighlight>
 +
 +
TODO: The version of kubernetes running on the cluster is 14.1., it might be necessary that they match. Test this sometimes.
 +
 +
You have now installed kubectl. This is a command line tool which lets you talk to Kubernetes clusters (such as our CCU compute cluster). The last error message means that kubectl did not detect a running kubernetes cluster on your local host, which probably does not come as a surprise. We will now connect to the CCU cluster.
 +
 +
 +
== Connecting to the CCU cluster ==
 +
 +
Now that you have kubectl running, attach it to our CCU compute cluster by executing the following steps:
 +
* Generate a new directory ".kube" in your home directory to host Kubernetes configuration files.
 +
* Download the following linked file called "config" and place it in the ".kube" directory.
 +
* Modify the file: replace <your.username> with your CCU username.
 +
 +
If you looked at the file a bit, you have now set up a context called "ccu" to run kubectl commands, which contains information about where to find the cluster. Switch to the context with
 +
 +
<syntaxhighlight lang="bash">
 +
> kubectl config use-context ccu
 +
</syntaxhighlight>
 +
 +
You have not set up any user credentials yet. If you try any kubectl command such as
 +
 +
<syntaxhighlight lang="bash">
 +
> kubectl cluster-info dump
 +
</syntaxhighlight>
 +
 +
you will get asked for username and password. Note that your CCU account does not work here, the process to get credentials is unfortunately a bit more involved and covered in the next step of the tutorial. However, this  shows that kubectl is now attached successfully to the cluster.

Revision as of 13:48, 1 June 2019

Install Kubernetes packages

If you want to run containers on your own system, make sure to first follow all previous guides. If you just want to use the cluster, it is sufficient to install Kubernetes kubectl command line tool as follows:

#!/bin/bash
sudo apt install snap
sudo snap install kubectl --classic

At this point you might need to reboot or at least relog to add snap to your path, if it was not already installed previously. Try out the installation with

> kubectl version
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.2", GitCommit:"66049e3b21efe110454d67df4fa62b08ea79a19b", GitTreeState:"clean", BuildDate:"2019-05-16T16:23:09Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?

TODO: The version of kubernetes running on the cluster is 14.1., it might be necessary that they match. Test this sometimes.

You have now installed kubectl. This is a command line tool which lets you talk to Kubernetes clusters (such as our CCU compute cluster). The last error message means that kubectl did not detect a running kubernetes cluster on your local host, which probably does not come as a surprise. We will now connect to the CCU cluster.


Connecting to the CCU cluster

Now that you have kubectl running, attach it to our CCU compute cluster by executing the following steps:

  • Generate a new directory ".kube" in your home directory to host Kubernetes configuration files.
  • Download the following linked file called "config" and place it in the ".kube" directory.
  • Modify the file: replace <your.username> with your CCU username.

If you looked at the file a bit, you have now set up a context called "ccu" to run kubectl commands, which contains information about where to find the cluster. Switch to the context with

> kubectl config use-context ccu

You have not set up any user credentials yet. If you try any kubectl command such as

> kubectl cluster-info dump

you will get asked for username and password. Note that your CCU account does not work here, the process to get credentials is unfortunately a bit more involved and covered in the next step of the tutorial. However, this shows that kubectl is now attached successfully to the cluster.