pod是k8s中的最小资源单位,任何一个k8s资源都需要yaml文件来创建

一个pod只有一个ip地址,k8s最适合应用微服务架构

一、在node2节点上将镜像打包

[root@k8s-node-2 ~]# docker tag docker.io/nginx:1.13 10.0.0.11:5000/nginx:1.13

二、将打包镜像推送至master主机上的私有仓库

[root@k8s-node-2 ~]# docker push 10.0.0.11:5000/nginx:1.13

三、在master上定义yaml文件

[root@k8s-master ~]# vim k8s_yaml/pod/k8s_pod.yaml 
apiVersion: v1    #api版本
kind: Pod    #资源类型
metadata:  #属性
  name: nginx
  labels:  #标签
    app: web
spec:     #详细
  containers:
    - name: nginx
      image: 10.0.0.11:5000/nginx:1.13  私有仓库地址
      ports:
        - containerPort: 80

四、创建nginx资源

[root@k8s-master pod]# kubectl create -f k8s_pod.yaml 
pod "nginx" created

五、查看资源运行状态

[root@k8s-master pod]# kubectl get pod nginx
NAME      READY     STATUS    RESTARTS   AGE
nginx     1/1       Running   0          1m

六、查看资源详情

[root@k8s-master pod]# kubectl describe pod nginx
Name:		nginx
Namespace:	default
Node:		10.0.0.12/10.0.0.12
Start Time:	Mon, 01 Jun 2020 20:50:24 +0800
Labels:		app=web
Status:		Running
IP:		172.18.57.2
Controllers:	<none>
Containers:
.....

七、删除资源

[root@k8s-master pod]# kubectl delete pod nginx
pod "nginx" deleted

八、编辑资源

[root@k8s-master pod]# kubectl edit pod nginx-xqrf9 

Categories: docker&k8s

0 Comments

发表评论

Avatar placeholder

邮箱地址不会被公开。 必填项已用*标注