Kubernetes Minikube Secrets 似乎未安装在 Pod 中
Kubernetes Minikube Secrets appear not mounted in Pod
我在 Kubernetes 中有一个 "Deployment",它在 GKE 中工作正常,但在 MiniKube 中失败。
我有一个带有 2 个容器的 Pod:-
(1) Nginx 作为反向代理(分别读取 /etc/tls 和 /etc/nginx 处的 secrets 和 configMap 卷)
(2) 监听 localhost
的基于 JVM 的服务
minikube 部署中的问题是 Nginx 容器无法读取似乎不存在的 TLS 证书 - 即 Pod 的秘密卷安装似乎失败。
nginx: [emerg] BIO_new_file("/etc/tls/server.crt") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/tls/server.crt','r') error:2006D080:BIO routines:BIO_new_file:no such file)
但如果我这样做 "minikube logs" 我会得到大量看似 "successful" tls 卷挂载...
MountVolume.SetUp succeeded for volume "kubernetes.io/secret/61701667-eca7-11e6-ae16-080027187aca-scriptwriter-tls" (spec.Name: "scriptwriter-tls")
秘密本身就在集群中...
$ kubectl get secrets scriptwriter-tls
NAME TYPE DATA AGE
scriptwriter-tls Opaque 3 1h
所以从秘密的角度来看,就 miniKube 而言,一切似乎都很好。但是另一方面nginx容器是看不到的。
我也无法登录容器,因为它一直在终止。
为了完整性,部署 yaml 中的相关部分 ...
首先是 nginx 配置...
- name: nginx
image: nginx:1.7.9
imagePullPolicy: Always
ports:
- containerPort: 443
lifecycle:
preStop:
exec:
command: ["/usr/sbin/nginx", "-s", "quit"]
volumeMounts:
- name: "nginx-scriptwriter-dev-proxf-conf"
mountPath: "/etc/nginx/conf.d"
- name: "scriptwriter-tls"
mountPath: "/etc/tls"
其次,容器级别的卷本身...
volumes:
- name: "scriptwriter-tls"
secret:
secretName: "scriptwriter-tls"
- name: "nginx-scriptwriter-dev-proxf-conf"
configMap:
name: "nginx-scriptwriter-dev-proxf-conf"
items:
- key: "nginx-scriptwriter.conf"
path: "nginx-scriptwriter.conf"
如有任何帮助,我们将不胜感激。
我是第一个class麻木的! :-) 有时错误就是错误!所以问题是这些秘密是使用本地 $HOME/.ssh/* 证书创建的……如果您是从具有不同证书的不同计算机生成它们,那么您猜怎么着?!所以现在全部修复:-)
我在 Kubernetes 中有一个 "Deployment",它在 GKE 中工作正常,但在 MiniKube 中失败。 我有一个带有 2 个容器的 Pod:- (1) Nginx 作为反向代理(分别读取 /etc/tls 和 /etc/nginx 处的 secrets 和 configMap 卷) (2) 监听 localhost
的基于 JVM 的服务minikube 部署中的问题是 Nginx 容器无法读取似乎不存在的 TLS 证书 - 即 Pod 的秘密卷安装似乎失败。
nginx: [emerg] BIO_new_file("/etc/tls/server.crt") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/tls/server.crt','r') error:2006D080:BIO routines:BIO_new_file:no such file)
但如果我这样做 "minikube logs" 我会得到大量看似 "successful" tls 卷挂载...
MountVolume.SetUp succeeded for volume "kubernetes.io/secret/61701667-eca7-11e6-ae16-080027187aca-scriptwriter-tls" (spec.Name: "scriptwriter-tls")
秘密本身就在集群中...
$ kubectl get secrets scriptwriter-tls
NAME TYPE DATA AGE
scriptwriter-tls Opaque 3 1h
所以从秘密的角度来看,就 miniKube 而言,一切似乎都很好。但是另一方面nginx容器是看不到的。
我也无法登录容器,因为它一直在终止。
为了完整性,部署 yaml 中的相关部分 ... 首先是 nginx 配置...
- name: nginx
image: nginx:1.7.9
imagePullPolicy: Always
ports:
- containerPort: 443
lifecycle:
preStop:
exec:
command: ["/usr/sbin/nginx", "-s", "quit"]
volumeMounts:
- name: "nginx-scriptwriter-dev-proxf-conf"
mountPath: "/etc/nginx/conf.d"
- name: "scriptwriter-tls"
mountPath: "/etc/tls"
其次,容器级别的卷本身...
volumes:
- name: "scriptwriter-tls"
secret:
secretName: "scriptwriter-tls"
- name: "nginx-scriptwriter-dev-proxf-conf"
configMap:
name: "nginx-scriptwriter-dev-proxf-conf"
items:
- key: "nginx-scriptwriter.conf"
path: "nginx-scriptwriter.conf"
如有任何帮助,我们将不胜感激。
我是第一个class麻木的! :-) 有时错误就是错误!所以问题是这些秘密是使用本地 $HOME/.ssh/* 证书创建的……如果您是从具有不同证书的不同计算机生成它们,那么您猜怎么着?!所以现在全部修复:-)