Kubernetes - SSL docker Nodejs

11/20/2018

I am new to K8s and this is my first time trying to get to grips with it. I am trying to set up a basic Nodejs Express API using this deployment.yml

kind: Service
apiVersion: v1
metadata:
  name: ${GCP_PROJECT_NAME}
spec:
  selector:
    app: ${GCP_PROJECT_NAME}
  ports:
    - protocol: TCP
      port: 80
      targetPort: 3000
  type: LoadBalancer
  loadBalancerIP: ${STATIC_IP_ADDRESS}
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: ${GCP_PROJECT_NAME}
  labels:
    app: ${GCP_PROJECT_NAME}
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ${GCP_PROJECT_NAME}
  template:
    metadata:
      labels:
        app: ${GCP_PROJECT_NAME}
    spec:
      containers:
        - name: ${GCP_PROJECT_NAME}
          image: gcr.io/${GCP_PROJECT_ID}/${GCP_PROJECT_NAME}:${CIRCLE_SHA1}
          ports:
            - name: http
              containerPort: 3000
              protocol: TCP
          env:
            - name: MONGO_URL_PROD
              value: $MONGO_URL_PROD

Everything works great with this setup and deploys to Kubernetes. When I hit my endpoint i.e. http://123.345.333.123 as expected there is no SSL.

I generated my SSL certificates and tried to follow this tutorial [https://vorozhko.net/kubernetes-sidecar-pattern-nginx-ssl-proxy-for-nodejs] but I wasn't able to. Could anyone point me in the right direction, what am I doing wrong or what am I missing?

-- Software Ninja
docker
google-compute-engine
google-kubernetes-engine
kubernetes
node.js

2 Answers

11/21/2018

This approach didnt work for me. Ingress was not able to get the Cluster IP, it shows <none>

-- Software Ninja
Source: StackOverflow

11/20/2018

You can use nginx ingress controller to handle all your SSL setup and usage. Following is a step by step guide to do so:

https://dgkanatsios.com/2017/07/07/using-ssl-for-a-service-hosted-on-a-kubernetes-cluster/

Hope this helps.

-- Prafull Ladha
Source: StackOverflow