Kubernetes 服务和集群与 Google Compute Engine 对象之间的关系是什么?
What are the relationships between Kubernetes services and clusters and Google Compute Engine objects?
我正在 Google 容器引擎上设置几个服务 运行,流量通过 Google HTTP 负载平衡器进入,使用路径映射。
有一个关于设置基于内容的负载平衡的很好的 Google 教程 here,但它都是关于普通的 Google 计算对象,如实例组和后端服务。但是,我有 Kubernetes 服务、pods 和集群。
Kubernetes 对象与 Google 计算资源之间的关系是什么?我如何以编程方式在两者之间进行映射?
(我知道我可以使用 Kubernetes Web Ingress 对象来进行平衡,如解释的那样 here,但看起来 Kubernetes Ingress 尚不支持 HTTPS,而这需要。)
What is the relationship between the Kubernetes objects and the Google Compute resources? How do I map between the two programmatically?
https://github.com/kubernetes/contrib/tree/master/Ingress/controllers/gce#overview
(I am aware that I could be using a Kubernetes web ingress object to do the balancing, as explained here, but it looks like Kubernetes Ingress does not yet support HTTPS, which need.)
Ingress 将在 1.2 中支持 HTTPS。这是资源的样子:https://github.com/kubernetes/kubernetes/issues/19497#issuecomment-174112834。同时,您可以使用 Ingress 设置 HTTP 负载平衡并手动修改它以支持 https。事先道歉,这很复杂,很快就会好起来的。
首先创建一个 HTTP Ingress:
- 创建 Type=NodePort
的服务
- 确保你有 BackendService quota
- 创建 HTTP Ingress
- 在防火墙中公开服务的节点端口(也如https://cloud.google.com/container-engine/docs/tutorials/http-balancer中所述)
- 等到kubect describe ing显示HEALTHY for you backends.
此时您应该能够 curl 您的 Ingress 负载均衡器 IP 并访问 nginx 服务(或您在步骤 1 中创建的任何服务)。
然后通过 GCE console 手动执行以下操作:
- 将 Ingress 资源的 IP 从 "Ephmermal" 更改为 "Static"(在 "External IP addresses" 选项卡中查找
kubectl get ing
中的 IP)
- 创建您的 ssl 证书。如果你只想要一个自签名证书,你可以这样做:
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /tmp/nginx.key -out /tmp/nginx.crt -subj "/CN=nginxsvc/O=nginxsvc"
- 为 HTTPS 负载均衡器创建新的目标 HTTPS 代理和转发规则,并将其分配给与 http 负载均衡器相同的(静态)IP。
此时你应该可以 curl https://loadbalancer-ip -k
我正在 Google 容器引擎上设置几个服务 运行,流量通过 Google HTTP 负载平衡器进入,使用路径映射。
有一个关于设置基于内容的负载平衡的很好的 Google 教程 here,但它都是关于普通的 Google 计算对象,如实例组和后端服务。但是,我有 Kubernetes 服务、pods 和集群。
Kubernetes 对象与 Google 计算资源之间的关系是什么?我如何以编程方式在两者之间进行映射?
(我知道我可以使用 Kubernetes Web Ingress 对象来进行平衡,如解释的那样 here,但看起来 Kubernetes Ingress 尚不支持 HTTPS,而这需要。)
What is the relationship between the Kubernetes objects and the Google Compute resources? How do I map between the two programmatically?
https://github.com/kubernetes/contrib/tree/master/Ingress/controllers/gce#overview
(I am aware that I could be using a Kubernetes web ingress object to do the balancing, as explained here, but it looks like Kubernetes Ingress does not yet support HTTPS, which need.)
Ingress 将在 1.2 中支持 HTTPS。这是资源的样子:https://github.com/kubernetes/kubernetes/issues/19497#issuecomment-174112834。同时,您可以使用 Ingress 设置 HTTP 负载平衡并手动修改它以支持 https。事先道歉,这很复杂,很快就会好起来的。
首先创建一个 HTTP Ingress:
- 创建 Type=NodePort 的服务
- 确保你有 BackendService quota
- 创建 HTTP Ingress
- 在防火墙中公开服务的节点端口(也如https://cloud.google.com/container-engine/docs/tutorials/http-balancer中所述)
- 等到kubect describe ing显示HEALTHY for you backends.
此时您应该能够 curl 您的 Ingress 负载均衡器 IP 并访问 nginx 服务(或您在步骤 1 中创建的任何服务)。
然后通过 GCE console 手动执行以下操作:
- 将 Ingress 资源的 IP 从 "Ephmermal" 更改为 "Static"(在 "External IP addresses" 选项卡中查找
kubectl get ing
中的 IP) - 创建您的 ssl 证书。如果你只想要一个自签名证书,你可以这样做:
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /tmp/nginx.key -out /tmp/nginx.crt -subj "/CN=nginxsvc/O=nginxsvc"
- 为 HTTPS 负载均衡器创建新的目标 HTTPS 代理和转发规则,并将其分配给与 http 负载均衡器相同的(静态)IP。
此时你应该可以 curl https://loadbalancer-ip -k