如何处理 Nginx on Kubernetes (GKE) 的配置?
How to handle configuration for Nginx on Kubernetes (GKE)?
由于 ingress resources (in my case I need more than 50 routes which is not supported in Google Container Engine) I'm considering using Nginx as a reverse proxy to other backend services. What I want to do is essentially the same as an ingress resource provides such as routing path "/x" to service x and "/y" to service y. I'd like to run more than one instance of Nginx for HA, probably behind a service 的限制。我的问题主要涉及我有几个选项的配置:
- 创建自定义 Docker 镜像,使用 nginx 作为基础镜像,然后复制
我们的 nginx 配置到这个图像中。这会让它很
很容易 运行 这个基于 nginx 的镜像在 Kubernetes 上。但是虽然这
需要重建、发布和存储新的工作
每次配置更改时自定义 nginx 图像。我们已经
为此设置了管道,所以这不会是一个大问题
操作上。
- 使用 vanilla nginx docker 镜像,创建一个在所有 nginx pods 处于只读模式。我看到的这个方法的问题是如何以简单的方式将配置更新复制到磁盘?
- 还有更好的选择吗?我查看了配置映射 and/or 秘密(这将解决配置更新问题)但我认为它们不能包含任意数据,例如 nginx 配置文件。
包含文本文件的 ConfigMaps 应该完全没有问题。看看 --from-file
选项:http://kubernetes.io/docs/user-guide/configmap/.
我不确定 ConfigMap 中的二进制文件。我可以添加 JPEG,但尝试读取对象会导致错误,因此这可能不是预期的(需要额外的 base64 编码等)。
$ kubectl create configmap test --from-file=foo1=/tmp/scudcloud_U0GQ27N0M.jpg
configmap "test" created
$ kubectl get configmap test -o yaml
error: error converting JSON to YAML: %!(EXTRA *errors.errorString=yaml: control characters are not allowed)
由于 ingress resources (in my case I need more than 50 routes which is not supported in Google Container Engine) I'm considering using Nginx as a reverse proxy to other backend services. What I want to do is essentially the same as an ingress resource provides such as routing path "/x" to service x and "/y" to service y. I'd like to run more than one instance of Nginx for HA, probably behind a service 的限制。我的问题主要涉及我有几个选项的配置:
- 创建自定义 Docker 镜像,使用 nginx 作为基础镜像,然后复制 我们的 nginx 配置到这个图像中。这会让它很 很容易 运行 这个基于 nginx 的镜像在 Kubernetes 上。但是虽然这 需要重建、发布和存储新的工作 每次配置更改时自定义 nginx 图像。我们已经 为此设置了管道,所以这不会是一个大问题 操作上。
- 使用 vanilla nginx docker 镜像,创建一个在所有 nginx pods 处于只读模式。我看到的这个方法的问题是如何以简单的方式将配置更新复制到磁盘?
- 还有更好的选择吗?我查看了配置映射 and/or 秘密(这将解决配置更新问题)但我认为它们不能包含任意数据,例如 nginx 配置文件。
包含文本文件的 ConfigMaps 应该完全没有问题。看看 --from-file
选项:http://kubernetes.io/docs/user-guide/configmap/.
我不确定 ConfigMap 中的二进制文件。我可以添加 JPEG,但尝试读取对象会导致错误,因此这可能不是预期的(需要额外的 base64 编码等)。
$ kubectl create configmap test --from-file=foo1=/tmp/scudcloud_U0GQ27N0M.jpg
configmap "test" created
$ kubectl get configmap test -o yaml
error: error converting JSON to YAML: %!(EXTRA *errors.errorString=yaml: control characters are not allowed)