将kuberentes api暴露给网络的其他部分

时间:2018-04-19 08:27:36

标签: kubernetes kubectl

ss -tnulp|grep 8443
tcp    LISTEN     0      128    172.16.1.4:8443                  *:*                   users:(("kube-apiserver",pid=29513,fd=5))

我的api服务器正在运行,我想将它暴露给网络的其余部分,这是我的集群上的网络配置:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.16.1.4  netmask 255.255.255.0  broadcast 172.16.1.255
        inet6 fe80::f816:3eff:feb5:93a3  prefixlen 64  scopeid 0x20<link>
        ether fa:16:3e:b5:93:a3  txqueuelen 1000  (Ethernet)
        RX packets 218935  bytes 2518654013 (2.3 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 160281  bytes 33994810 (32.4 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 139.54.130.39  netmask 255.255.254.0  broadcast 139.54.131.255
        inet6 3ffe:302:11:2:f816:3eff:fe46:ab28  prefixlen 64  scopeid 0x0<global>
        inet6 fd12:1f4b:e0bf:10:f816:3eff:fe46:ab28  prefixlen 64  scopeid 0x0<global>
        inet6 fd12:1f4b:e0bf:1:f816:3eff:fe46:ab28  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::f816:3eff:fe46:ab28  prefixlen 64  scopeid 0x20<link>
        ether fa:16:3e:46:ab:28  txqueuelen 1000  (Ethernet)
        RX packets 3227129  bytes 845879874 (806.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1072031  bytes 132806957 (126.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

VM有外部IP 139.54.130.39 任何领导如何做到这一点?

1 个答案:

答案 0 :(得分:0)

您是否尝试使用此选项
 - --apiserver-advertise-address=139.54.130.39
 通过此网络 Kubectl 将能够握手139.54.130.39

你可以申请这取决于你的安装:
.......

如果 ..您将apiserver安装为pod  您可以在

中更改apiserver-advertise-address参数
/etc/kubernetes/manifests/kube-apiserver.yaml

或  检查/列出kube-system pod你必须获得实际的apiserver名称并进行编辑(仔细)

  

kubectl get pod -n kube-system

     

kubectl edit pod -n kube-system kube-apiserver

........

如果 ..您将apiserver安装为服务,请编辑systemd脚本

例如:

 vim /etc/systemd/system/kube-apiserver.service

修改

  

ExecStart =的/ usr / local / bin中/ KUBE-API服务器    --bind地址= 0.0.0.0
   --advertise_address = 139.54.130.39