K8s: 关于Kubernetes中的Pod的创建,实现原理,Job调度pod以及pod网络

  • 现在创建一个 nginx 的 pod, 创建一个文件: my-nginx.yaml
    apiVersion: v1
    kind: Pod
    metadata:
      name: my-nginx
      labels:
        name: my-nginx
    spec:
      containers:
      - name: my-nginx
        image: nginx:latest
        resources:
            limits:
                memory: "128Mi"
                cpu: "500m"
        ports:
        - containerPort: 80
    
  • $ kubectl create -f my-nginx.yaml
    pod/my-nginx created
    
  • $ kubectl get po
    NAME       READY   STATUS              RESTARTS   AGE
    my-nginx   0/1     ContainerCreating   0          6s
    
  • $ kubectl describe pod my-nginx
    Name:         my-nginx
    Namespace:    default
    Priority:     0
    Node:         node1.k8s/10.211.55.11
    Start Time:   Thu, 18 Apr 2024 09:49:12 +0800
    Labels:       name=my-nginx
    Annotations:  <none>
    Status:       Running
    IP:           10.244.1.12
    IPs:
      IP:  10.244.1.12
    Containers:
      my-nginx:
        Container ID:   docker://2c73c0faa3aa91a72849fdaa1aa09cbca1ce3c6ef2092e2542fc7558d3b524a3
        Image:          nginx
        Image ID:       docker-pullable://nginx@sha256:d2cb0992f098fb075674730da5e1c6cccdd4890516e448a1db96e0245c1b7fca
        Port:           80/TCP
        Host Port:      0/TCP
        State:          Running
          Started:      Thu, 18 Apr 2024 09:49:23 +0800
        Ready:          True
        Restart Count:  0
        Limits:
          cpu:     500m
          memory:  128Mi
        Requests:
          cpu:        500m
          memory:     128Mi
        Environment:  <none>
        Mounts:
          /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-kpmzn (ro)
    Conditions:
      Type              Status
      Initialized       True
      Ready             True
      ContainersReady   True
      PodScheduled      True
    Volumes:
      kube-api-access-kpmzn:
        Type:                    Projected (a volume that contains injected data from multiple sources)
        TokenExpirationSeconds:  3607
        ConfigMapName:           kube-root-ca.crt
        ConfigMapOptional:       <nil>
        DownwardAPI:             true
    QoS Class:                   Guaranteed
    Node-Selectors:              <none>
    Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                                 node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
    Events:
      Type    Reason     Age   From               Message
      ----    ------     ----  ----               -------
      Normal  Scheduled  13s   default-scheduler  Successfully assigned default/my-nginx to node1.k8s
      Normal  Pulling    13s   kubelet            Pulling image "nginx"
      Normal  Pulled     2s    kubelet            Successfully pulled image "nginx" in 10.625690431s
      Normal  Created    2s    kubelet            Created container my-nginx
      Normal  Started    2s    kubelet            Started container my-nginx
    
    • 这里可以看到:
      • Successfully assigned default/my-nginx to node1.k8s
      • 这里将pod分配到 node1.k8s 节点上
  • 上一篇:vue语法


    下一篇:StringBuilder和StringJoiner来实现字符串拼接