我使用HA-Proxy
(独立服务器)和Kubernetes v1.25.4
集群(一个主服务器和三个工作服务器)裸机。
- 流程图:-**
我已经在Link的帮助下部署了Jenkins
和Nginx ingress controller
,
但当我试图访问我们的Jenkins网址http://jenkins.company.com/jenkins
得到404 Not Found
错误。
- 我的Jenkins应用程序名称空间状态:-**
$ kubectl get all -n jenkins
NAME READY STATUS RESTARTS AGE
pod/jenkins-75cbc954b6-2wfpt 1/1 Running 2 (13d ago) 70d
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/jenkins-svc ClusterIP 10.96.180.240 <none> 80/TCP 70d
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/jenkins 1/1 1 1 70d
NAME DESIRED CURRENT READY AGE
replicaset.apps/jenkins-75cbc954b6 1 1 1 70d
- 入口控制器状态:-**
$ kubectl get all -n nginx-ingress
NAME READY STATUS RESTARTS AGE
pod/nginx-ingress-5xnz4 1/1 Running 2 (13d ago) 70d
pod/nginx-ingress-h2g9p 1/1 Running 3 (13d ago) 70d
pod/nginx-ingress-jgtc9 1/1 Running 2 (13d ago) 70d
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
daemonset.apps/nginx-ingress 3 3 3 3 3 <none> 70d
- 入口pod日志:-**
$ kubectl logs nginx-ingress-h2g9p -n nginx-ingress
2023/01/09 03:21:33 [notice] 25#25: signal 29 (SIGIO) received
2023/01/09 03:21:33 [notice] 25#25: signal 17 (SIGCHLD) received from 145
2023/01/09 03:21:33 [notice] 25#25: worker process 145 exited with code 0
2023/01/09 03:21:33 [notice] 25#25: worker process 164 exited with code 0
2023/01/09 03:21:33 [notice] 25#25: worker process 178 exited with code 0
2023/01/09 03:21:33 [notice] 25#25: signal 29 (SIGIO) received
- 进入状态:-**
一个三个三个一个
即使在Kubernetes群集主终端上,curl
也会出现以下错误。
$ curl -D- http://jenkins.company.com/jenkins -v
* Trying 160.20.21.6...
* TCP_NODELAY set
* Connected to jenkins.company.com (160.20.21.6) port 80 (#0)
> GET /jenkins HTTP/1.1
> Host: jenkins.company.com
> User-Agent: curl/7.58.0
> Accept: */*
>
< HTTP/1.1 404 Not Found
HTTP/1.1 404 Not Found
< Server: nginx/1.23.2
Server: nginx/1.23.2
< Date: Mon, 09 Jan 2023 02:58:06 GMT
Date: Mon, 09 Jan 2023 02:58:06 GMT
< Content-Type: text/html
Content-Type: text/html
< Content-Length: 153
Content-Length: 153
< Connection: keep-alive
Connection: keep-alive
<
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.23.2</center>
</body>
</html>
* Connection #0 to host jenkins.company.com left intact
- 我的Jenkins服务yaml文件如下,**
apiVersion: v1
kind: Service
metadata:
name: jenkins-svc
namespace: jenkins
labels:
app: jenkins
spec:
selector:
app: jenkins
type: ClusterIP
ports:
- protocol: TCP
port: 80
targetPort: 8080
- 我的nginx入口. yaml文件如下所示**
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
name: jenkins-ingress
namespace: jenkins
spec:
ingressClassName: nginx
rules:
- host: jenkins.company.com
http:
paths:
- path: /jenkins
pathType: Prefix
backend:
service:
name: jenkins-svc
port:
number: 80
请让我知道我的配置方面有什么问题?
任何帮助都会很有帮助。先谢了。
1条答案
按热度按时间41zrol4v1#
对我来说,它的外观,就像你的请求没有达到Nginx容器本身。所以尝试下面提到的选项。
由于Nginx入口作为守护程序集运行,因此Nginx容器端口80和443Map到主机的80和443端口。因此您可以使用http://{node-IP}连接到Nginx容器。您可以使用3个节点中的任何一个node-IP。一旦请求到达Nginx容器,则在检查您创建的资源规则后,它将被路由到后端容器。因此您可以使用http//{node-ip}/jenkins连接到jenkins容器。
要使用curl客户端进行测试,可以使用主机名欺骗。curl -H“主机:jenkins.company.com“http://{主机IP}/Jenkins