Table of Contents
Fiche pédagogique
- Objectifs SMART : créer des outils CLI Python & Go, publier un package interne et automatiser un opérateur de service en 12 jours.
- Durée : 14 h (6 h théorie, 8 h pratique)
- Prérequis : Git, Linux, notions DevOps.
- Niveau : Intermédiaire.
Sommaire
- Automatisation Python (Typer, asyncio, API)
- Automatisation Go (CLI, concurrency, gRPC)
- Packaging, distribution & observabilité
- Cas réels : opérateur interne & SDK CLI
- Labs, quiz, checklist
- Ressources & synthèse
1. Automatisation Python
- Tooling : Poetry, Typer, FastAPI.
- Async : asyncio, HTTPX.
- Infra APIs : SDK AWS boto3, Kubernetes Python client.
import httpx
import typer
app = typer.Typer()
@app.command()
def deploy(env: str = "dev"):
resp = httpx.post(f"https://api.example.com/{env}/deploy")
typer.echo(resp.json())
if __name__ == "__main__":
app()
2. Automatisation Go
- Structure module,
go test, Cobra CLI. - Concurrency : goroutines, context, channels.
- Clients Kubernetes : client-go, controllers, Operator SDK.
package main
import (
"context"
"fmt"
"time"
)
func main() {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
go func() {
<-ctx.Done()
fmt.Println("timeout!")
}()
// work ...
}
3. Packaging, distribution & observabilité
- Python : build wheels, publier sur Devpi.
- Go : release multi-plateforme via Goreleaser.
- Observabilité : logging structuré (
structlog,zerolog), tracing OpenTelemetry. - Sécurité : Bandit, gosec.
4. Cas réels
- Opérateur interne : Operator SDK + Argo Events pour créer namespaces et secrets.
- CLI FinOps : Typer + boto3 pour générer rapports coûts.
- Résultats : temps de provisioning -60%, erreurs humaines quasi nulles.
5. Labs, quiz, checklist
| Lab | Objectif | Livrable |
|---|---|---|
| Lab Typer | CLI déploiement + tests pytest | Package Poetry + CI |
| Lab Cobra | CLI Go + release Goreleaser | binaire multiplateforme |
| Lab Operator | Controller Go + CRD | Repo + manifestes |
Quiz : asyncio vs threads, différence goroutines/tasks, comment gèrer contexts, comment signer releases. Checklist : doc CLI, tests unitaires/integration, observabilité, sécurité.
6. Ressources & synthèse
- RealPython, Go by Example.
- asyncio docs, pkg.go.dev.
- Outils : python-fire, Bubble Tea.
- Certifs : PCAP, Go learning.
À retenir : traitez vos scripts comme du produit logiciel (tests, packaging, observabilité).