Last active
March 23, 2023 02:22
-
-
Save allbarbos/da824c13583791dac8a7c7a916759012 to your computer and use it in GitHub Desktop.
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
k get pods -n <NAMESPACE_NAME> | |
# RECURSOS | |
k top pod <POD_NAME> -n <NAMESPACE_NAME> --containers | |
k top pod -n <NAMESPACE_NAME> | |
# LOG | |
k logs <POD_NAME> -n <NAMESPACE_NAME> | |
# Forward a local port to a port on the Pod | |
k get service <SERVICE> -n <NAMESPACE_NAME> | |
k port-forward -n <NAMESPACE_NAME> <POD> 28015:<SERVICE_PORT> | |
# CONFIGMAP | |
k get configmap -n <NAMESPACE_NAME> <CONFIGMAP_NAME> -o yaml > ./configmap.yaml | |
k apply -n <NAMESPACE_NAME> -f ./configmap.yaml | |
# SCALE | |
k scale deployment -n <NAMESPACE_NAME> <deployment> --replicas=1 | |
# REDEPLOY | |
k rollout restart deployment <deployment_name> -n <namespace> | |
### Generic | |
kubectl explain < RESOURSE > // help | |
kubectl get <pod, deployment, service, replicasets, ...> | |
kubectl get <resourse> -o wide // wide retorna mais detalhes | |
### Context | |
kubectl config get-contexts | |
kubectl config rename-context old-name new-name | |
kubectl config unset contexts.<NAME_CONTEXT> | |
kubectl config set-context $(kubectl config current-context) -n <NAMESPACE_NAME> // evitar utilizar | |
### Namespace | |
kubectl get ns --context <CONTEXT_NAME> | |
### Recurso | |
kubectl apply -f <YAML> --context <CONTEXT_NAME> | |
kubectl delete -f <YAML> --context <CONTEXT_NAME> | |
kubectl port-forward <servico> 8000:8000 -n <NAMESPACE_NAME> | |
### Replicasets | |
kubectl get replicasets --context <CONTEXT_NAME> | |
### Pods | |
kubectl get pods --context <CONTEXT_NAME> | |
kubectl describe pods <POD_NAME> -n <NAMESPACE_NAME> --context <CONTEXT_NAME> | |
kubectl delete pod <NAME_POD> -n <NAMESPACE_NAME> --context <CONTEXT_NAME> | |
kubectl exec -it <pod-name> <command> | |
### Deployments | |
kubectl get deployments --context <CONTEXT_NAME> | |
### Logs | |
kubectl logs <pod-name> | |
### Nodes | |
kubectl get nodes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment