source <(kubectl completion bash) && echo "source <(kubectl completion bash)" >> ~/.bashrc
# Dans .bash_aliases alias k='kubectl' complete -F __start_kubectl k
kubectl port-forward svc/mon-service port-local:port-service
kubectl exec -it nom-container -- /bin/bash
kubectl exec -ti nom-pod -c nom-container -- bash
kubectl get pvc mon-pvc-0 -o yaml > pvc0.yml
kubectl cp archive.tar.gz namespace/mon-pod:/foo/ -c mon-container
kubectl get pod | grep Evicted | awk '{print $1}' | xargs kubectl delete pod
kubectl get po| grep Terminating | awk '{print $1}' | xargs kubectl delete pod --force
kubectl get namespace "MYNAMESPACE" -o json | tr -d "\n" | sed "s/\"finalizers\": \[[^]]\+\]/\"finalizers\": []/" | kubectl replace --raw /api/v1/namespaces/MYNAMESPACE/finalize -f -
kubectl drain --ignore-daemonsets --delete-emptydir-data mon-node
gzcat dump.sql.gz | kubectl exec -i pod-mariadb-0 -- mysql -u root -pPASSWORD ma_db
kubectl top [node|pod] nom-pod-node
kubectl get no | kubectl top no
kubectl get pod -A -o wide|grep NODE
kubectl get pod -A -o wide
kubectl exec nom-pod -- df -h
apiVersion: v1 kind: Pod metadata: name: debian-test spec: containers: - name: debian image: debian:stable-slim command: - "sleep" - "86400" volumeMounts: - name: data mountPath: /mnt/data volumes: - name: data persistentVolumeClaim: claimName: data-debian-test-0
--- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: data-debian-test-0 spec: accessModes: - ReadWriteOnce volumeMode: Filesystem resources: requests: storage: 50Gi storageClassName: csi-cinder-classic
Suite à une mise à jour du cluster, des ressources peuvent être dans une version API obsolète. Exemple :
Error: UPGRADE FAILED: unable to build kubernetes objects from current release manifest: [resource mapping not found for name: "XXXXXXXX" namespace: "" from "": no matches for kind "PodDisruptionBudget" in version "policy/v1beta1" ensure CRDs are installed first, resource mapping not found for name: "XXXXXXXX" namespace: "" from "": no matches for kind "PodDisruptionBudget" in version "policy/v1beta1"
La solution consiste à faire tourner Mapkubeapis :
helm plugin install https://github.com/helm/helm-mapkubeapis
helm mapkubeapis RELEASE
kubectl get namespace <YOUR_NAMESPACE> -o json > <YOUR_NAMESPACE>.json
# Supprimer le finalizer: kubernetes vim <YOUR_NAMESPACE>.json
kubectl replace --raw "/api/v1/namespaces/<YOUR_NAMESPACE>/finalize" -f ./<YOUR_NAMESPACE>.json
source : https://stackoverflow.com/questions/52369247/namespace-stuck-as-terminating-how-i-removed-it
Ce processus n'a été testé que chez AWS avec gp2 pour storageclass
k delete sts MON-STS
k edit pvc MON-PVC
Méthode chez OVH : https://support.us.ovhcloud.com/hc/en-us/articles/1500005033982-How-to-Resize-Persistent-Volumes
rsync -arv -e "ssh -i $(minikube ssh-key)" --rsync-path="sudo rsync" /path/to/source/files/ docker@$(minikube ip):/data/
Ressources de commandes essentielles :