pod是k8s中最小的管理单元,程序在容器中,容器在pod中
k8s通过管理pod来管理容器,通过管理容器进而管理程序
pod可以说是容器的封装,一个pod中可以存在一个或多个容器
[qq@k8snode1 ~]$ kubectl get pods -n kube-system NAME READY STATUS RESTARTS AGE coredns-64897985d-bnkbc 1/1 Running 0 45s etcd-minikube 1/1 Running 1 57s kube-apiserver-minikube 1/1 Running 2 57s kube-controller-manager-minikube 1/1 Running 1 58s kube-proxy-tgbx2 1/1 Running 0 45s kube-scheduler-minikube 1/1 Running 1 57s storage-provisioner 1/1 Running 2 (40s ago) 54s APIservice 所有服务的访问统一入口 crontrollerManager:维持副本期望数目 Scheduler:负责介绍任务,选择合适的节点进行分配任务 ETCD:键值对数据库 存储K8s集群所有重要信息持久化,负责存储集群中各种资源对象的信息 Kubelet:直接跟容器引擎交互实现容器的生命周期管理 Kube-proxy:负责写入规则至IPTABLES,IPVS实现服务映射访问 docker:节点上的容器操作 [qq@k8snode1 ~]$ kubectl create ns dev namespace/dev created 《创建命名空间》 [qq@k8snode1 ~]$ kubectl get ns NAME STATUS AGE default Active 7m54s dev Active 10s kube-node-lease Active 7m55s kube-public Active 7m55s kube-system Active 7m55s 《看一下》 [qq@k8snode1 ~]$ kubectl run nginxss --image=nginx:1.17.1 --port=80 -n dev pod/nginxss created [qq@k8snode1 ~]$ kubectl get pod -n dev NAME READY STATUS RESTARTS AGE nginxss 1/1 Running 0 18s [qq@k8snode1 ~]$ kubectl get pod -n dev -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES nginxss 1/1 Running 0 43s 172.17.0.3 minikube <none> <none> [qq@k8snode1 ~]$ kubectl describe pod nginxss -n dev 《查看详细的pod信息》 Name: nginxss Namespace: dev Priority: 0 Node: minikube/192.168.49.2 Start Time: Sat, 19 Feb 2022 18:29:18 +0800 Labels: run=nginxss Annotations: <none> Status: Running IP: 172.17.0.3 IPs: IP: 172.17.0.3 Containers: nginxss: Container ID: docker://386271d32e3a74ac5837c671d177cd2f28ff6ecf5b62c52bee0fbae3b34ae0e1 Image: nginx:1.17.1 Image ID: docker-pullable://nginx@sha256:b4b9b3eee194703fc2fa8afa5b7510c77ae70cfba567af1376a573a967c03dbb Port: 80/TCP Host Port: 0/TCP State: Running Started: Sat, 19 Feb 2022 18:29:19 +0800 Ready: True Restart Count: 0 Environment: <none> Mounts: /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-7hqgp (ro) Conditions: Type Status Initialized True Ready True ContainersReady True PodScheduled True Volumes: kube-api-access-7hqgp: Type: Projected (a volume that contains injected data from multiple sources) TokenExpirationSeconds: 3607 ConfigMapName: kube-root-ca.crt ConfigMapOptional: <nil> DownwardAPI: true QoS Class: BestEffort 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 2m50s default-scheduler Successfully assigned dev/nginxss to minikube Normal Pulled 2m49s kubelet Container image "nginx:1.17.1" already present on machine Normal Created 2m49s kubelet Created container nginxss Normal Started 2m49s kubelet Started container nginxss [qq@k8snode1 ~]$ kubectl delete pod nginxss -n dev pod "nginxss" deleted 《用delete干掉》 [qq@k8snode1 ~]$ kubectl delete ns dev namespace "dev" deleted [qq@k8snode1 ~]$ kubectl get pod -A NAMESPACE NAME READY STATUS RESTARTS AGE kube-system coredns-64897985d-bnkbc 1/1 Running 0 25m kube-system etcd-minikube 1/1 Running 1 25m kube-system kube-apiserver-minikube 1/1 Running 2 25m kube-system kube-controller-manager-minikube 1/1 Running 1 25m kube-system kube-proxy-tgbx2 1/1 Running 0 25m kube-system kube-scheduler-minikube 1/1 Running 1 25m kube-system storage-provisioner 1/1 Running 2 (25m ago) 25m
命令式对象配置,使用yaml创建pod,上面的是pod的下面的是命名空间的
apiVersion: v1 kind: Pod metadata: name: nginx namespace: dev spec: containers: - image: nginx:latest name: pod ports: - name: nginx-port containerPort: 80 protocol: TCP
apiVersion: v1 kind: Namespace metadata: name: dev
命令式对象配置的创建和删除
[qq@k8snode1 ~]$ ll 总用量 12 -rw-rw-r--. 1 qq qq 43 2月 11 20:02 2022-02-11 -rw-rw-r--. 1 qq qq 54 2月 14 18:57 devns.yaml -rw-rw-r-- 1 qq qq 202 2月 19 18:58 nginx.yaml [qq@k8snode1 ~]$ kubectl create -f devns.yaml namespace/dev created [qq@k8snode1 ~]$ kubectl create -f nginx.yaml pod/nginx created [qq@k8snode1 ~]$ kubectl delete -f nginx.yaml pod "nginx" deleted [qq@k8snode1 ~]$ kubectl delete -f devns.yaml namespace "dev" deleted [qq@k8snode1 ~]$
本文暂时没有评论,来添加一个吧(●'◡'●)