真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

KubernetesIngress-Nginx實(shí)現(xiàn)高可用

假定我們在Kubernetes 指定兩個worker節(jié)點(diǎn)中部署了ingress nginx來為后端的pod做proxy,這時候我們就需要通過keepalived實(shí)現(xiàn)高可用,提供對外的VIP

“只有客戶發(fā)展了,才有我們的生存與發(fā)展!”這是創(chuàng)新互聯(lián)的服務(wù)宗旨!把網(wǎng)站當(dāng)作互聯(lián)網(wǎng)產(chǎn)品,產(chǎn)品思維更注重全局思維、需求分析和迭代思維,在網(wǎng)站建設(shè)中就是為了建設(shè)一個不僅審美在線,而且實(shí)用性極高的網(wǎng)站。創(chuàng)新互聯(lián)對網(wǎng)站設(shè)計(jì)制作、成都網(wǎng)站建設(shè)、網(wǎng)站制作、網(wǎng)站開發(fā)、網(wǎng)頁設(shè)計(jì)、網(wǎng)站優(yōu)化、網(wǎng)絡(luò)推廣、探索永無止境。

Kubernetes Ingress-Nginx實(shí)現(xiàn)高可用

首先我們要先確保有兩個worker節(jié)點(diǎn)部署了ingress nginx
在本實(shí)驗(yàn)中,環(huán)境如下:

IP地址主機(jī)名描述
10.0.0.31 k8s-master01
10.0.0.34 k8s-node02 ingress nginx、keepalived
10.0.0.35 k8s-node03 ingress nginx、keepalived

1、查看ingress nginx狀態(tài)

[root@k8s-master01 Ingress]# kubectl get pod -n ingress-nginx -o wide
NAME                                        READY   STATUS    RESTARTS   AGE     IP          NODE         NOMINATED NODE   READINESS GATES
nginx-ingress-controller-85bd8789cd-8c4xh   1/1     Running   0          62s     10.0.0.34   k8s-node02              
nginx-ingress-controller-85bd8789cd-mhd8n   0/1     Pending   0          3s                              
nginx-ingress-controller-85ff8dfd88-vqkhx   1/1     Running   0          3m56s   10.0.0.35   k8s-node03              

創(chuàng)建一個用于測試環(huán)境的namespace

 kubectl  create namespace test

2、部署一個Deployment(用于測試)

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myweb-deploy
  # 部署在測試環(huán)境
  namespace: test
spec:
  replicas: 3
  selector:
    matchLabels:
      name: myweb
      type: test
  template:
    metadata:
      labels:
        name: myweb
        type: test
    spec:
      containers:
      - name: nginx
        image: nginx:1.13
        imagePullPolicy: IfNotPresent
        ports:
          - containerPort: 80
---
# service
apiVersion: v1
kind: Service
metadata:
  name: myweb-svc
spec:
  selector:
    name: myweb
    type: test
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
---
# ingress

執(zhí)行kubectl create 創(chuàng)建deployment

kubectl  create -f myweb-demo.yaml

查看deployment是否部署成功

[root@k8s-master01 Project]# kubectl get pods -n test -o wide | grep "myweb"
myweb-deploy-6d586d7db4-2g5ll   1/1     Running   0          23s     10.244.3.240   k8s-node02              
myweb-deploy-6d586d7db4-cf7w7   1/1     Running   0          4m2s    10.244.1.132   k8s-node01              
myweb-deploy-6d586d7db4-rp5zc   1/1     Running   0          3m59s   10.244.2.5     k8s-node03              

3、在兩個worker節(jié)點(diǎn)部署keepalived
VIP:10.0.0.130,接口:eth0

1.安裝keepalived

yum -y install keepalived

1.k8s-node03節(jié)點(diǎn)作為master配置keepalived

[root@k8s-node03 ~]# cat /etc/keepalived/keepalived.conf
! Configuration File for keepalived

global_defs {
   notification_email_from Alexandre.Cassen@firewall.loc
   router_id k8s-node03
   vrrp_skip_check_adv_addr
   vrrp_strict
   vrrp_garp_interval 0
   vrrp_gna_interval 0
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 110
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        10.0.0.130/24 dev eth0 label eth0:1
    }
}

2.k8s-node03節(jié)點(diǎn)作為配置keepalived

[root@k8s-node03 ~]# cat /etc/keepalived/keepalived.conf
! Configuration File for keepalived

global_defs {
   router_id k8s-node03
   vrrp_skip_check_adv_addr
   vrrp_strict
   vrrp_garp_interval 0
   vrrp_gna_interval 0
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 110
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        10.0.0.130/24 dev eth0 label eth0:1
    }
}

3.k8s-node02節(jié)點(diǎn)配置keeplived

[root@k8s-node02 ~]# cat /etc/keepalived/keepalived.conf
! Configuration File for keepalived

global_defs {
   router_id k8s-node02
   vrrp_skip_check_adv_addr
   vrrp_strict
   vrrp_garp_interval 0
   vrrp_gna_interval 0
}

vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
      10.0.0.130/24 dev eth0 label eth0:1
    }
}

4.兩個節(jié)點(diǎn)啟動keepalived并加入開機(jī)啟動

systemctl start keepalived.service
systemctl enable keepalived.service 

啟動完成后檢查k8s-node03的IP地址是否已有VIP

[root@k8s-node03 ~]# ip add | grep "130"
    inet 10.0.0.130/24 scope global secondary eth0:1

5.在宿主機(jī)上配置hosts文件,實(shí)現(xiàn)IP和域名的解析

10.0.0.130 myweb.app.com

6.瀏覽器測試訪問
Kubernetes Ingress-Nginx實(shí)現(xiàn)高可用

4.測試vip漂移
現(xiàn)在我將k8s-node03的keepalived進(jìn)程關(guān)閉,那么vip就會漂移到k8s-node02

[root@k8s-node03 ~]# systemctl stop keepalived.service

// 在k8s-node02上查看VIP
[root@k8s-node02 ~]# ip add | grep "130"
    inet 10.0.0.130/24 scope global secondary eth0:1

再次訪問
Kubernetes Ingress-Nginx實(shí)現(xiàn)高可用


文章標(biāo)題:KubernetesIngress-Nginx實(shí)現(xiàn)高可用
轉(zhuǎn)載注明:http://weahome.cn/article/ieeeip.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部