Terminal · Infra

Kubernetes

Documentação oficial
port-forward

Encaminha uma porta local para um service do cluster

Kubernetes
kubectl port-forward service/argocd-server -n argocd 9000:80
kubectl --kubeconfig .\kubeconfig port-forward service/argocd-server -n argocd 9000:80
kubectl --kubeconfig .\kubeconfig port-forward service/trivy-operator -n trivy-system 8000:80
apply

Aplica as mudanças no cluster

Kubernetes
kubectl apply -f .\argocd
kubectl --kubeconfig .\kubeconfig apply -f .\argocd
get secret

Mostra a senha inicial do admin do ArgoCD

Kubernetes
kubectl --kubeconfig .\kubeconfig -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}"
create secret

Cria um secret de acesso ao registry

Kubernetes
kubectl create secret docker-registry <SECRET NAME> --namespace argocd --docker-server=<REGISTRY HOST> --docker-username=<REGISTRY USER> --docker-password=<REGISTRY PASSWORD>
kubectl --kubeconfig .\kubeconfig create secret docker-registry <SECRET NAME> --namespace argocd --docker-server=<REGISTRY HOST> --docker-username=<REGISTRY USER> --docker-password=<REGISTRY PASSWORD>

GET

get pods

Lista os pods

Kubernetes
kubectl get pods
kubectl --kubeconfig .\kubeconfig get pods
get service

Lista os services

Kubernetes
kubectl get service -n production
kubectl --kubeconfig .\kubeconfig get service
get ns

Lista os namespaces

Kubernetes
kubectl get ns
kubectl --kubeconfig .\kubeconfig get ns
get all

Lista tudo de um namespace

Kubernetes
kubectl get all -n argocd
kubectl --kubeconfig .\kubeconfig get all -n argocd
kubectl --kubeconfig .\kubeconfig get all -n trivy-system
logs

Mostra os logs de um pod

Kubernetes
kubectl logs <POD NAME> --all-containers
kubectl --kubeconfig .\kubeconfig logs <POD NAME> --all-containers
get secrets

Lista os secrets de todos os namespaces

Kubernetes
kubectl get secrets --all-namespaces
get hpa

Lista os HPA de um namespace

Kubernetes
kubectl get hpa -n production
top pod

Mostra o consumo de CPU e memória dos pods

Kubernetes
kubectl top pod -A
kubectl describe hpa <HPA NAME> -n production