1
1
mirror of https://github.com/namibia/awesome-cheatsheets.git synced 2024-12-22 01:58:54 +00:00

Merge pull request #128 from mihir-1997/master

added exec and set namespace commands
This commit is contained in:
Julien Le Coupanec 2020-07-13 11:42:56 +02:00 committed by GitHub
commit 69d3cf7abb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,6 +23,8 @@ kubectl config view -o jsonpath='{.users[?(@.name == "k8s")].user.password}'
# Set credentials for foo.kuberntes.com
kubectl config set-credentials kubeuser/foo.kubernetes.com --username=kubeuser --password=kubepassword
# Set active namespace
kubectl config set-context --current --namespace=namespace_name
##############################################################################
# VIEWING, FINDING RESOURCES
@ -115,3 +117,21 @@ kubectl logs pod_name
# Stream pod container logs (stdout, multi-container case)
kubectl logs -f pod_name -c my-container
##############################################################################
# INTERACTING WITH RUNNING PODS
##############################################################################
# Run command in pod
kubectl exec pod_name -- command_name
# Run command in pod with multiple containers
kubectl exec pod_name -c container_name -- command_name
# Get terminal of pod
kubectl exec -it pod_name /bin/sh
# Get terminal of a container running in pod with multiple containers
kubectl exec -it pod_name -c container_name /bin/sh