播种自定义容器

本节涵盖在播种主机上运行的用户自定义容器部署功能的配置。

配置

例如,要部署一个 squid 容器镜像

seed.yml
seed_containers:
  squid:
    image: "docker.io/stackhpc/squid"
    pre: "{{ kayobe_env_config_path }}/containers/squid/pre.yml"
    post: "{{ kayobe_env_config_path }}/containers/squid/post.yml"
    pre_destroy: "{{ kayobe_env_config_path }}/containers/squid/pre_destroy.yml"
    post_destroy: "{{ kayobe_env_config_path }}/containers/squid/post_destroy.yml"
    tag: "3.5.20-1"

请注意可选的 pre、post、pre_destroy 和 post_destroy Ansible 任务文件 - 这些需要在 kayobe-config 路径下创建。下表描述了它们运行的时间

容器钩子

钩子

触发点

pre

容器部署之前

post

容器部署之后

pre_destroy

容器销毁之前

post_destroy

容器销毁之后

容器部署的可能选项

seed_containers:
  containerA:
    capabilities:
    command:
    comparisons:
    detach:
    env:
    network_mode:
    image:
    init:
    ipc_mode:
    pid_mode:
    ports:
    privileged:
    restart_policy:
    shm_size:
    sysctls:
    tag:
    ulimits:
    user:
    volumes:

有关每个选项的详细说明 - 请参阅 Ansible docker_container 模块页面。

Kayobe 应用到必需 docker_container 变量的默认列表

---
# Action to perform: One of: "deploy", "destroy".
manage_containers_action: "deploy"

deploy_containers_defaults:
  comparisons:
    image: strict
    env: strict
    volumes: strict
  detach: True
  network_mode: "host"
  init: True
  privileged: False
  restart_policy: "unless-stopped"

deploy_containers_docker_api_timeout: 120

deploy_containers_registry_attempt_login: "{{ kolla_docker_registry_username is truthy and kolla_docker_registry_password is truthy }}"

Docker 注册表

由于 Docker 注册表部署步骤先于自定义容器部署步骤,因此可以从播种上部署的 Docker 注册表拉取播种容器。

也可以将自定义容器化的 Docker 注册表作为自定义播种容器部署。在这种情况下,可以通过设置禁用基本的身份验证登录尝试

seed.yml
seed_deploy_containers_registry_attempt_login: false

如果没有此设置,登录将失败,因为注册表尚未部署。

有关部署 Docker 注册表的更多信息,请参见 此处