2020-09-10-k8s-pod

创建

worker1,2
[root@worker1 ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
bf5952930446: Pull complete 
cb9a6de05e5a: Pull complete 
9513ea0afb93: Pull complete 
b49ea07d2e93: Pull complete 
a5e4a503d449: Pull complete 
Digest: sha256:2850bbf7ed1bcb88e50c08c424c13fec71cf0a0bf0d496b5481601c69f905534
Status: Downloaded newer image for nginx:latest
You have new mail in /var/spool/mail/root
[root@worker1 ~]# docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
k8s.gcr.io/kube-proxy       v1.19.1             33c60812eab8        23 hours ago        118MB
nginx                       latest              4bb46517cac3        3 weeks ago         133MB
k8s.gcr.io/pause            3.2                 80d28bedfe5d        6 months ago        683kB
calico/node                 v3.9.0              f9d62fb5edb1        12 months ago       190MB
calico/pod2daemon-flexvol   v3.9.0              aa79ce3237eb        12 months ago       9.78MB
calico/cni                  v3.9.0              56c7969ed8e6        12 months ago       160MB
calico/kube-controllers     v3.9.0              f5cc48269a09        12 months ago       50.4MB
[root@worker1 ~]# 
master
[root@master1 yamldir]# kubectl get pod
No resources found in default namespace.
[root@master1 yamldir]# kubectl get namespace
NAME              STATUS   AGE
default           Active   4h38m
kube-node-lease   Active   4h38m
kube-public       Active   4h38m
kube-system       Active   4h38m
[root@master1 yamldir]# kubectl get pods --namespace default
No resources found in default namespace.
[root@master1 yamldir]# kubectl get pods --n default
Error: unknown flag: --n
See 'kubectl get --help' for usage.
[root@master1 yamldir]# kubectl get pods -n default
No resources found in default namespace.
[root@master1 yamldir]# kubectl get pod -n kube-system
NAME                                       READY   STATUS    RESTARTS   AGE
calico-kube-controllers-64596cf887-6d5mv   1/1     Running   0          3h51m
calico-node-gnhg4                          1/1     Running   0          3h47m
calico-node-qn6zt                          1/1     Running   0          3h48m
calico-node-x57js                          1/1     Running   0          3h51m
coredns-f9fd979d6-h7789                    1/1     Running   0          4h40m
coredns-f9fd979d6-lwnnw                    1/1     Running   0          4h40m
etcd-master1                               1/1     Running   0          4h40m
kube-apiserver-master1                     1/1     Running   0          4h40m
kube-controller-manager-master1            1/1     Running   0          3h8m
kube-proxy-g8zzh                           1/1     Running   0          4h40m
kube-proxy-pbdz4                           1/1     Running   0          3h48m
kube-proxy-z4554                           1/1     Running   0          3h47m
kube-scheduler-master1                     1/1     Running   0          3h9m
[root@master1 yamldir]# vim 02_create_pod.yaml
You have new mail in /var/spool/mail/root
[root@master1 yamldir]# cat 02_create_pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: pod1
spec:
  containers:
  - name: nginx-container
    image: nginx:latest
    imagePullPolicy: IfNotPresent
    ports:
    - name: nginxport
      containerPort: 80
[root@master1 yamldir]# kubectl apply -f 02_create_pod.yaml
pod/pod1 created
[root@master1 yamldir]# kubectl get pods
NAME   READY   STATUS              RESTARTS   AGE
pod1   0/1     ContainerCreating   0          10s
[root@master1 yamldir]# kubectl get pods -o wide
NAME   READY   STATUS    RESTARTS   AGE    IP              NODE      NOMINATED NODE   READINESS GATES
pod1   1/1     Running   0          102s   172.16.189.65   worker2   <none>           <none>
[root@master1 yamldir]# 

两种删除

[root@master1 yamldir]# kubectl get pods
NAME   READY   STATUS    RESTARTS   AGE
pod1   1/1     Running   0          8m24s
[root@master1 yamldir]# kubectl delete pods pod1 -n default
pod "pod1" deleted
[root@master1 yamldir]# kubectl get pods
No resources found in default namespace.
[root@master1 yamldir]# kubectl apply -f 02_create_pod.yaml 
pod/pod1 created
[root@master1 yamldir]# kubectl get pods
NAME   READY   STATUS              RESTARTS   AGE
pod1   0/1     ContainerCreating   0          5s
[root@master1 yamldir]# kubectl delete -f 02_create_pod.yaml 
pod "pod1" deleted
[root@master1 yamldir]# kubectl get pods
No resources found in default namespace.
[root@master1 yamldir]# 
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容