Table des matières

Serveur Bastion

Le bastion d’administration crée un accès unique pour l’ensemble de vos connexions. C’est l’assurance pour vous de gérer vos accès sensibles telles que l'administration du cluster.

Toute action sur un serveur critique doit impérativement être surveillée, tracée et facilement identifiable. Toute personne à droits privilégiés doit être clairement identifiée et son accès restreint.

Création utilisateur rke

Nous allons créer un utilisateur 'rke'. Cette utilisateur va nous permettre de déployer la solution kubernetes sur notre cluster.

$ useradd rke --uid 1250 --home /home/rke/ --create-home --shell /bin/bash

On se connecte avec notre utilisateur 'rke'

$ su - rke

On génère une clé SSH sur notre serveur bastion.

rke $ ssh-keygen -t rsa -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/home/rke//.ssh/id_rsa):
Created directory '/home/rke//.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/rke//.ssh/id_rsa.
Your public key has been saved in /home/rke//.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:KFBjfjKxuyhKia1wzh03QixWgXq+8EObD+T03gFrlOA rke@ubuntu-18
The key's randomart image is:
+---[RSA 4096]----+
|   .*            |
|  .+ =           |
| .o * .          |
|...= * .         |
| oE O . S        |
|o*+* =           |
|+**+B +          |
|+**= = o         |
|o oo+ .          |
+----[SHA256]-----+

Maintenant, nous allons transférer la clé ssh de l'utilisateur 'rke' vers tout les serveurs du cluster kubernetes (Master Nodes et Worker Nodes).

rke $ for i in master01 master02 master03 worker01 worker02; do
  ssh-copy-id -i ~/.ssh/id_rsa.pub rke@$i
done

Installation binaire kubectl

Récupération du binaire 'kubectl' depuis le repositorie officiel.

bastion:~$ curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
bastion:~$ chmod +x ./kubectl
bastion:~$ sudo mv ./kubectl /usr/local/bin/kubectl
bastion:~$ kubectl version --client
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.4", GitCommit:"c96aede7b5205121079932896c4ad89bb93260af", GitTreeState:"clean", BuildDate:"2020-06-17T11:41:22Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}

Kubectl Autocomplete

echo "source <(kubectl completion bash)" >> ~/.bashrc # add autocomplete permanently to your bash shell.

Installation binaire rke

Récupération du binaire 'rke' depuis le repositorie officiel.

bastion:~$ curl -s https://api.github.com/repos/rancher/rke/releases/latest | grep download_url | grep amd64 | cut -d '"' -f 4 | wget -qi -
bastion:~$ chmod +x rke_linux-amd64
bastion:~$ sudo mv rke_linux-amd64 /usr/local/bin/rke
bastion:~$ rke --version
rke version v1.0.10

Installation binaire helm3

Récupération du binaire 'helm' depuis le repo officiel.

bastion:~$ curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
bastion:~$ chmod 700 get_helm.sh
bastion:~$ ./get_helm.sh

Mise à jour du repo

bastion:~$ helm repo add stable https://charts.helm.sh/stable
bastion:~$ helm repo update

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts

Installation de KubeLinter

Cf. KubeLinter, Yaml analiser

Installation de Krew

Cf. Krew - Gestionnaire de plugin Kubectl