简体   繁体   English

Kubernetes:hostPath卷未安装

[英]Kubernetes: hostPath volume does not mount

I want to create a web app using apache server with https, and I have generated certificate files using letsencrypt. 我想使用带https的apache服务器创建一个Web应用程序,我使用letsencrypt生成了证书文件。 I already verified that cert.pem , chain.pem , fullchain.pem , and privkey.pem are stored on the host machine. 我已经验证了cert.pemchain.pemfullchain.pemprivkey.pem存储在主机上。 However, I cannot map them to the pod. 但是,我无法将它们映射到pod。 Here is the web-controller.yaml file: 这是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

After kubectl create -f web-controller.yaml the error log says: 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.

This is why I think the problem is that the certificates are not mapped into the container. 这就是我认为问题是证书没有映射到容器的原因。

Could anyone help me on this? 有人可以帮我吗? Thanks a lot! 非常感谢!

I figured it out: I have to mount it to /etc/letsencrypt/live/host rather than /usr/local/myapp/https 我想通了:我必须将它挂载到/etc/letsencrypt/live/host而不是/usr/local/myapp/https

This is probably not the root cause, but it works now. 这可能不是根本原因,但它现在有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM