Last active
August 30, 2022 04:59
-
-
Save Chever-John/24785873ef5589fc13d9396588d5def0 to your computer and use it in GitHub Desktop.
some commands about kubectl
This file contains 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
kubectl delete pods --all --all-namespaces | |
kubectl delete pod websocket-server-service | |
kubectl delete --all pods --namespace=foo | |
kubectl delete --all deployments --namespace=foo | |
kubectl delete --all namespaces | |
```bash | |
for each in $(kubectl get ns -o jsonpath="{.items[*].metadata.name}" | grep -v kube-system); | |
do | |
kubectl delete ns $each | |
done | |
``` | |
kubectl get pods --all-namespaces | |
// usage of `kubectl describe`, and we can find the `apisix-b8865dfcf-hd45m` by the second or third command. | |
kubectl describe pod apisix-b8865dfcf-hd45m -n apisix | |
kubectl get pods -n apisix -l app.kubernetes.io/name=apisix -o name | |
kubectl get pods -n apisix | |
kubectl apply -f dev.yaml | |
kubectl delete -f dev.yaml | |
// kubectl logs!!! | |
kubectl logs apisix-6f7d4f7894-wcv8f -n apisix | |
// kubectl and expose service | |
kubectl expose deployment hello-world --type=ClusterIP --name=my-service | |
kubectl get services my-service | |
kubectl get services --all-namespaces | |
kubectl delete service my-service | |
// run backend services | |
kubectl create ns demo | |
kubectl -n demo run httpbin --image-pull-policy=IfNotPresent --image kennethreitz/httpbin --port 80 | |
kubectl -n demo expose pod httpbin --port 80 | |
// enter terminal | |
kubectl exec -it -n ingress-apisix apisix-7d6b8577b6-x2xrv -- /bin/bash | |
# apisix-7d6b8577b6-x2xrv can be get by command `kubectl get pods --all-namespaces` | |
// troubleshooting | |
kubectl describe ar -n {namespaces} | |
kubectl describe pods pod-XXX | |
kubectl logs pod-XXX | |
kubectl logs pod-XXX -c init-container-XXX | |
// configmap | |
kb get configmap apisix-configmap -o json -n ingress-apisix-1 | |
// Get NodePort IP Address | |
kubectl get pod -o wide --selector app=frontend |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment