无法创建到KubeSphere的入口路由



我已经安装了nginx入口控制器。据我所知,使用入口的主要原因之一是不创建多个负载平衡器,从而节省资金。

我的kubessphere -console服务yaml清单如下:

cat kubesphere-console.yaml 
apiVersion: v1
kind: Service
metadata:
annotations:
meta.helm.sh/release-name: ks-core
meta.helm.sh/release-namespace: kubesphere-system
creationTimestamp: "2022-05-30T04:51:22Z"
finalizers:
- service.kubernetes.io/load-balancer-cleanup
labels:
app: ks-console
app.kubernetes.io/managed-by: Helm
tier: frontend
version: v3.1.0
name: ks-console
namespace: kubesphere-system
resourceVersion: "785863"
uid: 8628c2d0-164b-499f-ac0c-254ac77aa48c
spec:
allocateLoadBalancerNodePorts: true
clusterIP: 10.0.29.29
clusterIPs:
- 10.0.29.29
externalTrafficPolicy: Cluster
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- name: nginx
nodePort: 30880
port: 80
protocol: TCP
targetPort: 8000
selector:
app: ks-console
tier: frontend
sessionAffinity: None
type: LoadBalancer
status:
loadBalancer:
ingress:
- ip: 20.248.217.111

kubessphere -console入口路由yaml清单如下:

cat ingress-route-kubesphere.yaml 
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: kubesphere-console
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: ks-console
port:
number: 80
- path: /(.*)
pathType: Prefix
backend:
service:
name: ks-console
port:
number: 80
---

我在AKS集群上创建入口控制器,如下所示:

NAMESPACE=ingress-basic
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm install ingress-nginx ingress-nginx/ingress-nginx 
--create-namespace 
--namespace $NAMESPACE 
--set controller.service.annotations."service.beta.kubernetes.io/azure-load-balancer-health-probe-request-path"=/healthz

为nginxingress-controller创建LB,如下所示

k get svc -ningress-basic
NAME                                 TYPE           CLUSTER-IP    EXTERNAL-IP    PORT(S)                      AGE
ingress-nginx-controller             LoadBalancer   10.0.194.38   20.92.133.79   80:32703/TCP,443:31053/TCP   23h
ingress-nginx-controller-admission   ClusterIP      10.0.189.8    <none>         443/TCP                      23h

请注意,我在入口资源/网络方面不是那么好,所以我仍在学习。我的主要意图是使用一个入口控制器来公开所有的应用程序

的例子:

Kubesphere-console——比;端口80和端点应该是ksconsole

tekton-pipelines——比;端口80和端点应该是tekton-dashboard

我将真诚地感谢任何帮助。附言:我调查了入口控制舱日志,但没有运气,或者我真的不知道他们是什么意思....
k logs -f ingress-nginx-controller-6648b5dbb8-ntm8t -ningress-basic
10.240.0.4 - - [02/Jun/2022:12:29:42 +0000] "GET /healthz HTTP/1.1" 302 43 "-" "Load Balancer Agent" 194 0.002 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.000 302 6ea21ca50e247cc5d5e56975c8946fcc
10.240.0.4 - - [02/Jun/2022:12:29:42 +0000] "GET /healthz HTTP/1.1" 302 43 "-" "Load Balancer Agent" 194 0.003 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.004 302 1f2e1bfa0223e6b3b630a59fe7dba4d1
10.240.0.4 - - [02/Jun/2022:12:29:48 +0000] "GET /healthz HTTP/1.1" 302 43 "-" "Load Balancer Agent" 194 0.004 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.000 302 dbb5af0fd6426f783c337da06912e427
10.240.0.4 - - [02/Jun/2022:12:29:48 +0000] "GET /healthz HTTP/1.1" 302 43 "-" "Load Balancer Agent" 194 0.003 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.004 302 9fc084018c70c0f61f379e2266a056f8
10.240.0.4 - - [02/Jun/2022:12:29:54 +0000] "GET /healthz HTTP/1.1" 302 43 "-" "Load Balancer Agent" 194 0.003 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.004 302 f9e4c75d81aa0e7ff03e402dfdca2d35
10.240.0.4 - - [02/Jun/2022:12:29:54 +0000] "GET /healthz HTTP/1.1" 302 43 "-" "Load Balancer Agent" 194 0.003 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.000 302 187cc1fdb0fb1499c1ef040e8aeb5e01
10.240.0.4 - - [02/Jun/2022:12:30:00 +0000] "GET /healthz HTTP/1.1" 302 43 "-" "Load Balancer Agent" 194 0.003 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.004 302 9b3b1ae4165184ed16fa974be51cd460
10.240.0.4 - - [02/Jun/2022:12:30:00 +0000] "GET /healthz HTTP/1.1" 302 43 "-" "Load Balancer Agent" 194 0.003 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.004 302 eac2591d333af20ab1a3ee4052327291
10.240.0.4 - - [02/Jun/2022:12:30:06 +0000] "GET /healthz HTTP/1.1" 302 43 "-" "Load Balancer Agent" 194 0.004 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.000 302 f08f30018bcfd229adb1ed36b6473563
10.240.0.4 - - [02/Jun/2022:12:30:06 +0000] "GET /healthz HTTP/1.1" 302 43 "-" "Load Balancer Agent" 194 0.002 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.000 302 f157141e253c7fcc61008440ff047605
10.240.0.4 - - [02/Jun/2022:12:30:12 +0000] "GET /healthz HTTP/1.1" 302 43 "-" "Load Balancer Agent" 194 0.003 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.004 302 6ba07067e1345b665e16a3cab03ee50c
10.240.0.4 - - [02/Jun/2022:12:30:12 +0000] "GET /healthz HTTP/1.1" 302 43 "-" "Load Balancer Agent" 194 0.003 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.004 302 4978c44153381d1aac6bc959c4afa72d
10.240.0.4 - - [02/Jun/2022:12:30:18 +0000] "GET /healthz HTTP/1.1" 302 43 "-" "Load Balancer Agent" 194 0.003 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.004 302 fc1e6e7fd4f4219ef6ca38689275035a
10.240.0.4 - - [02/Jun/2022:12:30:18 +0000] "GET /healthz HTTP/1.1" 302 43 "-" "Load Balancer Agent" 194 0.003 [kubesphere-system-ks-console-80] [] 10.240.0.41:8000 43 0.000 302 1e286ef7a2b36a5b04521e59657e0433

通常,如果您创建一个没有指定主机的入口,则可以直接通过入口控制器svc的外部IP(通配符)访问您的服务。正确配置DNS解析后,可以配置入口域名

下面是一个通过nginx-ingress-controller暴露ks-apiserverks-console的示例。

nginx controller svc

root@master:~# kubectl -n ingress-nginx get svc
NAME                                 TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
ingress-nginx-controller             NodePort    10.233.11.24    <none>        80:30882/TCP,443:31054/TCP   15m
ingress-nginx-controller-admission   ClusterIP   10.233.18.191   <none>        443/TCP                      37m

ks-apiserverks-console的进入

root@master:~# kubectl -n kubesphere-system get ing api -o yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubesphere.io/creator: admin
creationTimestamp: "2022-06-02T08:48:48Z"
generation: 8
name: kubesphere
namespace: kubesphere-system
resourceVersion: "982261"
uid: f8f6cadf-874c-4996-8759-3467ac33d61c
spec:
ingressClassName: nginx
rules:
- host: api.172.31.50.170.nip.io
http:
paths:
- backend:
service:
name: ks-apiserver
port:
number: 80
path: /
pathType: ImplementationSpecific
- host: console.172.31.50.170.nip.io
http:
paths:
- backend:
service:
name: ks-console
port:
number: 80
path: /
pathType: ImplementationSpecific
status:
loadBalancer:
ingress:
- ip: 172.31.50.170

验证入口

$ curl http://api.172.31.50.170.nip.io:30882/
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {
},
"status": "Failure",
"message": "forbidden: User "system:anonymous" cannot GET path "/"",
"reason": "Forbidden",
"details": {
},
"code": 403
}%
$ curl http://console.172.31.50.170.nip.io:30882/
Redirecting to <a href="/login">/login</a>.%

最新更新