How to create a cluster
This page shows you how to create a cluster
Example
Section titled “Example”You can see clusters example at clusters example
Create your clusters directory
Section titled “Create your clusters directory”A clusters directory is a directory that contains one or more cluster directory.
In your .bashrc
export KUBEE_CLUSTERS_PATH=~/kubee/clustersCreate your clusters directory
mkdir -p "$KUBEE_CLUSTERS_PATH"Create your cluster
Section titled “Create your cluster”Create a cluster directory
Section titled “Create a cluster directory”Create a cluster directory
KUBEE_CLUSTER_NAME=my-clustermkdir -p "$KUBEE_CLUSTERS_PATH/$KUBEE_CLUSTER_NAME"Create a cluster values files
Section titled “Create a cluster values files”touch "$MY_CLUSTER_PATH/values.yaml"Create your environment
Section titled “Create your environment”Environment variables are set up in .envrc
touch "$KUBEE_CLUSTERS_PATH/$KUBEE_CLUSTER_NAME/.envrc"Set the infra value env
Section titled “Set the infra value env”Set at minimal the following environment variables in your cluster values files:
- the full qualified server hostname. ie
server-01.example.com - the server ip
- the k3s token - A random secret value
Example:
- in the console, generate a k3s token
with `openssl rand -base64 64 | tr -d '\n'- use it in
.envrc:
export KUBEE_INFRA_K3S_TOKEN='bib7F0biIxpUUuOJJpjs9EgzqViHjAVna3MyxGbTq++gjXf6tm7y5c7' # don't change it- With a password manager such as pass or gopass
# once to store your token# pass insert kubee/k3s/tokenexport KUBEE_INFRA_K3S_TOKEN=$(pass kubee/k3s/token)- Set the values in your cluster values file
kubernetes: k3s: token: '${KUBEE_INFRA_K3S_TOKEN}' hosts: servers: - fqdn: 'server-01.example.com' ip: '188.245.43.202' all: connection: username: root type: 'ssh'- Check that all cluster infra values has been set by printing the inventory
kubee --cluster "$KUBEE_CLUSTER_NAME" cluster confk3s_cluster: children: server: hosts: node-name.example.com: ....Connection: Set your cluster private key file
Section titled “Connection: Set your cluster private key file”By default, kubee will load and use:
- the ssh agent key if running
- or the default ssh private key files.
If you don’t use them, you can define your ssh private file via one of this 2 environment variables in the cluster
.envrc file:
KUBEE_INFRA_CONNECTION_PRIVATE_KEY_FILE: a private key path (without any passphrase)KUBEE_INFRA_CONNECTION_PRIVATE_KEY: the private key content
Example .envrc file:
- From a file
export KUBEE_INFRA_CONNECTION_PRIVATE_KEY_FILE=~/.ssh/server_01_rsa- From a secret store such as pass
export KUBEE_INFRA_CONNECTION_PRIVATE_KEYKUBEE_INFRA_CONNECTION_PRIVATE_KEY=$(pass cluster_name/ssh/private_key)You can check that you can connect to your cluster by pinging it
kubee --cluster "$KUBEE_CLUSTER_NAME" cluster pingYou should get
server-01.example.com | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python3" }, "changed": false, "ping": "pong"}Execute the cluster installation
Section titled “Execute the cluster installation”Once, you can connect to your cluster, you can install it with the play command
Example:
kubee --cluster "$KUBEE_CLUSTER_NAME" cluster playThe play command is idempotent, meaning that you can run it multiple times.
If the app is:
- not installed, it will install and configure it
- installed, it will configure it
Install applications in the Kubernetes app
Section titled “Install applications in the Kubernetes app”With kubee helmet, you can install apps with any kubee charts
Example:
- Install the Traefik proxy
kubee --cluster "$KUBEE_CLUSTER_NAME" helmet play traefik- Install
Cert Manager
kubee --cluster "$KUBEE_CLUSTER_NAME" helmet play cert-manageror install any other Kubee Charts