kubernetes - Kubespray Kubernetes安装失败-dockerd [8296]:无法使用文件/etc/docker/daemon.json配置Docker守护程序

标签 kubernetes kubespray

使用kubespray安装kubernetes时发生上述错误。

安装失败,并且通过journal -xe我看到以下内容:

    ` node1 systemd[1]: Starting Docker Application Container Engine...
-- Subject: Unit docker.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.service has begun starting up.
Dec 09 23:37:01 node1 dockerd[8296]: unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the configuration file: lo
Dec 09 23:37:01 node1 systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Dec 09 23:37:01 node1 systemd[1]: Failed to start Docker Application Container Engine.

如何解决该问题?我缺少寻找什么吗?
json文件如下
    [root@k8s-master01 kubespray]# cat /etc/docker/daemon.json
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2",
  "storage-opts": [
    "overlay2.override_kernel_check=true"
  ]
}

docker.yml文件如下:
     cat inventory/sample/group_vars/all/docker.yml
---
## Uncomment this if you want to force overlay/overlay2 as docker storage driver
## Please note that overlay2 is only supported on newer kernels
# docker_storage_options: -s overlay2

## Enable docker_container_storage_setup, it will configure devicemapper driver on Centos7 or RedHat7.
docker_container_storage_setup: false

## It must be define a disk path for docker_container_storage_setup_devs.
## Otherwise docker-storage-setup will be executed incorrectly.
# docker_container_storage_setup_devs: /dev/vdb

## Uncomment this if you have more than 3 nameservers, then we'll only use the first 3.
docker_dns_servers_strict: false

# Path used to store Docker data
docker_daemon_graph: "/var/lib/docker"

## Used to set docker daemon iptables options to true
docker_iptables_enabled: "false"

# Docker log options
# Rotate container stderr/stdout logs at 50m and keep last 5
docker_log_opts: "--log-opt max-size=50m --log-opt max-file=5"

# define docker bin_dir
docker_bin_dir: "/usr/bin"

# keep docker packages after installation; speeds up repeated ansible provisioning runs when '1'
# kubespray deletes the docker package on each run, so caching the package makes sense
docker_rpm_keepcache: 0

## An obvious use case is allowing insecure-registry access to self hosted registries.
## Can be ipaddress and domain_name.
## example define 172.19.16.11 or mirror.registry.io
# docker_insecure_registries:
#   - mirror.registry.io
#   - 172.19.16.11

## Add other registry,example China registry mirror.
# docker_registry_mirrors:
#   - https://registry.docker-cn.com
#   - https://mirror.aliyuncs.com

## If non-empty will override default system MountFlags value.
## This option takes a mount propagation flag: shared, slave
## or private, which control whether mounts in the file system
## namespace set up for docker will receive or propagate mounts
## and unmounts. Leave empty for system default
# docker_mount_flags:

## A string of extra options to pass to the docker daemon.
## This string should be exactly as you wish it to appear.
docker_options: >-

setup.cfg文件如下
[root@k8s-master01 kubespray]# cat setup.cfg
[metadata]
name = kubespray
summary = Ansible modules for installing Kubernetes
description-file =
    README.md
author = Kubespray
author-email = smainklh@gmail.com
license = Apache License (2.0)
home-page = https://github.com/kubernetes-sigs/kubespray
classifier =
  License :: OSI Approved :: Apache Software License
  Development Status :: 4 - Beta
  Intended Audience :: Developers
  Intended Audience :: System Administrators
  Intended Audience :: Information Technology
  Topic :: Utilities

[global]
setup-hooks =
    pbr.hooks.setup_hook

[files]
data_files =
    usr/share/kubespray/playbooks/ =
        cluster.yml
        upgrade-cluster.yml
        scale.yml
        reset.yml
        remove-node.yml
        extra_playbooks/upgrade-only-k8s.yml
    usr/share/kubespray/roles = roles/*
    usr/share/kubespray/library = library/*
    usr/share/doc/kubespray/ =
        LICENSE
        README.md
    usr/share/doc/kubespray/inventory/ =
        inventory/sample/inventory.ini
    etc/kubespray/ =
        ansible.cfg
    etc/kubespray/inventory/sample/group_vars/ =
        inventory/sample/group_vars/etcd.yml
    etc/kubespray/inventory/sample/group_vars/all/ =
        inventory/sample/group_vars/all/all.yml
        inventory/sample/group_vars/all/azure.yml
        inventory/sample/group_vars/all/coreos.yml
        inventory/sample/group_vars/all/docker.yml
        inventory/sample/group_vars/all/oci.yml
        inventory/sample/group_vars/all/openstack.yml

[wheel]
universal = 1

[pbr]
skip_authors = True
skip_changelog = True

[bdist_rpm]
group = "System Environment/Libraries"
requires =
    ansible
    python-jinja2
    python-netaddr

最佳答案

看一下您在deamon.json文件存储驱动程序中定义的内容:

  "storage-driver": "overlay2",
  "storage-opts": [
    "overlay2.override_kernel_check=true"

同时在docker.yaml文件中,您未启用存储驱动程序选项:
## Uncomment this if you want to force overlay/overlay2 as docker storage driver
## Please note that overlay2 is only supported on newer kernels
# docker_storage_options: -s overlay2

请取消注释docker_storage_options: -s overlay2行。

确保您已按照tutorial的步骤进行操作。

关于kubernetes - Kubespray Kubernetes安装失败-dockerd [8296]:无法使用文件/etc/docker/daemon.json配置Docker守护程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59260214/

相关文章:

kubernetes - Kubeadm无法在升级时签署证书

docker - 我可以从Kubernetes中另一个节点上运行的另一个容器通过其主机名访问一个容器吗?

node.js - 用于连接到 NATS 事件总线的 Kubernetes 部署配置

kubernetes - Kubernetes | kubespray

kubernetes - 如何在 kubespray 部署中设置 API Server 参数

kubernetes - 印花布:networkPlugin CNI无法设置Pod,I/O超时

docker - POD的回应线索

amazon-web-services - K8s服务类型ELB卡在进行中

logging - 仅激活选定 pod 的 kubernetes 日志

kubernetes - 如何测量 Kubernetes 容器启动时间?