1. Kubernetes 컨텍스트 및 클러스터 관리
kubectl config current-context # Show the current context
kubectl config use-context <context> # Switch to a different context
kubectl config get-contexts # List all available contexts
kubectl cluster-info # Display information about the cluster
kubectl get nodes # List all nodes in the cluster
kubectl describe node <node-name> # Detailed information about a specific node
2. 자원 관리
kubectl create -f <file.yaml> # Create resources defined in a YAML/JSON file
kubectl apply -f <file.yaml> # Apply changes from a file (create/update)
kubectl run <name> --image=<image> # Create a pod with a specific image
kubectl get pods # List all pods
kubectl get deployments # List all deployments
kubectl get services # List all services
kubectl get configmaps # List all ConfigMaps
kubectl get secrets # List all Secrets
kubectl get all # List all resources in the namespace
kubectl describe pod <pod-name> # Detailed information about a pod
kubectl describe deployment <name> # Detailed information about a deployment
kubectl describe service <name> # Detailed information about a service
kubectl delete pod <pod-name> # Delete a specific pod
kubectl delete deployment <name> # Delete a specific deployment
kubectl delete -f <file.yaml> # Delete resources defined in a YAML/JSON file
kubectl delete namespace <namespace> # Delete a namespace
3. 로그 및 디버깅
kubectl logs <pod-name> # View logs of a pod
kubectl logs <pod-name> -c <container> # View logs for a specific container in a pod
kubectl logs -f <pod-name> # Follow logs of a pod in real-time
kubectl exec -it <pod-name> -- /bin/bash # Open a shell in a running pod
kubectl exec <pod-name> -- <command> # Execute a command in a running pod
kubectl port-forward <pod-name> 8080:80 # Forward a local port to a pod's port
kubectl get events # View cluster events
4. 네임스페이스
kubectl get namespaces # List all namespaces
kubectl create namespace <namespace> # Create a new namespace
kubectl delete namespace <namespace> # Delete a namespace
kubectl config set-context --current --namespace=<namespace> # Set default namespace
5. 리소스 확장 및 업데이트
kubectl scale deployment <name> --replicas=<number> # Scale replicas
kubectl rollout status deployment/<name> # Check the status of a rollout
kubectl rollout undo deployment/<name> # Roll back to the previous version
kubectl rollout restart deployment/<name> # Restart a deployment
6. ConfigMap 및 비밀
kubectl create configmap <name> --from-literal=key=value # Create ConfigMap from a literal
kubectl create configmap <name> --from-file=<file> # Create ConfigMap from a file
kubectl describe configmap <name> # Describe a ConfigMap
kubectl create secret generic <name> --from-literal=key=value # Create a secret from a literal
kubectl describe secret <name> # Describe a Secret
7. YAML 구성
kubectl get pod <pod-name> -o yaml # Get a pod's YAML definition
kubectl get deployment <name> -o yaml # Get a deployment's YAML definition
kubectl apply -f <file.yaml> # Apply changes from a YAML file
8. 기타
kubectl top nodes # View resource usage of nodes
kubectl top pods # View resource usage of pods
kubectl describe pod <pod-name> # Check events related to the pod
kubectl logs <pod-name> # Check pod logs
kubectl exec -it <pod-name> -- /bin/bash # Access the pod for manual inspection
kubectl apply -f <file.yaml> --dry-run=client # Check what will happen without making changes
| project - Pipe Line 구성1 (0) | 2025.04.05 |
|---|---|
| Python - 크롤링 (0) | 2025.02.23 |
| Hadoop - Webhdfs (0) | 2025.01.05 |
| 압축 알고리즘 등 (1) | 2024.12.28 |
| OpenSearch (0) | 2024.12.22 |