健康检查探针

在k8s集群内部署,pod有健康检查探针,httpd镜像检查nfs挂载到pod内的index.html存在即可更新。

每次更新(新旧容器)最多容器总量为15个

在所有节点上搭建nfs服务器:

[root@server1 ~]# yum -y install nfs-utils rpcbind

[root@server2 ~]# yum -y install nfs-utils rpcbind

[root@server3 ~]# yum -y install nfs-utils rpcbind

在server2上创建nfs文件:

[root@server2 ~]# mkdir /nfsdata

[root@server2 ~]# vi /etc/exports

添加:

/nfsdata *(rw,no_root_squash,sync)

[root@server2 ~]# exportfs -r

[root@server2 ~]# systemctl start rpcbind

[root@server2 ~]# systemctl start nfs-server

所有节点测试访问:

[root@server2 ~]# showmount -e 192.168.1.5

主节点server1上部署:

[root@server1 ~]# vi http.yaml

添加:

apiVersion: apps/v1

kind: Deployment

metadata:

  name: apache

spec:

  selector:

    matchLabels:

      app: apache

  replicas: 10

  template:

    metadata:

      labels:

        app: apache

    spec:

      containers:

      - name: httpd

        image: httpd:2.4.48

        ports:

        - containerPort: 80

        volumeMounts:

          - name: httpd

            mountPath: /usr/local/apache2/htdocs

      volumes:

      - name: httpd

        nfs:

          server: 192.168.1.5

          path: /nfsdata

执行:

[root@server1 ~]# kubectl apply -f http.yaml --record

deployment.apps/apache created

[root@server1 ~]# cp http.yaml http1.yaml

查看:

 

修改httpd1.yaml文件:

[root@server1 ~]# vi http1.yaml

添加:

apiVersion: apps/v1

kind: Deployment

metadata:

  name: apache

spec:

  strategy:

    rollingUpdate:

      maxSurge: 50%

      maxUnavailable: 35%

  selector:

    matchLabels:

      app: apache

  replicas: 10

  template:

    metadata:

      labels:

        app: apache

    spec:

      containers:

      - name: httpd

        image: httpd:latest

        ports:

        - containerPort: 80

        volumeMounts:

          - name: httpd

            mountPath: /usr/local/apache2/htdocs

        args:

        - rm -rf /usr/local/apache2/htdocs/index.html; sleep 300000

        readinessProbe:

          exec:

            command:

            - cat

            - /usr/local/apache2/htdocs/index.html

          initialDelaySeconds: 10

          periodSeconds: 5   

      volumes:

      - name: httpd

        nfs:

          server: 192.168.1.5

          path: /nfsdata

执行:

[root@server1 ~]# kubectl apply -f http1.yaml --record

查看:

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值