Kubernetes: hostPath volume does not mount

6/14/2016

I want to create a web app using apache server with https, and I have generated certificate files using letsencrypt. I already verified that cert.pem, chain.pem, fullchain.pem, and privkey.pem are stored on the host machine. However, I cannot map them to the pod. Here is the web-controller.yaml file:

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:

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!

-- Yunsheng Bai
apache
docker
kubernetes
ssl

1 Answer

6/15/2016

I figured it out: I have to mount it to /etc/letsencrypt/live/host rather than /usr/local/myapp/https

This is probably not the root cause, but it works now.

-- Yunsheng Bai
Source: StackOverflow