我正在为 GCE 中的 kubernates 集群启用 HTTPS。我正在尝试利用 kubernates Ingress
我有 cert 和 priv 密钥,并且我创建了一个附加这些(ssl-secret)的秘密:
apiVersion: v1
kind: Secret
metadata:
name: ssl-secret
type: Opaque
data:
tls.crt: LS0tLS...
tls.key: Mc0c4t...
我还有一个利用秘密(ssl-ingress)的入口:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ssl-ingress
spec:
backend:
serviceName: client # Name of the service
servicePort: my-https-port # Fetched from annotations
tls:
- hosts:
- test.domain.se # My domain address
secretName: ssl-secret # Name of my previously created secret
最后,我尝试使用以下设置将这些应用到我的集群:
apiVersion: v1
kind: Service
metadata:
name: client
annotations:
service.alpha.kubernetes.io/app-protocols: '{"my-https-port":"HTTPS"}' # Must map port-name to HTTPS for the GCP ingress controller
labels:
app: client-pods
spec:
type: NodePort
ports:
- port: 12345 #To my understanding, not used
targetPort: client-https
protocol: TCP
name: my-https-port
selector:
name: client-pods
因此,我的目标是使用此设置,我将能够在https://test.domain.se上访问 test.domain.se 。但它只是超时,而http://test.domain.se工作得很好。
描述入口我得到以下信息:
Name: ssl-ingress
Namespace: default
Address: 35.186.253.27
Default backend: client:my-https-port ()
TLS:
ssl-secret terminates test.domain.se
Rules:
Host Path Backends
---- ---- --------
* * client:my-https-port ()
Annotations:
static-ip: k8s-fw-default-ssl-ingress--59114a8fc664f628
target-proxy: k8s-tp-default-ssl-ingress--59114a8fc664f628
url-map: k8s-um-default-ssl-ingress--59114a8fc664f628
backends: {"k8s-be-31894--59114a8fc664f628":"UNHEALTHY"}
forwarding-rule: k8s-fw-default-ssl-ingress--59114a8fc664f628
Events:
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
7m 7m 1 loadbalancer-controller Normal ADD default/ssl-ingress
6m 6m 1 loadbalancer-controller Normal CREATE ip: 35.186.253.27
6m 2m 18 loadbalancer-controller Warning GCE googleapi: Error 400: The SSL key could not be parsed.
6m 2m 18 loadbalancer-controller Warning Service failed to identify user specified default backend, couldn't find nodeport for default/client, using system default
所以我的问题如下:
警告 GCE googleapi:错误 400:无法解析 SSL 密钥。
1:似乎 Ingress 需要 priv 密钥的密码。如何向秘密添加密码(密钥确实有已知的密码,但我如何告知秘密呢?)
警告服务无法识别用户指定的默认后端,找不到默认/客户端的节点端口,使用系统默认值
2:它声称它找不到默认/客户端的节点端口。我的目标服务客户端已经在运行,但是入口似乎在服务名称之前附加了 default/ 。为什么,以及如何指定客户端服务?