In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Suppose we deploy ingress nginx in two worker nodes specified by Kubernetes to do proxy for the backend pod, then we need to achieve high availability and provide external VIP through keepalived.
First, we need to make sure that there are two worker nodes with ingress nginx deployed.
In this lab, the environment is as follows:
IP address hostname description 10.0.0.31k8s-master0110.0.0.34k8s-node02ingress nginx, keepalived10.0.0.35k8s-node03ingress nginx, keepalived
1. View ingress nginx status
[root@k8s-master01 Ingress] # kubectl get pod-n ingress-nginx-o wideNAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATESnginx-ingress-controller-85bd8789cd-8c4xh 1 Running 0 62s 10.0.0.34 k8s-node02 nginx-ingress-controller-85bd8789cd-mhd8n 0max 1 Pending 0 3s nginx-ingress-controller-85ff8dfd88-vqkhx 1/1 Running 0 3m56s 10.0.0.35 k8s-node03
Create a namespace for the test environment
Kubectl create namespace test
2. Deploy a Deployment (for testing)
ApiVersion: apps/v1kind: Deploymentmetadata: name: myweb-deploy # is deployed in the test environment namespace: testspec: replicas: 3 selector: matchLabels: name: myweb type: test template: metadata: labels: name: myweb type: testspec: containers:-name: nginx image: nginx:1.13 imagePullPolicy: IfNotPresent ports:-containerPort: 80- -- # serviceapiVersion: v1kind: Servicemetadata: name: myweb-svcspec: selector: name: myweb type: test ports:-port: 80 targetPort: 80 protocol: TCP---# ingress
Execute kubectl create to create deployment
Kubectl create-f myweb-demo.yaml
Check whether deployment is deployed successfully
[root@k8s-master01 Project] # kubectl get pods-n test-o wide | grep "myweb" myweb-deploy-6d586d7db4- 2g5ll 1 Running 0 23s 10.244.3.240 k8s-node02 myweb-deploy-6d586d7db4-cf7w7 1 Running 0 4m2s 10.244.1.132 k8s-node01 myweb-deploy-6d586d7db4-rp5zc 1 Running 0 3m59s 10.244.2.5 k8s-node03
3. Deploy keepalived on two worker nodes
VIP:10.0.0.130, API: eth0
1. Install keepalived
Yum-y install keepalived
The 1.k8s-node03 node configures keepalived as a master
[root@k8s-node03 ~] # cat / etc/keepalived/keepalived.conf! Configuration File for keepalivedglobal_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 node as configuration keepalived
[root@k8s-node03 ~] # cat / etc/keepalived/keepalived.conf! Configuration File for keepalivedglobal_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 node configuration keeplived
[root@k8s-node02 ~] # cat / etc/keepalived/keepalived.conf! Configuration File for keepalivedglobal_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. Two nodes start keepalived and join boot boot
Systemctl start keepalived.servicesystemctl enable keepalived.service
After startup, check whether the IP address of k8s-node03 already has VIP.
[root@k8s-node03 ~] # ip add | grep "130C" inet 10.0.0.130MB 24 scope global secondary eth0:1
5. Configure the hosts file on the host computer to realize the resolution of IP and domain name
10.0.0.130 myweb.app.com
6. Browser test access
4. Test vip drift
Now that I turn off the keepalived process of k8s-node03, vip will drift to k8s-node02
[root@k8s-node03 ~] # systemctl stop keepalived.service// View VIP [root @ k8s-node02 ~] # ip add on k8s-node02 | grep "130" inet 10.0.0.130 scope global secondary eth0:1
Visit again
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.