通过控制台使用ELB Ingress 配置HTTPS证书 Ingress支持配置TLS证书,以HTTPS协议的方式对外提供安全服务。 当前支持使用配置在集群中的IngressTLS密钥证书,以及ELB服务中的证书。 说明 同一个ELB实例的同一个端口配置HTTPS时,需要选择一样的证书。 使用IngressTLS密钥证书 步骤 1 请参见通过kubectl连接集群,使用kubectl连接集群。 步骤 2 执行如下命令,创建名为“ ingresstestsecret.yaml ”的YAML文件,此处文件名可自定义。 vi ingresstestsecret.yaml YAML文件配置如下: apiVersion: v1 data: tls.crt: LS0tLS0tCg tls.key: LS0tL0tLS0K kind: Secret metadata: annotations: description: test for ingressTLS secrets name: ingresstestsecret namespace: default type: IngressTLS 此处tls.crt和tls.key为示例,请获取真实密钥进行替换。tls.crt和tls.key的值为Base64编码后的内容。 步骤 3 创建密钥。 kubectl create f ingresstestsecret.yaml 回显如下,表明密钥已创建。 secret/ingresstestsecret created 查看已创建的密钥。 kubectl get secrets 回显如下,表明密钥创建成功。 NAME TYPE DATA AGE ingresstestsecret IngressTLS 2 13s 步骤 4 创建名为“ ingresstest.yaml ”的YAML文件,此处文件名可自定义。 vi ingresstest.yaml 说明 默认安全策略选择(kubernetes.io/elb.tlscipherspolicy)仅在1.17.17及以上版本的集群中支持。 自定义安全策略选择(kubernetes.io/elb.securitypolicyid)仅在1.17.17及以上版本的集群中支持。 以自动创建关联ELB为例,YAML文件配置如下: apiVersion: networking.k8s.io/v1beta1 kind: Ingress metadata: name: ingresstest annotations: kubernetes.io/elb.class: union kubernetes.io/ingress.class: cce kubernetes.io/elb.port: '443' kubernetes.io/elb.autocreate: '{ "type":"public", "bandwidthname":"ccebandwidth15511633796", "bandwidthchargemode":"bandwidth", "bandwidthsize":5, "bandwidthsharetype":"PER", "eiptype":"5bgp" }' kubernetes.io/elb.securitypolicyid: 99bec42b0dd4458398e9b05ce628d157