大网数据广告活动
服务器运维问答

TLS Termination using kubernetes Ingress

· 52CE 我爱测

I'm working on putting TLS/SSL in front of my wordpress site in kubernetes. I have an Ingress in front. Without any TLS config I can access the site ok. When I add TLS config I get timeouts on accessing the site. Ingress.yaml: ap…

问题原文

原帖链接 · Greg Pagendam-Turner · CC BY-SA 3.0

I'm working on putting TLS/SSL in front of my wordpress site in kubernetes.

I have an Ingress in front.

Without any TLS config I can access the site ok. When I add TLS config I get timeouts on accessing the site.

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

ingress-controller.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

已采纳解答

原帖链接 · Greg Pagendam-Turner · CC BY-SA 3.0

Turns out Load balancer needs to specify port 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

This thread was also helpful in completing the set up. https://github.com/kubernetes/ingress/issues/672

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-07-26)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。