如何在Kubernetes中设置HTTPS负载均衡器

时间:2018-11-26 17:08:03

标签: kubernetes ssl-certificate google-kubernetes-engine kubernetes-helm kubernetes-ingress

我需要让我的应用程序支持https上的请求并阻止http端口。我想使用我公司提供的证书,所以我需要jks证书或其他类型的证书。我不确定如何在gke中将其设为https。我看过一些文档,但是不清楚。这是我当前的kubernetes部署文件,请让我知道如何配置它。

apiVersion: v1
kind: Service
metadata:
  name: oms-integeration-service
spec:
  type: NodePort
  ports:
  - port: 80
    targetPort: 8081
    protocol: TCP
    name: http
  selector:
    app: integeration
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: integeration
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: integeration
    spec:
      containers:
      - name: esp
        image: gcr.io/endpoints-release/endpoints-runtime:1
        args: [
          "--http_port=8081",
          "--backend=127.0.0.1:8080",
          "--service=oms.endpoints.gcp-dsw-oms-int-{{env}}.cloud.goog",
          "--rollout_strategy=managed",
        ]
      - name: integeration-container
        image: us.gcr.io/gcp-dsw-oms-int-{{env}}/gke/oms-integ-service:{{tag}}
        readinessProbe:
          httpGet:
            path: /healthcheck
            port: 8080
          initialDelaySeconds: 60
          periodSeconds: 10
        ports:
        - containerPort: 8080
        resources:
          requests:
            memory: 500M
        env:
        - name: LOGGING_FILE
          value: "integeration-container"
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: integeration-ingress
  annotations:
    kubernetes.io/ingress.global-static-ip-name: "oms-int-ip"
    kubernetes.io/ingress.class: "gce"
  rules:
  - host: "oms.endpoints.gcp-dsw-oms-int-{{env}}.cloud.goog"
    http:
      paths:
      - path: /*
        backend:
          serviceName: oms-integeration-service
          servicePort: 80

1 个答案:

答案 0 :(得分:0)

您必须创建一个包含SSL证书的密码,然后在您的入口规范中将该密码引用为explained here