Kubernetes:hostPath卷未挂载

时间:2016-06-14 18:25:13

标签: apache ssl docker kubernetes

我想使用带https的apache服务器创建一个Web应用程序,我使用letsencrypt生成了证书文件。我已经确认cert.pemchain.pemfullchain.pemprivkey.pem存储在主机上。但是,我无法将它们映射到pod。这是web-controller.yaml文件:

apiVersion: v1
kind: ReplicationController
metadata:
  labels:
    name: web
  name: web-controller
spec:
  replicas: 2
  selector:
    name: web
  template:
    metadata:
      labels:
        name: web
    spec:
      containers:
      - image: <my-wen-app-image>
        command: ['/bin/sh', '-c']
        args: ['sudo a2enmod ssl && service apache2 restart && sudo /usr/sbin/apache2ctl -D FOREGROUND']
        name: web
        ports:
        - containerPort: 80
          name: http-server
        volumeMounts:
          - mountPath: /usr/local/myapp/https
            name: test-volume
            readOnly: false
      volumes:
        - hostPath:
            path: /etc/letsencrypt/live/xxx.xxx.xxx.edu
          name: test-volume

错误日志显示kubectl create -f web-controller.yaml后:

AH00526: Syntax error on line 8 of /etc/apache2/sites-enabled/000-default.conf:
SSLCertificateFile: file '/usr/local/myapp/https/cert.pem' does not exist or is empty
Action 'configtest' failed.

这就是为什么我认为问题是证书没有映射到容器中。

有人可以帮我这个吗?非常感谢!

1 个答案:

答案 0 :(得分:0)

我明白了:我必须将其挂载到/etc/letsencrypt/live/host而不是/usr/local/myapp/https

这可能不是根本原因,但它现在有效。

相关问题