在 Docker Swarm 方式下作为服务运行连接器代理程序以实现高可用性
使用 Docker 的Swarm模式,在多台机器上运行最多3个容器的集群,以确保 Satellite 连接器代理的高可用性。
要配置 Satellite 连接器,您必须在 Satellite 服务拥有管理员权限。
- Satellite 连接器将所有连接到该连接器的代理视为平等。
- TCP 会话会以轮询方式分配给所有代理。
- 根据 IBM Connector 指南,为确保冗余,应至少使用 3 个代理。 这使得 Satellite 连接器服务更加可靠,且增加代理不会产生额外费用。 在 Windows 系统上,这意味着需要使用多个 Windows 主机。
- 如果您正在使用容器,请确保这些容器并非全部位于同一台 VM 或硬件上,因为这种配置不具备冗余性。
- 对于高带宽工作负载,IBM 建议至少部署 6 个代理,因为这样可以覆盖更多主机并提供更大的带宽。
- Satellite 每个连接器最多支持 9 个代理,但 IBM 不建议采用此配置,因为容器和虚拟机具有短暂性,且在发现某个容器消失并有新容器尝试连接时,可能会出现延迟。 相反,应预留至少 3 个空闲插槽,以便容器和虚拟机能够停止和启动。
-
在您的 Swarm 管理器系统上创建一个名为
connector-agent.yaml的 Satellite 连接器代理配置文件,并将以下内容复制到该文件中。 如果有多个环境,则需要创建多个配置文件,并按环境命名。 例如,为生产创建connector-agent-prod.yaml,为暂存创建connector-agent-staging.yaml。 然后,在相应文件中加入要用于每个环境的连接器 ID。version: '3.9' services: agent: image: icr.io/ibm/satellite-connector/satellite-connector-agent:latest environment: - SATELLITE_CONNECTOR_ID=/satellite-connector-id - SATELLITE_CONNECTOR_IAM_APIKEY=/run/secrets/satellite-connector-iam-apikey - SATELLITE_CONNECTOR_TAGS={{.Node.Hostname}} # You also can add other details in this field. For example, SATELLITE_CONNECTOR_TAGS="Some text" deploy: replicas: 3 restart_policy: condition: any update_config: parallelism: 2 delay: 20s failure_action: rollback order: start-first resources: limits: cpus: '0.40' memory: 500M reservations: cpus: '0.04' memory: 200M configs: - source: satellite-connector-id uid: '1000' gid: '1000' mode: 0400 - source: satellite-connector-region uid: '1000' gid: '1000' mode: 0400 secrets: - source: satellite-connector-iam-apikey uid: '1000' gid: '1000' mode: 0400 logging: driver: "json-file" options: max-size: ${JSON_FILE_MAX_SIZE:-1m} max-file: ${JSON_FILE_MAX_FILE:-10} configs: satellite-connector-id: external: true satellite-connector-region: external: true secrets: satellite-connector-iam-apikey: external: true networks: default: external: true name: bridge -
使用 Satellite 连接器标识创建 Docker 配置。
printf <satellite connector id value> | docker config create satellite-connector-id - -
使用 Satellite 连接器区域创建 Docker 配置。
printf <satellite connector region value> | docker config create satellite-connector-region - -
使用 IAM API 密钥创建 Docker 私钥。
printf <Your IAM API key> | docker secret create satellite-connector-iam-apikey -
缺省情况下,Swarm 组合文件将 SATELLITE_CONNECTOR_TAGS 环境变量设置为 Swarm 节点的主机名。 您可以调整此值以满足组合文件中的需求。 此外,缺省情况下,副本数设置为 3。 您可以将此数目调整为更低,但仅支持最多 3 个副本。
- 部署 Satellite 连接器代理程序服务。
- 确保您已使用
ibmcloud cr loginCLI 或 API 密钥docker login -u iamapikey -p <your apikey> icr.io登录到 IBM Cloud® Container Registry。 - 部署堆栈。
docker stack deploy --compose-file satellite-connector-agent.yaml --with-registry-auth satellite_connector
- 确保您已使用
- 验证 Satellite 连接器代理程序服务是否正在运行。
docker service ps satellite_connector_agent