Last active
September 22, 2023 06:32
-
-
Save schneefisch/61c47cd88565ff9208f9aed523eb3150 to your computer and use it in GitHub Desktop.
Basics for kubectl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Documentation: https://kubernetes.io/docs | |
# | |
# get kubernetes version and info | |
kubectl version | |
# get infor on pods | |
kubectl get pods | |
# get info on deployments | |
kubectl get deployments | |
kubectl describe deployments | |
# get info on replicas | |
kubectl get rs | |
# get POD name (if only one pod is there) | |
export POD_NAME=$(kubectl get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}') | |
# show environment variables | |
kubectl exec $POD_NAME env | |
# deployments | |
# the same command is used for "UPDATES!" | |
# simply change the parameters, version-numbers, etc and run the command again | |
kubectl apply -f <deployment.yml> | |
# whatch the pods for a specific app: | |
kubectl get pods -l app=<your_app> | |
# deployment Details | |
kubectl describe deployment <your_deployemnt> | |
# see service details | |
kubectl get svc <my-nginx> | |
kubectl describe svc <my-nginx> | |
# make available: | |
kubectl expose <deployment/my-nginx> | |
# delete deployment | |
kubectl delete deployment <deployment> | |
# open bash in the container | |
kubectl exec -it <pod> -- /bin/bash | |
# Port-Forwarding: | |
# port-forward <kind/name> <local-port>:<remove-port> | |
kubectl port-forward redis-master-765d459796-258hz 6379:6379 | |
kubectl port-forward deployment/redis-master 6379:6379 | |
# let kubernetes choose a random local port | |
kubectl port-forward deployment/redis-master :6379 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment