user2363318
user2363318

Reputation: 1067

fluentd container not mounting k8 worker directories via yaml (1.2)

When I run a container manually, I see the mounts but through a yaml, the mounts are empty.

apiVersion: v1
kind: Pod
metadata:
  name: fluentd2elasticsearch
  namespace: kube-system
spec:
  containers:
  - name: fluentd-es
    image: gcr.io/google_containers/fluentd-elasticsearch:1.15
    env:
      - name: FLUENTD_ARGS
        value: "-qq"
    volumeMounts:
      - name: containers
        mountPath: /var/lib/docker/containers
      - name: varlog
        mountPath: /var/log
  volumes:
  - name: containers
    source:
      hostDir:
        path: /var/lib/docker/containers
  - name: varlog
    source:
      hostDir:
        path: /var/log

When I connect to the container, the directories are empty or contains just the fluentd pod files. Run it manually:

docker run -d -v /var/lib/docker/containers:/var/lib/docker/containers -v /var/log:/var/log gcr.io/google_containers/fluentd-elasticsearch:1.15

Everything looks great but I need kuber to launch the container to get it talking to elasticsearch (inside kubernetes or k8 I see written sometimes).

docker inspect show this:

"Mounts": [
    {
        "Source": "/var/lib/kubelet/pods/1c11495ddc980659911fd7a596a346f8/volumes/kubernetes.io~empty-dir/containers",
        "Destination": "/var/lib/docker/containers",
        "Mode": "",
        "RW": true
    },
    {
        "Source": "/var/lib/kubelet/pods/1c11495ddc980659911fd7a596a346f8/volumes/kubernetes.io~empty-dir/varlog",
        "Destination": "/var/log",
        "Mode": "",
        "RW": true
    },

I'm guessing kubernetes.io~empty-dir is not what I want to see there.

Upvotes: 0

Views: 247

Answers (1)

Ryan Cox
Ryan Cox

Reputation: 5073

It looks like there are some structural problems with the volumes section. Try:

volumes:
  - name: containers
    hostPath:
      path: /var/lib/docker/containers
  - name: varlog
    hostPath:
      path: /var/log

Upvotes: 2

Related Questions