Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 负载平衡器类型的Kubernetes入口未按预期工作_Spring Boot_Docker_Nginx_Kubernetes_Kubernetes Ingress - Fatal编程技术网

Spring boot 负载平衡器类型的Kubernetes入口未按预期工作

Spring boot 负载平衡器类型的Kubernetes入口未按预期工作,spring-boot,docker,nginx,kubernetes,kubernetes-ingress,Spring Boot,Docker,Nginx,Kubernetes,Kubernetes Ingress,我安装在kubernetes集群中。当我试图通过入口控制器访问微服务端时,它没有按预期工作 我正在AWS实例上部署,我遵循了 我有两个Spring boot应用程序,其上下文路径为运行在端口9000上的/customer,运行在端口8000上的/prac,第三个是运行在端口80上的nginx 我已经执行了这些命令来创建LoadBalancer类型的入口控制器 kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress

我安装在kubernetes集群中。当我试图通过入口控制器访问微服务端时,它没有按预期工作

我正在AWS实例上部署,我遵循了

我有两个Spring boot应用程序,其上下文路径为运行在端口9000上的/customer,运行在端口8000上的/prac,第三个是运行在端口80上的nginx

我已经执行了这些命令来创建LoadBalancer类型的入口控制器

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/mandatory.yaml

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/provider/aws/service-l4.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/provider/aws/patch-configmap-l4.yaml
豆荚跑

NAMESPACE       NAME                                        READY   STATUS    RESTARTS   AGE     IP              NODE               NOMINATED NODE   READINESS GATES
ingress-nginx   nginx-ingress-controller-7f74f657bd-rh5fj   1/1     Running   0          23h     10.32.0.10      ip-172-31-11-145   <none>           <none>
kube-system     coredns-6955765f44-8wkwl                    1/1     Running   0          2d23h   10.32.0.3       ip-172-31-11-145   <none>           <none>
kube-system     coredns-6955765f44-w79bh                    1/1     Running   0          2d23h   10.32.0.2       ip-172-31-11-145   <none>           <none>
kube-system     etcd-ip-172-31-11-145                       1/1     Running   0          2d23h   172.31.11.145   ip-172-31-11-145   <none>           <none>
kube-system     kube-apiserver-ip-172-31-11-145             1/1     Running   0          2d23h   172.31.11.145   ip-172-31-11-145   <none>           <none>
kube-system     kube-controller-manager-ip-172-31-11-145    1/1     Running   0          2d23h   172.31.11.145   ip-172-31-11-145   <none>           <none>
kube-system     kube-proxy-6ktz2                            1/1     Running   0          2d23h   172.31.34.24    ip-172-31-34-24    <none>           <none>
kube-system     kube-proxy-mrlt6                            1/1     Running   0          2d23h   172.31.11.145   ip-172-31-11-145   <none>           <none>
kube-system     kube-scheduler-ip-172-31-11-145             1/1     Running   0          2d23h   172.31.11.145   ip-172-31-11-145   <none>           <none>
kube-system     weave-net-5bmvb                             2/2     Running   0          2d23h   172.31.11.145   ip-172-31-11-145   <none>           <none>
kube-system     weave-net-gl7xz                             2/2     Running   1          2d23h   172.31.34.24    ip-172-31-34-24    <none>           <none>
practice        customer-6d467cbc57-q6l6h                   1/1     Running   0          46h     10.32.0.8       ip-172-31-11-145   <none>           <none>
practice        customer-6d467cbc57-rx7zt                   1/1     Running   0          46h     10.32.0.5       ip-172-31-11-145   <none>           <none>
practice        ngtest-6c5ff8c7df-lmbhz                     1/1     Running   0          45h     10.44.0.1       ip-172-31-34-24    <none>           <none>
practice        ngtest-6c5ff8c7df-pvv4w                     1/1     Running   0          45h     10.32.0.9       ip-172-31-11-145   <none>           <none>
practice        prac-865d49687b-q8hss                       1/1     Running   0          23h     10.32.0.11      ip-172-31-11-145   <none>           <none>
practice        prac-865d49687b-wxkxr                       1/1     Running   0          23h     10.44.0.2       ip-172-31-34-24    <none>           <none>
practice        some-mysql-7896cfbb4c-kgnxf                 1/1     Running   0          46h     10.32.0.7       ip-172-31-11-145   <none>           <none>

我创建了经典的负载平衡器,但是负载平衡器的健康检查没有通过,健康检查我指向端口80,但是它显示为停止服务

我试图用集群IP进行检查,但它显示服务器的空响应,请帮助我

