整个配置过程还算顺利,也很简单,遇到了个小问题,简单记录下处理的思路;
阿里云上的k8s集群使用的是​​​ingress-nginx​​​,官网提供的信息非常全,还提供了配置的​​demo​​,如果证书没有问题的话,配置一个域名的https基本上就是分分钟的事情;

遇到的问题之一是因为生成的证书是带匹配符的*.domain.com这种形式,nginx-controller认为具体的子域名不包含在匹配符的域名里。

部署完证书,更新了ingress的配置之后,发现网站没有加载正确的证书,返回的证书时Kubernetes生成的fake certificate,导致网站无法访问;

于是查看nginx-controller pod的日志,找到如下部分

W0121 12:53:52.734872       1 controller.go:1008] ssl certificate fengxin58-stage/stage-sms-micro.fengxin58.com does not contain a common name for host stage-sms-micro.ddforme.com
I0121 12:53:52.808804 1 nginx.go:293] NGINX configuration diff
I0121 12:53:52.808822 1 nginx.go:294] --- /tmp/a207863636 2019-01-21 12:53:52.806425508 +0000
+++ /tmp/b631219875 2019-01-21 12:53:52.806425508 +0000
@@ -219,7 +219,7 @@
}
upstream fengxin58-stage-sentinel-30015 {
least_conn;
- server 127.0.0.1:8181 max_fails=0 fail_timeout=0;
+ server 172.16.15.185:30015 max_fails=0 fail_timeout=0;
}
upstream fengxin58-stage-sms-micro-30006 {
least_conn;
I0121 12:53:52.843809 1 controller.go:420] ingress backend successfully reloaded...

于是去查nginx controller代码仓库的issue,找到如下两个issue
​​​Got fake certificate on Azure​​​​Kubernetes Fake SSL cert used for wildcard SSL passthrough with SNI routing​​ 明确说了不支持通配符域名的证书,使用FQDN新生成了证书,就好使了。

参考

​Kuberneters源码分析 - Ingress nginx 主流程​​​​Kuberneters源码分析 - Ingress nginx 配置更新​​​​NGINX Ingress Controller​