使用 kubernetes Ingress 终止 TLS

使用 kubernetes Ingress 终止 TLS

我正在努力将 TLS/SSL 放在 kubernetes 中的 wordpress 网站前面。

我前面有一个 Ingress。

没有任何 TLS 配置,我可以正常访问网站。当我添加 TLS 配置时,访问网站时会超时。

Ingress.yaml:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: helloworld-rules
spec:
  tls:
  - hosts:
    - mysite.com
    secretName: tls-secret
  rules:
  - host: mysite.com
    http:
      paths:
      - path: /
        backend:
          serviceName: mysite
          servicePort: 80

入口控制器.yaml:

apiVersion: v1
kind: Service
metadata:
  name: nginx-ingress
  labels:
    app: nginx-ingress
spec:
  type: LoadBalancer
  ports:
  - port: 80
    targetPort: 80
  selector:
    app: nginx-ingress
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx-ingress
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: nginx-ingress
    spec:
      containers:
      - name: nginx-ingress
        image: gcr.io/google_containers/nginx-ingress-controller:0.9.0-beta.10
        imagePullPolicy: Always
        readinessProbe:
          httpGet:
            path: /healthz
            port: 10254
            scheme: HTTP
        livenessProbe:
          httpGet:
            path: /healthz
            port: 10254
            scheme: HTTP
          initialDelaySeconds: 10
          timeoutSeconds: 1
        env:
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        ports:
        - containerPort: 80
          hostPort: 80
        args:
        - /nginx-ingress-controller
        - --default-backend-service=$(POD_NAMESPACE)/echoheaders-default
        - --configmap=$(POD_NAMESPACE)/nginx-load-balancer-conf

答案1

事实证明,负载均衡器需要指定端口 443

apiVersion: v1
kind: Service
metadata:
  name: nginx-ingress
  labels:
    app: nginx-ingress
spec:
  type: LoadBalancer
  ports:
  - name: http
    port: 80
    targetPort: 80
  - name: https
    port: 443
    targetPort: 443
  selector:
    app: nginx-ingress

该线程对于完成设置也非常有帮助。 https://github.com/kubernetes/ingress/issues/672

相关内容