Skip to content

Instantly share code, notes, and snippets.

@flyingoverclouds
Last active October 1, 2021 10:11
Show Gist options
  • Save flyingoverclouds/c272a73e91e2dc8f59e2a28cbf036110 to your computer and use it in GitHub Desktop.
Save flyingoverclouds/c272a73e91e2dc8f59e2a28cbf036110 to your computer and use it in GitHub Desktop.
Aide mémoire Kubenetes

Aide mémoire Kubernetes (K8S)

Commandes de base

Create a new namespace

kubectl create namespace NOM_NAMESPACE_A_CREER

Get resources from a namespace

kubectl get namespace|pods|service|deployment|logs --namespace NAMESPACE_CIBLE

Get resources from ALL namespaces

kubectl get namespace|pods|service|deployment --all-namespaces

Apply a yaml file

kubectl apply --namespace NAMESPACE_CIBLE -f FICHIER_YAML

Récupérer la version du cluster K8S :

kubectl version

Détail par noeud :

kubectl get nodes

redirection de port d'un sur l'hote local

Permet de tester le fonctionnement d'un pod sans ingress ou service.

kubectl port-forward PODID LOCALPORT:CONTAINERPORT

Execution de commande dans un pod

kubectl exec -it PODID COMMAND

Lancer un shell 'sh' dans le pod 'monsuperpod':

kubectl exec -it monsuperpod sh

Copier des fichiers de/vers un container

kubectl cp PODID:FILEPATH LOCALTARGETFILEPATH
kubectl cp LOCALFILEPATH PODID:TARGETFILEPATH

ex:

kubectl cp monpod:/log/last.txt /tmp/last.txt
kubectl cp ./config.txt monpod:/tmp/new-config.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment