【k8s】6、Deployment

        在kubernetes中,Pod是最小的控制单元,但是kubernetes很少直接控制Pod,一般都是通过Pod控制器来完成的。Pod控制器用于pod的管理,确保pod资源符合预期的状态,当pod的资源出现故障时,会尝试进行重启或重建pod。

[root@master01 4.3]# kubectl run nginx --image=nginx:latest --port=80 --replicas=3 -n dev
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
deployment.apps/nginx created
[root@master01 4.3]# kubectl get pods -n dev
NAME                    READY   STATUS              RESTARTS   AGE
nginx-dd6b5d745-59stb   0/1     ContainerCreating   0          6s
nginx-dd6b5d745-gb9lg   0/1     ContainerCreating   0          6s
nginx-dd6b5d745-hsvjt   0/1     ContainerCreating   0          6s
[root@master01 4.3]# kubectl get pods -n dev
NAME                    READY   STATUS    RESTARTS   AGE
nginx-dd6b5d745-59stb   1/1     Running   0          28s
nginx-dd6b5d745-gb9lg   1/1     Running   0          28s
nginx-dd6b5d745-hsvjt   1/1     Running   0          28s
[root@master01 4.3]# kubectl get deploy -n dev -o wide
NAME    READY   UP-TO-DATE   AVAILABLE   AGE   CONTAINERS   IMAGES         SELECTOR
nginx   3/3     3            3           43s   nginx        nginx:latest   run=nginx
[root@master01 4.3]# kubectl describe deploy nginx -n dev
Name:                   nginx
Namespace:              dev
CreationTimestamp:      Fri, 30 Dec 2022 21:50:25 +0800
Labels:                 run=nginx
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               run=nginx
Replicas:               3 desired | 3 updated | 3 total | 3 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:
  Labels:  run=nginx
  Containers:
   nginx:
    Image:        nginx:latest
    Port:         80/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      True    MinimumReplicasAvailable
  Progressing    True    NewReplicaSetAvailable
OldReplicaSets:  <none>
NewReplicaSet:   nginx-dd6b5d745 (3/3 replicas created)
Events:
  Type    Reason             Age   From                   Message
  ----    ------             ----  ----                   -------
  Normal  ScalingReplicaSet  50s   deployment-controller  Scaled up replica set nginx-dd6b5d745 to 3
[root@master01 4.3]# kubectl delete deploy nginx -n dev
deployment.apps "nginx" deleted
[root@master01 4.3]# 

创建deploy-nginx.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  namespace: dev
spec:
  replicas: 3
  selector:
    matchLabels:
      run: nginx
  template:
    metadata:
      labels:
        run: nginx
    spec:
      containers:
      - image: nginx:latest
        name: nginx
        ports:
        - containerPort: 80
          protocol: TCP

问题:

1、open /run/flannel/subnet.env: no such file or directory

查看各个节点,包括master 节点是否有/run/flannel/subnet.env,内容应该是类似如下:

FLANNEL_NETWORK=10.244.0.0/16
FLANNEL_SUBNET=10.244.0.1/24
FLANNEL_MTU=1450
FLANNEL_IPMASQ=true
若有节点没有该文件那就拷贝一份。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值