单节点部署Kubesphere+PorterLB - iCodex's Blog

/ 0评 / 0

测试环境说明:

  1. Hetzner AX41-NVME服务器一台
  2. 没有其他节点,只有单节点
  3. 只有一个公网IP

测试目标:PorterLB配置本地LB,实现docker程序公网暴露

参考资料:https://porterlb.io/docs/getting-started/installation/install-porter-on-kubernetes/

一、首先按照官网说明all-in-one的方式进行安装,然后进入终端,敲命令:

kubectl apply -f https://raw.githubusercontent.com/kubesphere/porter/master/deploy/porter.yaml

然后查看是否已经ready

kubectl get po -n porter-system

二、打开strictARP

kubectl edit configmap kube-proxy -n kube-system

ipvs:
strictARP: true

然后重启kube-proxy
kubectl rollout restart daemonset kube-proxy -n kube-system

三、查看本地网卡接口地址,主要是接口名称和ip,然后添加为eip

kubectl apply -f - <<EOF
apiVersion: network.kubesphere.io/v1alpha2
kind: Eip
metadata:
    name: porter-layer2-public-eip
spec:
    address: 162.55.6.168
    interface: eth0
    protocol: layer2
EOF

四、最后到项目网关那里,添加为LB模式,注意要添加注释

lb.kubesphere.io/v1alpha1: porter
protocol.porter.kubesphere.io/v1alpha1: layer2
eip.porter.kubesphere.io/v1alpha2: porter-layer2-public-eip

五、测试部署whoami,进入项目-应用负载-应用,添加一个自制应用,然后在应用路由那里使用自己的域名就好了

六、如何获取客户的实际IP,参考:https://kubesphere.io/zh/blogs/how-to-get-real-ip-in-pod/

结束啦~

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.