首页 > 解决方案 > 无法在 ubuntu 上的 kubernetes 集群中创建 fluentd 容器

问题描述

我正在尝试使用 Elasticsearch、Fluentd 和 Kibana 对我的 kubernetes 集群进行日志监控。这是我在此任务中关注的链接。我用 beta.kubernetes.io/fluentd-ds-ready: "true" 标记了节点。最初,我为 Elasticsearch 创建了 statefulset。

之后,我创建了 fluentd-es-configmap.yaml、fluentd-es-ds.yaml 并使用kubectl get pods -n kube-system. Fluentd pod 显示容器创建等状态。我检查了 Fluentd 容器的日志,它显示如下错误:

来自服务器的错误(BadRequest):pod“fluentd-es-v2.0.1-csx96”中的容器“fluentd-es”正在等待启动:ContainerCreating

这是流利的 pod 描述:

Name:               fluentd-es-v2.0.1-csx96
Namespace:          kube-system
Priority:           0
PriorityClassName:  <none>
Node:               ldap/192.168.1.191
Start Time:         Wed, 10 Oct 2018 15:08:17 -0400
Labels:             controller-revision-hash=5754d85c97
                    k8s-app=fluentd-es
                    kubernetes.io/cluster-service=true
                    pod-template-generation=1
                    version=v2.0.1
Annotations:        scheduler.alpha.kubernetes.io/critical-pod:
Status:             Pending
IP:
Controlled By:      DaemonSet/fluentd-es-v2.0.1
Containers:
  fluentd-es:
    Container ID:
    Image:          gcr.io/google-containers/fluentd-elasticsearch:v2.0.1
    Image ID:
    Port:           <none>
    Host Port:      <none>
    State:          Waiting
      Reason:       ContainerCreating
    Ready:          False
    Restart Count:  0
    Limits:
      memory:  500Mi
    Requests:
      cpu:     100m
      memory:  200Mi
    Environment:
      FLUENTD_ARGS:  --no-supervisor -q
    Mounts:
      /etc/fluent/config.d from config-volume (rw)
      /host/lib from libsystemddir (ro)
      /var/lib/docker/containers from varlibdockercontainers (ro)
      /var/log from varlog (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from fluentd-es-token-l2b2m                                                                                         (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  varlog:
    Type:          HostPath (bare host directory volume)
    Path:          /var/log
    HostPathType:
  varlibdockercontainers:
    Type:          HostPath (bare host directory volume)
    Path:          /var/lib/docker/containers
    HostPathType:
  libsystemddir:
    Type:          HostPath (bare host directory volume)
    Path:          /usr/lib64
    HostPathType:
  config-volume:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      fluentd-es-config-v0.1.0
    Optional:  false
  fluentd-es-token-l2b2m:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  fluentd-es-token-l2b2m
    Optional:    false
QoS Class:       Burstable
Node-Selectors:  beta.kubernetes.io/fluentd-ds-ready=true
Tolerations:     node.kubernetes.io/disk-pressure:NoSchedule
                 node.kubernetes.io/memory-pressure:NoSchedule
                 node.kubernetes.io/not-ready:NoExecute
                 node.kubernetes.io/unreachable:NoExecute
                 node.kubernetes.io/unschedulable:NoSchedule
Events:
  Type     Reason       Age                    From           Message
  ----     ------       ----                   ----           -------
  Warning  FailedMount  14m (x42 over 107m)    kubelet, ldap  Unable to mount vo                                                                                        lumes for pod "fluentd-es-v2.0.1-csx96_kube-system(d80d9c78-ccbf-11e8-b7b5-52540                                                                                        0e4ff36)": timeout expired waiting for volumes to attach or mount for pod "kube-                                                                                        system"/"fluentd-es-v2.0.1-csx96". list of unmounted volumes=[config-volume]. li                                                                                        st of unattached volumes=[varlog varlibdockercontainers libsystemddir config-volume fluentd-es-token-l2b2m]                                                                                    
  Warning  FailedMount  3m23s (x60 over 109m)  kubelet, ldap  MountVolume.SetUp  failed for volume "config-volume" : configmap "fluentd-es-config-v0.1.0" not found                                                                                                                                                                             

有人可以建议我如何解决这个问题吗?

提前致谢。

标签: elasticsearchkubernetesfluentd

解决方案


问题似乎是 configmap 名称不匹配。DaemonSet 在寻找一个名为fluentd-es-config-v0.1.0但没有找到的configmap。

在存储库中,configmapfluentd-es-config-v0.1.5在 fluentd-es-ds.yaml 和 fluentd-es-configmap.yaml 中命名,因此只需使用这些文件即可。


推荐阅读