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

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

kubernetes二進(jìn)制負(fù)載均衡部署如何實(shí)現(xiàn)-創(chuàng)新互聯(lián)

下文給大家?guī)韐ubernetes二進(jìn)制負(fù)載均衡部署如何實(shí)現(xiàn),希望能夠給大家在實(shí)際運(yùn)用中帶來一定的幫助,負(fù)載均衡涉及的東西比較多,理論也不多,網(wǎng)上有很多書籍,今天我們就用創(chuàng)新互聯(lián)在行業(yè)內(nèi)累計(jì)的經(jīng)驗(yàn)來做一個(gè)解答。

站在用戶的角度思考問題,與客戶深入溝通,找到肥東網(wǎng)站設(shè)計(jì)與肥東網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名注冊(cè)、網(wǎng)站空間、企業(yè)郵箱。業(yè)務(wù)覆蓋肥東地區(qū)。

實(shí)驗(yàn)環(huán)境:

負(fù)載均衡
Nginx1:192.168.35.104/24
Nginx2:192.168.35.105/24

Master節(jié)點(diǎn)
master1:192.168.35.100/24
master2:192.168.35.103/24

Node節(jié)點(diǎn)
node1:192.168.35.101/24
node2:192.168.35.102/24

nginx安裝部署

lb01和lb02操作

1、關(guān)閉防火墻
[root@localhost ~]# systemctl stop firewalld.service 
[root@localhost ~]# setenforce 0
2、安裝nginx服務(wù),把nginx.sh和keepalived.conf腳本拷貝到家目錄
[root@localhost ~]# ls
anaconda-ks.cfg    keepalived.conf  公共  視頻  文檔  音樂
initial-setup-ks.cfg  nginx.sh     模板  圖片  下載  桌面
3、構(gòu)建nginx的yum源環(huán)境
(1)復(fù)制配置文件
[root@localhost ~]# vim nginx.sh

cat > /etc/yum.repos.d/nginx.repo << EOF
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0                  #復(fù)制四行內(nèi)容
EOF

stream {

  log_format  main  '$remote_addr $upstream_addr - [$time_local] $status $upstream_bytes_sent';
  access_log  /var/log/nginx/k8s-access.log  main;

  upstream k8s-apiserver {
    server 10.0.0.3:6443;
    server 10.0.0.8:6443;
  }
  server {
        listen 6443;
        proxy_pass k8s-apiserver;
  }
  }
(2)創(chuàng)建yum源,重新加載yum倉庫,并安裝nginx
[root@localhost ~]# vim /etc/yum.repos.d/nginx.repo

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0

[root@localhost ~]# yum list

[root@localhost ~]# yum install nginx -y
4、添加四層轉(zhuǎn)發(fā)
(1)復(fù)制配置文件
[root@localhost ~]# vim nginx.sh

cat > /etc/yum.repos.d/nginx.repo << EOF
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0                  
EOF

stream {

  log_format  main  '$remote_addr $upstream_addr - [$time_local] $status $upstream_bytes_sent';
  access_log  /var/log/nginx/k8s-access.log  main;

  upstream k8s-apiserver {
    server 10.0.0.3:6443;
    server 10.0.0.8:6443;
  }
  server {
        listen 6443;
        proxy_pass k8s-apiserver;
  }
  }             #復(fù)制此段內(nèi)容
(2)添加配置文件并修改
[root@localhost ~]# vim /etc/nginx/nginx.conf

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid     /var/run/nginx.pid;

events {
  worker_connections  1024;
}

stream {

  log_format  main  '$remote_addr $upstream_addr - [$time_local] $status $upstream_bytes_sent';
  access_log  /var/log/nginx/k8s-access.log  main;

  upstream k8s-apiserver {
    server 192.168.35.100:6443;
    server 192.168.35.103:6443;         #只需修改IP為master1和master2的地址    
  }
  server {
        listen 6443;
        proxy_pass k8s-apiserver;
  }
  }

