K3s
These steps build a kubernetes cluster using k3s.
k3s is an extremely light-weight but capable kubernetes distribution.
Install Kubernetes
Login to your host and install docker.
Install the base kubernetes k3s package.
- curl downloads the k3s installer.
- | is the pipe command chaining multiple commands together.
- INSTALL_K3S_EXEC… sets an environment variable instructing the install to skip k3s’ default ingress controller traefik.
- sh - runs the result of the previous step in a shell (in this case, the k3s install).
Copy config file to default location & install kubectl
Create a folder and move the kubernetes config file to a default location to help further standardize this kubernetes install.
What is the kubernetes config file?
- Kubernetes distributions create a config file that describe the cluster and how to access it.
- These next few steps move the k3s config file to the default spot where kubectl will look & secure the file to avoid errors later.
- mkdir is the linux make directory command.
- -m700 limits the permissions to just our user (preventing security warnings later)
- ~/.kube is the standard folder location for the config file.
Export the config file to the folder you created.
Ensure you are the file’s owner (prevents security warnings/issues later).
Install kubectl
k3s comes with a slightly modified kubectl command. There’s nothing wrong with it- but to make sure kubernetes works in a standard way across all tutorials, we’ll install and use the official kubectl.
Download kubectl.
What is kubectl?
- Kubernetes’s interface is an API. We need a way to interact with it.
- kubectl is a well organized/documented command line tool to achieve this. Running
kubectl
will show you the myriad of options available.
The weird bonus curl command in the middle simply gets the most current version number for downloading in the main curl command. #InceptionButWithCurl
Install.
:checkered_flag: Checkpoint
To check that everything works, run the following.
If you see a response indicating a READY
status, congratulations :tada:! You have kubernetes.
Final config for k3s
We skipped the k3s ingress controller during install. We’ll install nginx with the command below.
New Ingress, who dis?
By default, Kubernetes sets up a virtual network between the containers. This lets application components communicate with each other and (generally) the internet.
We need an ingress controller to manage cluster access from the outside. It’s like adding a gate to a walled city with guards directing traffic. It allows access to approved locations and prevents unauthorized requests.
Next steps
With kubernetes running, move to next step on the left sidebar.