Kubernetes Concepts:
- Pod: The smallest deployable unit in Kubernetes. A pod can contain one or more containers.
- Node: A physical or virtual machine in the cluster where pods are scheduled.
- Deployment: A higher-level resource for managing pods. It provides updates and scaling capabilities.
- Service: An abstraction to access a set of pods. There are different types, including ClusterIP, NodePort, and LoadBalancer.
- Namespace: A way to partition resources in a cluster. Useful for multi-tenancy.
- ReplicaSet: Ensures a specified number of pod replicas are running at all times.
Kubernetes Commands:
- kubectl get pods: List all pods in the current namespace.
- kubectl get nodes: List all nodes in the cluster.
- kubectl get deployments: List all deployments.
- kubectl get services: List all services.
- kubectl get namespaces: List all namespaces.
- kubectl describe pod <pod-name>: Get detailed information about a pod.
- kubectl logs <pod-name>: Show logs for a specific pod.
- kubectl exec -it <pod-name> -- /bin/sh: Start an interactive shell in a pod.
- kubectl apply -f <filename>: Create or update resources from a YAML file.
- kubectl delete pod <pod-name>: Delete a pod.
- kubectl scale deployment <deployment-name> --replicas=<replica-count>: Scale the number of replicas in a deployment.
Pod Management:
- kubectl create -f <filename>: Create a pod from a YAML file.
- kubectl expose pod <pod-name> --type=NodePort --port=80: Expose a pod as a service on a specific port.
- kubectl label pods <pod-name> <label-key>=<label-value>: Add labels to pods for easier management.
- kubectl run <pod-name> --image=<image-name>: Create a pod with a specified container image.
- kubectl delete pod <pod-name>: Delete a pod.
Configuration:
- kubectl config view: View the current Kubernetes configuration.
- kubectl config use-context <context-name>: Switch to a different context (cluster).
- kubectl config set-context <context-name> --namespace=<namespace>: Set the default namespace for a context.
Troubleshooting:
- kubectl describe pod <pod-name>: Get detailed information about a pod, including events.
- kubectl logs <pod-name>: Show container logs for a specific pod.
- kubectl exec -it <pod-name> -- /bin/sh: Start an interactive shell in a pod for troubleshooting.
No comments:
Post a Comment