大家好,
我使用 Kubekey 安裝 K8s,無法使用 Load balancer,請問 nodeport 如何去做 ingress 讓 https 能夠訪問?
我也沒有域名,希望直接用 https:// {IP} 訪問就好
KubeSphere 地端k8s 使用 nodeport 如何用 https 訪問 web console?
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
4条回答 默认 最新
阿里嘎多学长 2025-02-17 10:01关注阿里嘎多学长整理AIGC生成,因移动端显示问题导致当前答案未能完全显示,请使用PC端查看更加详细的解答过程
KubeSphere 地端k8s 使用 nodeport 如何用 https 訪問 web console?
你使用 KubeKey 安裝 K8s,無法使用 Load balancer,想使用 NodePort 來實現 ingress,讓 https 能夠訪問 Web Console。
解決方案:
- 創建 Service
apiVersion: v1 kind: Service metadata: name: web-console spec: selector: app: web-console ports: - name: https port: 443 targetPort: 8443 type: NodePort這個 Service 會將流量轉發到 Pod 的 8443 端口,並將流量Expose 到 NodePort 443。
- 創建 Ingress
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: web-console-ingress spec: rules: - host: <your-node-ip> http: paths: - path: / backend: serviceName: web-console servicePort: 443這個 Ingress 會將流量轉發到 Service 的 443 端口,並將流量Expose 到 Node 的 IP。
- 設置 NodePort
kubectl get svc web-console -o jsonpath='{.spec.ports[0].nodePort}'這個命令會顯示 NodePort 的值,例如 30080。
- 訪問 Web Console
https://<your-node-ip>:30080這樣你就可以使用 https 訪問 Web Console 了。
注意:這個解決方案假設你已經創建了 Web Console 的 Pod,並且 Pod 的 8443 端口Expose 到 NodePort。
解决 无用评论 打赏 举报