Kubernetes1 est aujourd'hui la référence pour orchestrer des conteneurs à grande échelle. Dans ce guide, nous expliquons comment bâtir une plateforme PaaS interne multi-tenant, de la création de l’infrastructure IaaS à la mise en production automatisée, en passant par l’orchestration Kubernetes, la gestion centralisée avec Rancher, l’intégration CI/CD et la maintenance proactive.
Prérequis
Avant de commencer, assurez-vous d’avoir :
- Un compte cloud (AWS, Azure ou GCP) avec droits d’administration
- Terraform (≥ 1.2) installé localement
- Ansible (≥ 2.10) installé localement
- Helm (≥ 3.5) installé
- Un domaine DNS configuré et pointé vers votre infrastructure
- Docker Engine et kubectl installés sur votre poste
# Installation rapide des outils (exemple Ubuntu)
sudo apt update
sudo apt install -y terraform ansible helm docker.io kubectl
Provisionnement de l’infrastructure IaaS
1. Initialisation du projet Terraform
mkdir paas-infra && cd paas-infra
terraform init
2. Configuration du provider et du réseau
# main.tf
provider "aws" {
region = "eu-west-1"
}
resource "aws_vpc" "paas" {
cidr_block = "10.20.0.0/16"
}
3. Subnets, sécurité et instances
resource "aws_subnet" "public" {
count = 2
vpc_id = aws_vpc.paas.id
cidr_block = cidrsubnet(aws_vpc.paas.cidr_block, 8, count.index)
map_public_ip_on_launch = true
}
resource "aws_instance" "control" {
count = 3
ami = "ami-0123456789abcdef0"
instance_type = "t3.medium"
subnet_id = aws_subnet.public[0].id
tags = {
Name = "paas-control-${count.index}"
}
}
4. Application du plan
terraform plan -out=tfplan
terraform apply tfplan
Configuration de Kubernetes et Rancher
1. Installation de Rancher
helm repo add rancher-latest https://releases.rancher.com/server-charts/latest
helm install rancher rancher-latest/rancher --namespace cattle-system --create-namespace \
--set hostname="rancher.example.com"
2. Récupération du mot de passe initial
printf $(kubectl get secret --namespace cattle-system bootstrap-secret -o jsonpath="{{.data.bootstrapPassword}}") | base64 --decode
Déploiement de l’application multi-tenant
1. Création des namespaces
kubectl create namespace tenant-a
kubectl create namespace tenant-b
2. Déploiement avec Helm
helm repo add webapp https://example.com/helm-charts
helm install webapp tenant-a/webapp --namespace tenant-a
Intégration CI/CD avec GitLab
.gitlab-ci.yml
stages:
- build
- deploy
build:
script:
- docker build -t registry.example.com/webapp:${CI_COMMIT_SHA} .
- docker push registry.example.com/webapp:${CI_COMMIT_SHA}
deploy:
script:
- ansible-playbook -i inventory.ini deploy-webapp.yml
Maintenance et mise à jour
1. Playbook Ansible pour upgrades
# upgrade-cluster.yml
- hosts: control
become: true
tasks:
- name: Upgrade Kubernetes
shell: kubeadm upgrade apply v1.24.0 -y
2. Sauvegarde des etcd
ETCD_POD=$(kubectl get pods -n kube-system -l component=etcd -o name)
kubectl exec -n kube-system $ETCD_POD -- etcdctl snapshot save /backup/etcd-snapshot.db
Comparaison avec d'autres solutions
- OpenShift : solution clé en main mais plus lourde
- Rancher OSS : légère et flexible, nécessite Kubernetes existant
- Platform.sh : service commercial PaaS complet
Quand choisir une alternative ?
- OpenShift : si besoin d’un support entreprise complet
- Platform.sh : pour externaliser totalement la PaaS
- Dokku : pour petits projets à faible charge
Conclusion
Cette plateforme PaaS interne multi-tenant fournit un cadre robuste pour infogérer, déployer et maintenir vos applications web. En combinant Terraform, Kubernetes, Rancher, Helm et Ansible, vous gagnez en cohérence, automatisation et résilience.