Skip to content

naqa92/video-tf-crossplane

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

runme
version
v3

Crossplane vs Terraform : Quelles différences ?

Terraform : State verrouillé + drift détecté au plan

Création d'un bucket S3 de démo avec backend S3

aws s3api create-bucket \
  --bucket tf-state-demo-zone-infra \
  --region eu-west-3 \
  --create-bucket-configuration LocationConstraint=eu-west-3
cat main.tf
tf init
tf plan
tf apply

Terminal B : tf apply (Le second apply échoue/attend : le state est verrouillé par le lock S3 natif) + idempotence

Suppression manuelle

aws s3 rb s3://tf-demo-zone-infra --force

Détéction du drift

tf plan # le bucket sera recréé
#tf apply

👉 Terraform ne répare qu’au prochain plan/apply

Si on veut automatiser, il faut mettre en place un tf plan programmé dans un pipeline CI avec détection de code d'erreurs. Exemple :

  • Exit 0 : aucun changement
  • Exit 1 : erreur
  • Exit 2 : drift détecté (diff entre code et réel)

Puis notification (Slack, e-mail, commentaire MR, création d’issue...)

Alternative : Aller sur des services managés (ex : Terraform Cloud)

Crossplane : Réconciliation en continu (pas de state)

Création d'un cluster kind

kind create cluster

Installation de Crossplane

helm repo add crossplane-stable https://charts.crossplane.io/stable
helm repo update
helm upgrade --install crossplane crossplane-stable/crossplane --namespace crossplane-system --create-namespace --wait

Ajout du Provider AWS

cat ./crossplane/provider.yaml
k apply -f ./crossplane/provider.yaml

Création du secret

kubectl --namespace crossplane-system \
    create secret generic aws-creds \
    --from-file creds=./aws-creds.conf

Configuration du Provider AWS

cat ./crossplane/provider-config.yaml
k apply -f ./crossplane/provider-config.yaml

Création d'un bucket S3 de démo

cat ./crossplane/bucket.yaml
k apply -f ./crossplane/bucket.yaml
k klock buckets

On peut : Afficher le détail du CRD

k explore buckets # plugin krew

On peut : Décrire comme n'importe quelle autre ressource

k get buckets tf-demo-zone-infra
k describe buckets tf-demo-zone-infra

On peut : Voir la composition

k tree buckets.s3.aws.m.upbound.io tf-demo-zone-infra # plugin krew

Suppression manuelle

aws s3 rb s3://tf-demo-zone-infra --force

👉 Quand tu supprimes le bucket manuellement : le contrôleur détecte l’écart et recrée automatiquement le bucket ➜ La source de vérité est l’API Kubernetes, maintenue par des controllers en boucle de réconciliation.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages