How to setup HTTPS load balancer in kubernetes

11/26/2018

I have a requirement to make my application to support the request over https and block the http port.I want to use certificate provided my company so do i need the jks certs or some other type. Im not sure how to make it https in gke. I have seen couple of documentation but they are not clear.This is my current kubernetes deployment file.Please let me know how can i configure it.

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
-- Sid
google-kubernetes-engine
kubernetes
kubernetes-helm
kubernetes-ingress
ssl-certificate

1 Answer

11/26/2018

You have to create a secret that contains your SSL certificate and then reference that secret in your ingress spec as explained here

-- Patrick W
Source: StackOverflow