01 - Core Concepts - Pods

學習目標

  • Pods
  • ReplicaSets
  • Deployments
  • Namespaces
  • Services
  • Imperative Commands

Pods

$ kubectl get pods                        
$ kubectl get pod <pod-name>     
Look for existing Pods.

$ kubectl get pods                       
NAME      READY     STATUS               RESTARTS    AGE
newpod    /         Running                0                  10m
webapp    /        ImagePullBackOff   0                  2m49s
READY ➜ Running Containers in Pod /Total Containers in Pod

$ kubectl get pods -o wide           





$ kubectl get pods -A -ns                  










$ kubectl describe pods                     
$ kubectl describe pod <pod-name>   
Get detailed information about most of the Kubernetes primitives, including Nodes, Pods, and Deployments.
  • View what containers are inside that Pod
  • View what images are used to build those containers
  • Details about the Pod’s container: IP address, the ports used and a list of events related to the lifecycle of the Pod.


$ kubectl run nginx --image=nginx      
$ kubectl run redis --image redis        
Start a nginx/redis pod.


$ kubectl delete pod <pod-name>       
Delete a pod.


$ kubectl run --help


Create a pod definition YAML file and use it to create a pod.

(1) Method 1

$ kubectl run redis --image=redis123 --dry-run=client -o yaml                                   
$ kubectl run redis --image=redis123 --dry-run=client -o yaml > redis-definition.yaml  
$ kubectl create -f redis-definition.yaml                                                                   













(2) Method 2

$ vim redis-definition.yaml                               
$ kubectl apply -f redis-definition.yaml             
















待補充:
$ kubectl edit pod redis




留言