Kubernetes HTTPS Ingress in Google Container Engine

我与影子孤独终老i 提交于 2020-01-11 05:12:09

问题


I want to expose a HTTP service running in Google Container Engine over HTTPS only load balancer.

How to define in ingress object that I want HTTPS only load balancer instead of default HTTP?

Or is there a way to permanently drop HTTP protocol from created load balancer? When I add HTTPS protocol and then drop HTTP protocol, HTTP is recreated after few minutes by the platform.

Ingress:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: myapp-ingress
spec:
  backend:
    serviceName: myapp-service
    servicePort: 8080

回答1:


In order to have HTTPs service exposed only, you can block traffic on port 80 as mentioned on this link:

You can block traffic on :80 through an annotation. You might want to do this if all your clients are only going to hit the loadbalancer through https and you don't want to waste the extra GCE forwarding rule, eg:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test
  annotations:
    kubernetes.io/ingress.allow-http: "false"
spec:
  tls:
  # This assumes tls-secret exists.
  # To generate it run the make in this directory.
  - secretName: tls-secret
  backend:
    serviceName: echoheaders-https
    servicePort: 80


来源:https://stackoverflow.com/questions/40763718/kubernetes-https-ingress-in-google-container-engine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!