How to use kube-proxy to forward https serivce in k8s?

3/30/2017

As we know ,kube-proxy is used to proxy serive that could be accessed from external network via apiserver, does kube-proxy support to proxy https service in k8s or any other solution so that we could access it via apiserver ?

-- zulv
docker
https
kubernetes

2 Answers

4/7/2017

kube-proxy iptables mode works on IP layer(Networking layer), it does not care if the packet is http or https.

-- cizixs
Source: StackOverflow

4/2/2017

You need to expose your https pods via a service of type Nodeport, then you can access the https via the defined port on any node in the cluster (master or worker) because kube-proxy will forward the requests to your pods that are part of the service. NodePorts can be in the range of 30000-32767 by default.

Example configuration for an https service and deployment with nginx:

apiVersion: v1
kind: Service
metadata:
  annotations:
    service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
  name: nginx
  labels:
    app: nginx
spec:
  type: NodePort
  ports:
  - port: 443
    name: nginx
    targetPort: 443
    nodePort: 32756
  selector:
    app: nginx
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginxdeployment
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 443
-- Oswin Noetzelmann
Source: StackOverflow