发布时间: 2023-6-15 文章作者: myluzh 分类名称: Kubernetes 朗读文章
[root@master ~]# kubectl run testapp --image=ccr.ccs.tencentyun.com/k8s-tutorial/test-k8s:v1
[root@master ~]# kubectl get pod NAME READY STATUS RESTARTS AGE testapp 0/1 ContainerCreating 0 16s
apiVersion: v1 kind: Pod metadata: name: test-pod spec: # 定义容器,可以多个 containers: - name: test-k8s # 容器名字 image: ccr.ccs.tencentyun.com/k8s-tutorial/test-k8s:v1 # 镜像2.部署
[root@master ~]# kubectl apply -f ./pod.yaml [root@master ~]# kubectl get pod NAME READY STATUS RESTARTS AGE test-pod 1/1 Running 0 11s testapp 1/1 Running 0 8m16s
apiVersion: apps/v1 kind: Deployment metadata: # 部署名字 name: hellohttp spec: replicas: 5 # 用来查找关联的 Pod,所有标签都匹配才行 selector: matchLabels: app: hellohttp # 定义 Pod 相关数据 template: metadata: labels: app: hellohttp spec: # 定义容器,可以多个 containers: - name: hellohttp # 容器名字 image: registry.cn-hangzhou.aliyuncs.com/myluzh/hellohttp:v1 # 镜像2.部署
[root@master hellohttp]# kubectl apply -f app.yaml [root@master hellohttp]# kubectl get pod -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES hellohttp-78c5857bbd-5v6m6 1/1 Running 0 15m 10.32.0.3 node2 <none> <none> hellohttp-78c5857bbd-b4jg4 1/1 Running 0 15m 10.40.0.4 node1 <none> <none> hellohttp-78c5857bbd-pfdkv 1/1 Running 0 15m 10.40.0.3 node1 <none> <none> hellohttp-78c5857bbd-xjkvr 1/1 Running 0 15m 10.32.0.2 node2 <none> <none> hellohttp-78c5857bbd-z4n4q 1/1 Running 0 15m 10.32.0.4 node2 <none> <none>3.使用 describe查看pod状态
[root@master hellohttp]# kubectl describe pod/hellohttp-78c5857bbd-5v6m6注意:如果发现 Events 中有如下报错:”network: open /run/flannel/subnet.env: no such file or directory“,解决方案
FLANNEL_NETWORK=10.244.0.0/16 FLANNEL_SUBNET=10.244.0.1/24 FLANNEL_MTU=1450 FLANNEL_IPMASQ=true
标签: k8s k8s-depolyment kubernetes
发表评论