中文字幕日韩精品一区二区免费_精品一区二区三区国产精品无卡在_国精品无码专区一区二区三区_国产αv三级中文在线

KubernetesIngress-Nginx實(shí)現(xiàn)高可用-創(chuàng)新互聯(lián)

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

創(chuàng)新互聯(lián)建站基于成都重慶香港及美國(guó)等地區(qū)分布式IDC機(jī)房數(shù)據(jù)中心構(gòu)建的電信大帶寬,聯(lián)通大帶寬,移動(dòng)大帶寬,多線BGP大帶寬租用,是為眾多客戶提供專業(yè)服務(wù)器托管報(bào)價(jià),主機(jī)托管價(jià)格性價(jià)比高,為金融證券行業(yè)服務(wù)器托管,ai人工智能服務(wù)器托管提供bgp線路100M獨(dú)享,G口帶寬及機(jī)柜租用的專業(yè)成都idc公司。

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

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

IP地址 主機(jī)名 描述
10.0.0.31k8s-master01
10.0.0.34k8s-node02ingress nginx、keepalived
10.0.0.35k8s-node03ingress 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   <none>           <none>
nginx-ingress-controller-85bd8789cd-mhd8n   0/1     Pending   0          3s      <none>      <none>       <none>           <none>
nginx-ingress-controller-85ff8dfd88-vqkhx   1/1     Running   0          3m56s   10.0.0.35   k8s-node03   <none>           <none>

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

 kubectl  create namespace test

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

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myweb-deploy
  # 部署在測(cè)試環(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   <none>           <none>
myweb-deploy-6d586d7db4-cf7w7   1/1     Running   0          4m2s    10.244.1.132   k8s-node01   <none>           <none>
myweb-deploy-6d586d7db4-rp5zc   1/1     Running   0          3m59s   10.244.2.5     k8s-node03   <none>           <none>

3、在兩個(gè)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.兩個(gè)節(jié)點(diǎn)啟動(dòng)keepalived并加入開機(jī)啟動(dòng)

systemctl start keepalived.service
systemctl enable keepalived.service

啟動(dòng)完成后檢查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.瀏覽器測(cè)試訪問
Kubernetes Ingress-Nginx實(shí)現(xiàn)高可用

4.測(cè)試vip漂移
現(xiàn)在我將k8s-node03的keepalived進(jìn)程關(guān)閉,那么vip就會(huì)漂移到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)高可用

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

新聞標(biāo)題:KubernetesIngress-Nginx實(shí)現(xiàn)高可用-創(chuàng)新互聯(lián)
網(wǎng)站URL:http://m.rwnh.cn/article16/dpedgg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站建設(shè)手機(jī)網(wǎng)站建設(shè)、做網(wǎng)站、搜索引擎優(yōu)化、虛擬主機(jī)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁(yè)設(shè)計(jì)公司
尚志市| 沂南县| 马公市| 沈阳市| 遂川县| 肥城市| 桑植县| 南宫市| 枣强县| 九龙坡区| 信阳市| 宁波市| 大足县| 漳浦县| 高陵县| 京山县| 通榆县| 安溪县| 建德市| 宁阳县| 长宁县| 阿图什市| 黔南| 印江| 织金县| 丰顺县| 云林县| 六盘水市| 丹巴县| 孟津县| 平谷区| 长治县| 类乌齐县| 西峡县| 章丘市| 加查县| 太湖县| 凤翔县| 东明县| 梨树县| 海南省|