[root@k8s-master-31 ~]# kubectl get all -n ingress-nginx
NAME READY STATUS RESTARTS AGE
pod/ingress-nginx-admission-create-d5jpj 0/1 Completed 0 62m
pod/ingress-nginx-admission-patch-6h7bb 0/1 Completed 0 62m
pod/ingress-nginx-controller-8668bd45fd-cbh4f 1/1 Running 0 62m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/ingress-nginx-controller LoadBalancer 10.233.65.78 <pending> 80:30744/TCP,443:31237/TCP 62m
service/ingress-nginx-controller-admission ClusterIP 10.233.7.203 <none> 443/TCP 62m
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/ingress-nginx-controller 1/1 1 1 62m
NAME DESIRED CURRENT READY AGE
replicaset.apps/ingress-nginx-controller-8668bd45fd 1 1 1 62m
NAME COMPLETIONS DURATION AGE
job.batch/ingress-nginx-admission-create 1/1 1s 62m
job.batch/ingress-nginx-admission-patch 1/1 2s 62m
现在的情况是 :ingress-nginx-controller 已经是 running 状态了,但为何 service/ingress-nginx-controller 的 LoadBalancer 一直是 pending 状态?
是不是由于:公有云环境除外,是没有LB能力的?经过找到资料 :https://blog.csdn.net/textdemo123/article/details/99400237
之前一直运行的 ingress-demo ,也一直因为 ingress 的问题不可访问,虽然是running 状态,配置文件为 :
[root@k8s-master-31 ~]# cat ingress-demo.yaml
#deploy
apiVersion: apps/v1
kind: Deployment
metadata:
name: tomcat-demo
spec:
selector:
matchLabels:
app: tomcat-demo
replicas: 1
template:
metadata:
labels:
app: tomcat-demo
spec:
containers:
- name: tomcat-demo
image: registry.cn-hangzhou.aliyuncs.com/liuyi01/tomcat:8.0.51-alpine
ports:
- containerPort: 8080
---
#service
apiVersion: v1
kind: Service
metadata:
name: tomcat-demo
spec:
ports:
- port: 80
protocol: TCP
targetPort: 8080
selector:
app: tomcat-demo
---
#ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: tomcat-demo
spec:
rules:
- host: tomcat.mooc.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: tomcat-demo
port:
number: 80
[root@k8s-master-31 ~]# kubectl get svc -o wide
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
kubernetes ClusterIP 10.233.0.1 <none> 443/TCP 5d6h <none>
springboot-web-demo ClusterIP 10.233.161.134 <none> 80/TCP 2d app=springboot-web-demo
tomcat-demo ClusterIP 10.233.164.83 <none> 80/TCP 22m app=tomcat-demo
在 ingress controller 启动后,再来 apply 这个 demo 文件的时候还会报错 :
[root@k8s-master-31 ~]# kubectl apply -f ingress-demo.yaml
deployment.apps/tomcat-demo unchanged
service/tomcat-demo unchanged
Error from server (InternalError): error when creating "ingress-demo.yaml": Internal error occurred: failed calling webhook "validate.nginx.ingress.kubernetes.io": Post "https://ingress-nginx-controller-admission.ingress-nginx.svc:443/networking/v1/ingresses?timeout=10s": dial tcp 10.233.7.203:443: connect: connection timed out