如何解决如何从 k3s 上的 nginx 入口修复空的外部 IP?
我想在我的 k3s 集群中使用 Metallb 和 Nginx 入口。
目前外部IP为<none>
kubectl -n ingress-Nginx get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
ingress-Nginx-controller-admission ClusterIP 10.43.182.71 <none> 443/TCP 14m
ingress-Nginx-controller NodePort 10.43.221.32 <none> 80:31121/TCP,443:31807/TCP 14m
我希望它是 192.168.178.240
我安装了 k3s
export K3S_KUBECONfig_MODE="644"
export INSTALL_K3S_EXEC=" --disable servicelb --disable traefik"
export KUBECONfig="~/.kube/config:/etc/rancher/k3s/k3s.yaml"
curl -sfL https://get.k3s.io | sh -
然后我用
安装了Metallbkubectl apply -f https://raw.githubusercontent.com/Metallb/Metallb/v0.9.6/manifests/namespace.yaml
kubectl apply -f https://raw.githubusercontent.com/Metallb/Metallb/v0.9.6/manifests/Metallb.yaml
kubectl create secret generic -n Metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"
使用配置 kubectl apply -f config.yaml
config.yaml
---
apiVersion: v1
kind: ConfigMap
Metadata:
namespace: Metallb-system
name: config
data:
config: |
address-pools:
- name: default
protocol: layer2
addresses:
- 192.168.178.240-192.168.178.250
然后我安装了 Nginx ingress 裸机
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-Nginx/controller-v0.45.0/deploy/static/provider/bareMetal/deploy.yaml
所有 Pod 都在运行
% k3s kubectl get pods --all-namespaces -o wide
NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READInesS GATES
kube-system metrics-server-86cbb8457f-xmp4w 1/1 Running 0 42m 10.42.0.3 master-pi4 <none> <none>
kube-system coredns-854c77959c-vlpxf 1/1 Running 0 42m 10.42.0.2 master-pi4 <none> <none>
kube-system local-path-provisioner-5ff76fc89d-l6nmk 1/1 Running 0 42m 10.42.0.4 master-pi4 <none> <none>
Metallb-system speaker-zghmh 1/1 Running 0 40m 192.168.178.37 master-pi4 <none> <none>
Metallb-system controller-64f86798cc-bgcvw 1/1 Running 0 40m 10.42.1.2 node1-pi4 <none> <none>
Metallb-system speaker-cjjl4 1/1 Running 0 40m 192.168.178.240 node1-pi4 <none> <none>
Metallb-system speaker-pnmzm 1/1 Running 0 40m 192.168.178.35 node2-pi3 <none> <none>
ingress-Nginx ingress-Nginx-admission-patch-kmt2s 0/1 Completed 1 19m 10.42.0.5 master-pi4 <none> <none>
ingress-Nginx ingress-Nginx-admission-create-7j98l 0/1 Completed 0 19m 10.42.0.6 master-pi4 <none> <none>
ingress-Nginx ingress-Nginx-controller-7b78df5bb4-6t2jz 1/1 Running 0 19m 10.42.1.3 node1-pi4 <none> <none>
为什么入口控制器没有分配外部 IP?
解决方法
在 deploy.yml 旁边,Service 被定义为 NodePort
,它必须更改为 LoadBalancer
。然后 nginx 入口将作为负载均衡器运行。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。