我用印花布和haproxy设置了一个kubernetes单节点主平面。现在,每当我要创建一个Ingress时,该地址将保持为空,服务器将返回503错误。
以下显示了我的kubernetes部署。
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
selector:
matchLabels:
app: nginx
replicas: 1
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: wordpress
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
ports:
- port: 8080
targetPort: 8080
protocol: TCP
selector:
app: nginx
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: web-ingress
spec:
rules:
- host: wordpress.example.org
http:
paths:
- path: /
backend:
serviceName: nginx-service
servicePort: 8080
这是我从kubernetes cl中获得的输出。
NAME HOSTS ADDRESS PORTS AGE
ingress.extensions/web-ingress wordpress.example.org 80 35s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 10h
service/nginx-service ClusterIP 10.97.189.233 <none> 8080/TCP 35s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.extensions/nginx-deployment 1/1 1 1 35s
NAME READY STATUS RESTARTS AGE
pod/nginx-deployment-7798df5dd5-gnwf2 1/1 Running 0 35s
NAME ENDPOINTS AGE
endpoints/kubernetes 164.68.103.199:6443 10h
endpoints/nginx-service 192.168.104.150:8080 36s
Pascals-MBP-c8a4:api-gateway pascal$
我希望入口将接收服务的群集ip,并且正在侦听给定的主机uri,并提供除给定的503错误之外的其他信息。
//编辑:它是一个独立的节点,而不是台式机版本或minikube安装!
答案 0 :(得分:0)
服务的默认类型是ClusterIP,但仅用于群集内部通信。 对于外部流量,应切换到NodePort类型。 例如:
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
type: NodePort
ports:
- port: 80
targetPort: 8080
protocol: TCP
name: http
selector:
run: nginx
如果我没记错的话,nginx alb控制器允许使用ClusterIP(或LoadBalancer)。
此处有更多信息:https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types
答案 1 :(得分:0)
此图像的容器端口是80,而我暴露了8080。