如何使用kube-proxy在k8s中转发https serivce?

正如我们所知,kube-proxy用于代理可以通过apiserver从外部networking访问的serive,kube-proxy是否支持在k8s中代理https服务或者任何其他解决scheme,以便我们可以通过apiserver访问它?

您需要通过types为Nodeport的服务公开您的https pod,然后您可以通过集群中任何节点(master或worker)上定义的端口访问https,因为kube-proxy会将请求转发给您的pod,pod是属于服务。 NodePorts的默认范围是30000-32767。

使用nginx进行https服务和部署的示例configuration:

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 

kube-proxy iptables模式适用于IP层(networking层),它不关心数据包是http还是https