http {
  include    /etc/nginx/mime.types;
  default_type  application/octet-stream;

  log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
           '$status $body_bytes_sent "$http_referer" '
           '"$http_user_agent" "$http_x_forwarded_for"';

  access_log  /var/log/nginx/access.log  main;

  sendfile     on;
  #tcp_nopush   on;

  keepalive_timeout  65;

  #gzip  on;

  include /etc/nginx/conf.d/*.conf;
}
(3)驗(yàn)證語法是否錯(cuò)誤
[root@localhost ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
(4)修改首頁,進(jìn)行區(qū)分,一個(gè)master,一個(gè)backup。
lb01操作:
[root@localhost ~]# cd /usr/share/nginx/html/
[root@localhost html]# ls
50x.html  index.html
[root@localhost html]# vim index.html 

/14 

Welcome to master ginx!

lb02操作:
[root@localhost ~]# cd /usr/share/nginx/html/
[root@localhost html]# ls
50x.html  index.html
[root@localhost html]# vim index.html 

/14 

Welcome to backup ginx!

(5)開啟服務(wù),并訪問首頁
lb01:
[root@localhost ~]# systemctl start nginx
用瀏覽器訪問http://192.168.35.104/

kubernetes二進(jìn)制負(fù)載均衡部署如何實(shí)現(xiàn)

lb02:
[root@localhost ~]# systemctl start nginx
用瀏覽器訪問http://192.168.35.105/

kubernetes二進(jìn)制負(fù)載均衡部署如何實(shí)現(xiàn)

keepalived安裝部署

lb01和lb02操作:
1、安裝keepalived
[root@localhost ~]# yum install keepalived -y
2、修改配置文件
[root@localhost ~]# ls
anaconda-ks.cfg    keepalived.conf  公共  視頻  文檔  音樂
initial-setup-ks.cfg  nginx.sh     模板  圖片  下載  桌面
[root@localhost ~]# cp keepalived.conf /etc/keepalived/keepalived.conf
cp:是否覆蓋"/etc/keepalived/keepalived.conf"? yes

[root@localhost ~]# vim /etc/keepalived/keepalived.conf 
lb01是Master配置如下:
! Configuration File for keepalived

global_defs {
  # 接收郵件地址
  notification_email {
   acassen@firewall.loc
   failover@firewall.loc
   sysadmin@firewall.loc
  }
  # 郵件發(fā)送地址
  notification_email_from Alexandre.Cassen@firewall.loc
  smtp_server 127.0.0.1
  smtp_connect_timeout 30
  router_id NGINX_MASTER
}

vrrp_script check_nginx {
  script "/etc/nginx/check_nginx.sh"
}

vrrp_instance VI_1 {
  state MASTER 
  interface ens33
  virtual_router_id 51 # VRRP 路由 ID實(shí)例,每個(gè)實(shí)例是唯一的
  priority 100   # 優(yōu)先級(jí),備服務(wù)器設(shè)置 90  
  advert_int 1   # 指定VRRP 心跳包通告間隔時(shí)間,默認(rèn)1秒
  authentication {  
    auth_type PASS
    auth_pass 1111
  }   
  virtual_ipaddress {
    192.168.35.200/24
  }
  track_script {
    check_nginx
  }
}
lb02是Backup配置如下:
! Configuration File for keepalived

global_defs {
  # 接收郵件地址
  notification_email {
   acassen@firewall.loc
   failover@firewall.loc
   sysadmin@firewall.loc
  }
  # 郵件發(fā)送地址
  notification_email_from Alexandre.Cassen@firewall.loc
  smtp_server 127.0.0.1
  smtp_connect_timeout 30
  router_id NGINX_MASTER
}

vrrp_script check_nginx {
  script "/etc/nginx/check_nginx.sh"
}

vrrp_instance VI_1 {
  state BACKUP 
  interface ens33
  virtual_router_id 51 # VRRP 路由 ID實(shí)例,每個(gè)實(shí)例是唯一的
  priority 90   # 優(yōu)先級(jí),備服務(wù)器設(shè)置 90  
  advert_int 1   # 指定VRRP 心跳包通告間隔時(shí)間,默認(rèn)1秒
  authentication {  
    auth_type PASS
    auth_pass 1111
  }   
  virtual_ipaddress {
    192.168.35.200/24
  }
  track_script {
    check_nginx
  }
}
3、制作管理腳本
[root@localhost ~]# vim /etc/nginx/check_nginx.sh

count=$(ps -ef |grep nginx |egrep -cv "grep|$$")

if [ "$count" -eq 0 ];then
    systemctl stop keepalived
fi
4、賦予執(zhí)行權(quán)限并開啟服務(wù)
[root@localhost ~]# chmod +x /etc/nginx/check_nginx.sh
[root@localhost ~]# systemctl start keepalived
5、查看地址信息
(1)查看lb01地址信息
[root@localhost ~]# ip a
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN qlen 1
  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
  inet 127.0.0.1/8 scope host lo
    valid_lft forever preferred_lft forever
  inet6 ::1/128 scope host 
    valid_lft forever preferred_lft forever
2: ens33:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
  link/ether 00:0c:29:ba:e6:18 brd ff:ff:ff:ff:ff:ff
  inet 192.168.35.104/24 brd 192.168.35.255 scope global ens33
    valid_lft forever preferred_lft forever
  inet 192.168.35.200/24 scope global secondary ens33       #漂移地址在lb01中 
    valid_lft forever preferred_lft forever
  inet6 fe80::6ec5:6d7:1b18:466e/64 scope link tentative dadfailed 
    valid_lft forever preferred_lft forever
  inet6 fe80::2a3:b621:ca01:463e/64 scope link tentative dadfailed 
    valid_lft forever preferred_lft forever
  inet6 fe80::d4e2:ef9e:6820:145a/64 scope link tentative dadfailed 
    valid_lft forever preferred_lft forever
3: virbr0:  mtu 1500 qdisc noqueue state DOWN qlen 1000
  link/ether 52:54:00:14:39:99 brd ff:ff:ff:ff:ff:ff
  inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
    valid_lft forever preferred_lft forever
4: virbr0-nic:  mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
  link/ether 52:54:00:14:39:99 brd ff:ff:ff:ff:ff:ff
(2)查看lb02地址信息
[root@localhost ~]# ip a
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN qlen 1
  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
  inet 127.0.0.1/8 scope host lo
    valid_lft forever preferred_lft forever
  inet6 ::1/128 scope host 
    valid_lft forever preferred_lft forever
2: ens33:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
  link/ether 00:0c:29:1d:ec:b0 brd ff:ff:ff:ff:ff:ff
  inet 192.168.35.105/24 brd 192.168.35.255 scope global ens33
    valid_lft forever preferred_lft forever
  inet6 fe80::6ec5:6d7:1b18:466e/64 scope link tentative dadfailed 
    valid_lft forever preferred_lft forever
  inet6 fe80::2a3:b621:ca01:463e/64 scope link tentative dadfailed 
    valid_lft forever preferred_lft forever
  inet6 fe80::d4e2:ef9e:6820:145a/64 scope link tentative dadfailed 
    valid_lft forever preferred_lft forever
3: virbr0:  mtu 1500 qdisc noqueue state DOWN qlen 1000
  link/ether 52:54:00:14:39:99 brd ff:ff:ff:ff:ff:ff
  inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
    valid_lft forever preferred_lft forever
4: virbr0-nic:  mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
  link/ether 52:54:00:14:39:99 brd ff:ff:ff:ff:ff:ff
6、測試故障轉(zhuǎn)移切換
(1)驗(yàn)證地址漂移(lb01中使用pkill nginx,再在lb02中使用ip a 查看)
[root@localhost ~]# pkill nginx
[root@localhost ~]# systemctl status nginx
● nginx.service - nginx - high performance web server
  Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
  Active: failed (Result: exit-code) since 六 2020-02-08 16:54:45 CST; 11s ago
   Docs: http://nginx.org/en/docs/
 Process: 13156 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=1/FAILURE)
 Main PID: 6930 (code=exited, status=0/SUCCESS)

2月 08 16:54:45 localhost.localdomain kill[13156]: -q, --queue <信號(hào)>  …2)
2月 08 16:54:45 localhost.localdomain kill[13156]: -p, --pid       …號(hào)
2月 08 16:54:45 localhost.localdomain kill[13156]: -l, --list [=<信號(hào)>] …稱
2月 08 16:54:45 localhost.localdomain kill[13156]: -L, --table      …值
2月 08 16:54:45 localhost.localdomain kill[13156]: -h, --help   顯示此…出
2月 08 16:54:45 localhost.localdomain kill[13156]: -V, --version  輸出版…出
2月 08 16:54:45 localhost.localdomain kill[13156]: 更多信息請(qǐng)參閱 kill(1)。
2月 08 16:54:45 localhost.localdomain systemd[1]: nginx.service: control...
2月 08 16:54:45 localhost.localdomain systemd[1]: Unit nginx.service ent...
2月 08 16:54:45 localhost.localdomain systemd[1]: nginx.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

[root@localhost ~]# systemctl status keepalived.service       #keepalived服務(wù)也隨之關(guān)閉,說明nginx中的check_nginx.sh生效
● keepalived.service - LVS and VRRP High Availability Monitor
  Loaded: loaded (/usr/lib/systemd/system/keepalived.service; disabled; vendor preset: disabled)
  Active: inactive (dead)

2月 08 16:39:26 localhost.localdomain Keepalived_vrrp[7319]: VRRP_Instan...
2月 08 16:39:26 localhost.localdomain Keepalived_vrrp[7319]: Sending gra...
2月 08 16:39:26 localhost.localdomain Keepalived_vrrp[7319]: Sending gra...
2月 08 16:39:26 localhost.localdomain Keepalived_vrrp[7319]: Sending gra...
2月 08 16:39:26 localhost.localdomain Keepalived_vrrp[7319]: Sending gra...
2月 08 16:54:46 localhost.localdomain Keepalived[7317]: Stopping
2月 08 16:54:46 localhost.localdomain systemd[1]: Stopping LVS and VRRP ...
2月 08 16:54:46 localhost.localdomain Keepalived_vrrp[7319]: VRRP_Instan...
2月 08 16:54:46 localhost.localdomain Keepalived_vrrp[7319]: VRRP_Instan...
2月 08 16:54:47 localhost.localdomain systemd[1]: Stopped LVS and VRRP H...
Hint: Some lines were ellipsized, use -l to show in full.
在lb01查看地址:
[root@localhost ~]# ip a
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN qlen 1
  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
  inet 127.0.0.1/8 scope host lo
    valid_lft forever preferred_lft forever
  inet6 ::1/128 scope host 
    valid_lft forever preferred_lft forever
2: ens33:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
  link/ether 00:0c:29:ba:e6:18 brd ff:ff:ff:ff:ff:ff
  inet 192.168.35.104/24 brd 192.168.35.255 scope global ens33
    valid_lft forever preferred_lft forever
  inet6 fe80::6ec5:6d7:1b18:466e/64 scope link tentative dadfailed 
    valid_lft forever preferred_lft forever
  inet6 fe80::2a3:b621:ca01:463e/64 scope link tentative dadfailed 
    valid_lft forever preferred_lft forever
  inet6 fe80::d4e2:ef9e:6820:145a/64 scope link tentative dadfailed 
    valid_lft forever preferred_lft forever
3: virbr0:  mtu 1500 qdisc noqueue state DOWN qlen 1000
  link/ether 52:54:00:14:39:99 brd ff:ff:ff:ff:ff:ff
  inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
    valid_lft forever preferred_lft forever
4: virbr0-nic:  mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
  link/ether 52:54:00:14:39:99 brd ff:ff:ff:ff:ff:ff
在lb02查看地址:
[root@localhost ~]# ip a
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN qlen 1
  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
  inet 127.0.0.1/8 scope host lo
    valid_lft forever preferred_lft forever
  inet6 ::1/128 scope host 
    valid_lft forever preferred_lft forever
2: ens33:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
  link/ether 00:0c:29:1d:ec:b0 brd ff:ff:ff:ff:ff:ff
  inet 192.168.35.105/24 brd 192.168.35.255 scope global ens33
    valid_lft forever preferred_lft forever
  inet 192.168.35.200/24 scope global secondary ens33        #漂移地址轉(zhuǎn)移到lb02中
    valid_lft forever preferred_lft forever
  inet6 fe80::6ec5:6d7:1b18:466e/64 scope link tentative dadfailed 
    valid_lft forever preferred_lft forever
  inet6 fe80::2a3:b621:ca01:463e/64 scope link tentative dadfailed 
    valid_lft forever preferred_lft forever
  inet6 fe80::d4e2:ef9e:6820:145a/64 scope link tentative dadfailed 
    valid_lft forever preferred_lft forever
3: virbr0:  mtu 1500 qdisc noqueue state DOWN qlen 1000
  link/ether 52:54:00:14:39:99 brd ff:ff:ff:ff:ff:ff
  inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
    valid_lft forever preferred_lft forever
4: virbr0-nic:  mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
  link/ether 52:54:00:14:39:99 brd ff:ff:ff:ff:ff:ff
(2)恢復(fù)操作(在lb01中先啟動(dòng)nginx服務(wù),再啟動(dòng)keepalived服務(wù))
[root@localhost ~]# systemctl start nginx
[root@localhost ~]# systemctl start keepalived.service 
[root@localhost ~]# ip a
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN qlen 1
  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
  inet 127.0.0.1/8 scope host lo
    valid_lft forever preferred_lft forever
  inet6 ::1/128 scope host 
    valid_lft forever preferred_lft forever
2: ens33:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
  link/ether 00:0c:29:ba:e6:18 brd ff:ff:ff:ff:ff:ff
  inet 192.168.35.104/24 brd 192.168.35.255 scope global ens33
    valid_lft forever preferred_lft forever
  inet 192.168.35.200/24 scope global secondary ens33        #漂移地址又轉(zhuǎn)移回lb01中
    valid_lft forever preferred_lft forever
  inet6 fe80::6ec5:6d7:1b18:466e/64 scope link tentative dadfailed 
    valid_lft forever preferred_lft forever
  inet6 fe80::2a3:b621:ca01:463e/64 scope link tentative dadfailed 
    valid_lft forever preferred_lft forever
  inet6 fe80::d4e2:ef9e:6820:145a/64 scope link tentative dadfailed 
    valid_lft forever preferred_lft forever
3: virbr0:  mtu 1500 qdisc noqueue state DOWN qlen 1000
  link/ether 52:54:00:14:39:99 brd ff:ff:ff:ff:ff:ff
  inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
    valid_lft forever preferred_lft forever
4: virbr0-nic:  mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
  link/ether 52:54:00:14:39:99 brd ff:ff:ff:ff:ff:ff
(3)nginx站點(diǎn)/usr/share/nginx/html
在宿主機(jī)上ping虛擬IP,保證可以ping通,說明可以去進(jìn)行訪問

kubernetes二進(jìn)制負(fù)載均衡部署如何實(shí)現(xiàn)

在lb01查看index.html
[root@localhost ~]# cat /usr/share/nginx/html/index.html 



Welcome to nginx!



Welcome to master ginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

在lb01查看index.html [root@localhost ~]# cat /usr/share/nginx/html/index.html  Welcome to nginx!

Welcome to backup nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

因?yàn)槠频刂肥窃趌b01上,所以訪問漂移地址時(shí)現(xiàn)實(shí)的nginx首頁應(yīng)該是包含master的

kubernetes二進(jìn)制負(fù)載均衡部署如何實(shí)現(xiàn)

node節(jié)點(diǎn)綁定VIP地址

1、修改node節(jié)點(diǎn)配置文件統(tǒng)一VIP(bootstrap.kubeconfig,kubelet.kubeconfig)
[root@localhost ~]# vim /opt/kubernetes/cfg/bootstrap.kubeconfig
[root@localhost ~]# vim /opt/kubernetes/cfg/kubelet.kubeconfig
[root@localhost ~]# vim /opt/kubernetes/cfg/kube-proxy.kubeconfig

#全部都改為VIP地址

server: https://192.168.35.200:6443
2、替換完成直接自檢
[root@localhost ~]# cd /opt/kubernetes/cfg/

[root@localhost cfg]# grep 200 *
bootstrap.kubeconfig:   server: https://192.168.35.200:6443
kubelet.kubeconfig:   server: https://192.168.35.200:6443
kube-proxy.kubeconfig:   server: https://192.168.35.200:6443
3、重啟服務(wù)
[root@localhost cfg]# systemctl restart kubelet.service 
[root@localhost cfg]# systemctl restart kube-proxy.service 
4、在lb01上查看nginx的k8s日志
[root@localhost ~]# tail /var/log/nginx/k8s-access.log
192.168.35.102 192.168.35.100:6443 - [08/Feb/2020:17:42:00 +0800] 200 1119
192.168.35.102 192.168.35.103:6443 - [08/Feb/2020:17:42:00 +0800] 200 1121
192.168.35.101 192.168.35.100:6443 - [08/Feb/2020:17:42:14 +0800] 200 1121
192.168.35.101 192.168.35.100:6443 - [08/Feb/2020:17:42:14 +0800] 200 1121

在master01上操作

1、測試創(chuàng)建pod
[root@localhost k8s]# kubectl run nginx --image=nginx
kubectl run --generator=deployment/apps.v1beta1 is DEPRECATED and will be removed in a future version. Use kubectl create instead.
deployment.apps/nginx created
2、查看狀態(tài)
[root@localhost k8s]# kubectl get pods
NAME           READY  STATUS   RESTARTS  AGE
nginx-dbddb74b8-cfggf  1/1    0   ContainerCreating   64s        #正在創(chuàng)建中
[root@localhost k8s]# kubectl get pods
NAME           READY  STATUS   RESTARTS  AGE
nginx-dbddb74b8-cfggf  1/1   Running  0      74s          #創(chuàng)建完成,運(yùn)行中
3、注意日志問題(無法查看,會(huì)報(bào)錯(cuò))
[root@localhost k8s]# kubectl logs nginx-dbddb74b8-cfggf
Error from server (Forbidden): Forbidden (user=system:anonymous, verb=get, resource=nodes, subresource=proxy) ( pods/log nginx-dbddb74b8-cfggf)
解決辦法:
(1)權(quán)限提升
[root@localhost k8s]# kubectl create clusterrolebinding cluster-system-anonymous --clusterrole=cluster-admin --user=system:anonymous
clusterrolebinding.rbac.authorization.k8s.io/cluster-system-anonymous created
(2)在去進(jìn)行日志查看
[root@localhost k8s]# kubectl logs nginx-dbddb74b8-cfggf

//并不會(huì)出現(xiàn)報(bào)錯(cuò),只是因?yàn)闆]有去訪問,所以沒有產(chǎn)生日志
4、查看pod網(wǎng)絡(luò)
[root@localhost k8s]# kubectl get pods -o wide
NAME           READY  STATUS   RESTARTS  AGE  IP       NODE       NOMINATED NODE
nginx-dbddb74b8-cfggf  1/1   Running  0      14m  172.17.45.2  192.168.35.101  
5、在對(duì)應(yīng)網(wǎng)段的node節(jié)點(diǎn)上操作可以直接訪問
[root@localhost cfg]# curl 172.17.45.2



Welcome to nginx!



Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

6、訪問就會(huì)產(chǎn)生日志,回到master01操作
[root@localhost k8s]# kubectl logs nginx-dbddb74b8-cfggf

172.17.45.1 - - [08/Feb/2020:10:10:29 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.29.0" "-"

看了以上關(guān)于kubernetes二進(jìn)制負(fù)載均衡部署如何實(shí)現(xiàn),如果大家還有什么地方需要了解的可以在創(chuàng)新互聯(lián)行業(yè)資訊里查找自己感興趣的或者找我們的專業(yè)技術(shù)工程師解答的,創(chuàng)新互聯(lián)技術(shù)工程師在行業(yè)內(nèi)擁有十幾年的經(jīng)驗(yàn)了。創(chuàng)新互聯(lián)官網(wǎng)鏈接www.yisu.com


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


當(dāng)前文章:kubernetes二進(jìn)制負(fù)載均衡部署如何實(shí)現(xiàn)-創(chuàng)新互聯(lián)
轉(zhuǎn)載注明:http://weahome.cn/article/gpspi.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部