我在AWS
上有一個主節點和兩個工作節點kubernetes集羣。我在集羣中有兩個環境(qc和prod),我創建了兩個名稱空間。 我有相同的服務運行在qc
和prod
命名空間。Kubernetes - 入口路由問題 - 路由命名空間
我已經爲兩個名稱空間創建了入口。
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-ingress
namespace: prod
spec:
rules:
- host: "*.qc-k8s.example.com"
http:
paths:
- path: /app
backend:
serviceName: client-svc
servicePort: 80
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-ingress
namespace: qc
spec:
rules:
- host: "*.qc-k8s.example.com"
http:
paths:
- path: /app-qc
backend:
serviceName: client-svc
servicePort: 80
我有兩個qc
和prod
命名空間client-svc
並打開80 然後創建ELB
服務和daemonset
,如下nodeport。
kind: Service
apiVersion: v1
metadata:
name: ingress-svc
namespace: deafult
annotations:
service.beta.kubernetes.io/aws-load-balancer-ssl-cert: arn:aws:acm:ca-central-1:492276880714:certificate/xxxxxxxxxxxxxx
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "443"
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
spec:
type: LoadBalancer
selector:
app: my-app
ports:
- name: http
port: 80
targetPort: http
- name: https
port: 443
targetPort: http
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: ingress-nginx
namespace: deafult
spec:
template:
metadata:
labels:
app: my-app
spec:
terminationGracePeriodSeconds: 60
containers:
- image: gcr.io/google_containers/nginx-ingress-controller:0.9.0-beta.6
name: ingress-nginx
imagePullPolicy: Always
ports:
- name: http
containerPort: 80
hostPort: 80
livenessProbe:
httpGet:
path: /healthz
port: 10254
scheme: HTTP
initialDelaySeconds: 30
timeoutSeconds: 5
readinessProbe:
httpGet:
path: /healthz
port: 10254
scheme: HTTP
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
resources:
limits:
cpu: 100m
memory: 100Mi
requests:
cpu: 100m
memory: 100Mi
args:
- /nginx-ingress-controller
- --default-backend-service=$(POD_NAMESPACE)/nginx-default-backend
當我試圖捲曲curl -iv https://gayan.qc-k8s.example.com/app/
。然後我得到一個錯誤。
2017/06/27 15:43:31 [錯誤] 158#158:* 981連接()失敗(111:連接被拒絕),當連接到上游時,客戶端:209.128.50.138,服務器:gayan.qc -k8s.example.com,請求:「GET/app/HTTP/1.1」,上游:「http://100.82.2.47:80/app/」,主機:「gayan.qc-k8s.example.com」 209.128.50.138 - [209.128.50.138,209.128。 「GET/app/HTTP/1.1」500 193「 - 」「curl/7.51.0」198 0.014 100.82.2.47:80,100.96。 2.48:80 0,193 0.001,0.013 502,500
如果我捲曲curl -iv https://gayan.qc-k8s.example.com/app-qc
,我遇到同樣的問題。 任何人都曾經遇到過這個錯誤?任何線索來解決這個問題?
謝謝