root@ip-172-31-11-145:/home/ubuntu# kubectl get svc --all-namespaces
NAMESPACE       NAME               TYPE           CLUSTER-IP      EXTERNAL-IP     PORT(S)                      AGE
default         kubernetes         ClusterIP      10.96.0.1       <none>          443/TCP                      2d23h
ingress-nginx   ingress-nginx      LoadBalancer   10.110.197.3    18.221.167.75   80:32414/TCP,443:31112/TCP   23h
kube-system     kube-dns           ClusterIP      10.96.0.10      <none>          53/UDP,53/TCP,9153/TCP       2d23h
practice        customer-service   ClusterIP      10.106.14.223   <none>          9090/TCP                     46h
practice        ngtest             ClusterIP      10.109.249.63   <none>          80/TCP                       46h
practice        prac-service       ClusterIP      10.110.96.199   <none>          8000/TCP                     46h
practice        some-mysql         ClusterIP      None            <none>          3306/TCP                     46h
root@ip-172-31-11-145:/home/ubuntu#
root@ip-172-31-11-145:/home/ubuntu#
root@ip-172-31-11-145:/home/ubuntu#
root@ip-172-31-11-145:/home/ubuntu# curl http://10.110.197.3/
curl: (52) Empty reply from server
root@ip-172-31-11-145:/home/ubuntu# curl http://10.110.197.3/prac/
curl: (52) Empty reply from server
root@ip-172-31-11-145:/home/ubuntu#
root@ip-172-31-11-145:/home/ubuntu#kubectl get svc——所有名称空间
命名空间名称类型CLUSTER-IP EXTERNAL-IP端口年龄
默认kubernetes ClusterIP 10.96.0.1 443/TCP 2d23h
ingress nginx ingress nginx负载平衡器10.110.197.3 18.221.167.75 80:32414/TCP,443:31112/TCP 23h
kube系统kube dns ClusterIP 10.96.0.10 53/UDP、53/TCP、9153/TCP 2d23h
实践客户服务群集IP 10.106.14.223 9090/TCP 46h
实践ngtest ClusterIP 10.109.249.63 80/TCP 46h
实践prac服务群集IP 10.110.96.199 8000/TCP 46h
练习一些mysql ClusterIP None 3306/TCP 46h
root@ip-172-31-11-145:/home/ubuntu#
root@ip-172-31-11-145:/home/ubuntu#
root@ip-172-31-11-145:/home/ubuntu#
root@ip-172-31-11-145:/home/ubuntu#curlhttp://10.110.197.3/
curl:(52)来自服务器的空回复
root@ip-172-31-11-145:/home/ubuntu#curlhttp://10.110.197.3/prac/
curl:(52)来自服务器的空回复
root@ip-172-31-11-145:/home/ubuntu#

您是手动创建经典负载平衡器的吗?@ArghyaSadhu是的,我是手动创建的,并且我在ingress Nginx中设置了外部IP您不应该手动创建它…您应用的第二个yaml应该创建它automatically@ArghyaSadhu此static/provider/aws/service-l4.yaml本应创建它,但未创建它。现在需要做什么?好的,让我们开始手动…您是否创建了进出安全组?是否已将节点端口配置为LB中的实例端口?
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: practice-ingress
  namespace: practice
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec: 
  rules:
  - host: kdhut.com
    http: 
      paths:
      - backend:
          serviceName: customer-service
          servicePort: 9090
        path: /customer
      - backend:
          serviceName: prac-service
          servicePort: 8000
        path: /prac
      - backend:
          serviceName: ngtest
          servicePort: 80
        path: /
root@ip-172-31-11-145:/home/ubuntu# kubectl get svc --all-namespaces
NAMESPACE       NAME               TYPE           CLUSTER-IP      EXTERNAL-IP     PORT(S)                      AGE
default         kubernetes         ClusterIP      10.96.0.1       <none>          443/TCP                      2d23h
ingress-nginx   ingress-nginx      LoadBalancer   10.110.197.3    18.221.167.75   80:32414/TCP,443:31112/TCP   23h
kube-system     kube-dns           ClusterIP      10.96.0.10      <none>          53/UDP,53/TCP,9153/TCP       2d23h
practice        customer-service   ClusterIP      10.106.14.223   <none>          9090/TCP                     46h
practice        ngtest             ClusterIP      10.109.249.63   <none>          80/TCP                       46h
practice        prac-service       ClusterIP      10.110.96.199   <none>          8000/TCP                     46h
practice        some-mysql         ClusterIP      None            <none>          3306/TCP                     46h
root@ip-172-31-11-145:/home/ubuntu#
root@ip-172-31-11-145:/home/ubuntu#
root@ip-172-31-11-145:/home/ubuntu#
root@ip-172-31-11-145:/home/ubuntu# curl http://10.110.197.3/
curl: (52) Empty reply from server
root@ip-172-31-11-145:/home/ubuntu# curl http://10.110.197.3/prac/
curl: (52) Empty reply from server
root@ip-172-31-11-145:/home/ubuntu#