|NO.Z.00159|——————————|CloudNative|——|KuberNetes&服务发布.V10|——|service.v02|外部地址发生更新|

一、外部应用地址发生变化,解决方案
### --- 更改endpoints配置参数
~~~     查看百度地址
~~~     若是百度的地址或者目标地址变更了怎么办,我们只需要编辑endpoint就可以:
~~~     模拟编辑测试;代理一下淘宝的

[root@k8s-master01 ~]# ping taobao.com
PING taobao.com (140.205.220.96) 56(84) bytes of data.
### --- 编辑endpoints配置参数

[root@k8s-master01 ~]# vim nginx-ep-external.yaml 
subsets:
- addresses:
  - ip: 140.205.220.96
  ports:
  - name: http
    port: 80
    protocol: TCP 
二、重新触发容器
### --- 重新触发容器

[root@k8s-master01 ~]# kubectl replace -f nginx-ep-external.yaml 
endpoints/nginx-svc-external replaced
### --- 查看重新触发后endpoints容器对应的地址

[root@k8s-master01 ~]# kubectl get ep
NAME                 ENDPOINTS                                                          AGE
kubernetes           192.168.1.11:6443,192.168.1.12:6443,192.168.1.13:6443              11d
nginx-svc            172.17.125.13:443,172.18.195.18:443,172.17.125.13:80 + 1 more...   20h
nginx-svc-external   140.205.220.96:80 
三、查看endpoints对应的service地址并验证获取的数据是否与测试数据一致
### --- 查看创建的service地址

[root@k8s-master01 ~]# kubectl get svc
NAME                 TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
kubernetes           ClusterIP   10.96.0.1       <none>        443/TCP          11d
nginx-svc            ClusterIP   10.101.145.83   <none>        80/TCP,443/TCP   20h
nginx-svc-external   ClusterIP   10.97.162.95    <none>        80/TCP           12m
### --- 验证获取的数据是否与测试数据一致
~~~     可以看到返回值已经变为501,说明更新成功了

[root@k8s-master01 ~]# curl 10.97.162.95 -I
HTTP/1.1 501 Not Implemented                                   
Server: Tengine
Date: Wed, 21 Apr 2021 06:52:38 GMT
Content-Type: text/html
Content-Length: 583
Connection: close 

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

 

posted on   yanqi_vip  阅读(15)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示