Kubernetes Cheat Sheet - pifou25/docker-jeedom GitHub Wiki
kubectl get <resource>
kubectl describe <resource> <name>
kubectl explain <resource>
kubectl logs <name>
kubectl create ns training --dry-run=client -o yaml > training.ns.yml
kubectl get service -n formation who-is-there-rs -o yaml
watch -n 0.5 kubectl get po
revient sur le ReplicaSet précédent - si existe encore
kubectl rollout undo deployment who-is-there
kubectl run -ti curl -n formation --image debian
kubectl create deployment registry --image registry:2
kubectl expose deployment registry --port 5000 --type NodePort
kubectl scale replicaset who-is-there-rs --replicas 5
kubectl describe endpoints who-is-there-rs -n formation
kubectl exec -ti -n formation <name> -- /bin/sh
kubectl attach curl -c curl -it -n formation
kubectl logs -f services/who-is-there-rs -n formation
kubectl logs -f -n formation -l app=who-is-there-lb --max-log-requests 9 --all-containers --ignore-errors
kubectl logs website -c git-clone
kubectl create deployment registry --image registry:2
kubectl expose -f app.deploy.yml --port 80 --target-port 8080 --type NodePort
Le tester avec curl:
curl 127.0.0.1:31233/v2/_catalog
docker build -t web:formation .
docker tag web:formation 127.0.0.1:31233/web:formation
docker push 127.0.0.1:31233/web:formation
https://github.com/derailed/k9s
curl -L https://github.com/derailed/k9s/releases/download/v0.26.7/k9s_Linux_x86_64.tar.gz -o k9s.tgz
tar xzvf k9s.tgz
https://gitlab.com/ctritten/kubernetes-tp-files
créer un fichier texte avec les mots de passe (format clé=valeur) dans secret
MARIADB_ROOT_PASSWORD=admin
MARIADB_DATABASE=my-app
MARIADB_USER=my-user
MARIADB_PASSWORD=my-passwd
kubectl create secret generic mon-precieux --from-env-file secrets/secret -n formation
---
apiVersion: v1
kind: Pod
metadata:
name: maria-pod
namespace: formation
labels:
app: mariadb
version: v1
spec:
containers:
- name: mariadb-co
image: mariadb:10.7.1
envFrom:
- secretRef:
name: mon-precieux
restartPolicy: Always
### Création du déploiement pour l'appli web
apiVersion: apps/v1 kind: Deployment metadata: name: webapp-dp namespace: formation spec: replicas: 3 strategy: type: RollingUpdate rollingUpdate: maxUnavailable: 1 maxSurge: 1 selector: matchLabels: app: webapp template: metadata: labels: app: webapp version: v1 spec: containers: - name: webapp-ct image: 127.0.0.1:31233/web:formation env: - name: DB_HOST value: maria-sc - name: DB_DATABASE valueFrom: secretKeyRef: name: mon-precieux key: MARIADB_DATABASE - name: DB_USER valueFrom: secretKeyRef: name: mon-precieux key: MARIADB_USER - name: DB_PASSWORD valueFrom: secretKeyRef: name: mon-precieux key: MARIADB_PASSWORD
Fait en mode impératif (ligne de commande) : déclarer 2 services, 1 pour chaque POD. Puis éventuellement un Ingress.