Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将Kong部署到docker swarm?_Docker_Docker Compose_Database Migration_Docker Swarm_Kong - Fatal编程技术网

如何将Kong部署到docker swarm?

如何将Kong部署到docker swarm?,docker,docker-compose,database-migration,docker-swarm,kong,Docker,Docker Compose,Database Migration,Docker Swarm,Kong,按照以下步骤编写堆栈部署文件: stack.yml version: "3" services: kong-database: image: cassandra:3 ports: - "9042:9042" networks: - kong-net kong-migration: image: kong:latest depends_on: - kong-database environment:

按照以下步骤编写堆栈部署文件:

stack.yml

version: "3"
services:
  kong-database:
    image: cassandra:3
    ports:
      - "9042:9042"
    networks:
      - kong-net

  kong-migration:
    image: kong:latest
    depends_on:
      - kong-database
    environment:
      - KONG_DATABASE=cassandra
      - KONG_CASSANDRA_CONTACT_POINTS=kong-database
    command: kong migrations up
    networks:
      - kong-net

  kong:
    image: kong:latest
    depends_on:
      - kong-database
      - kong-migration
    deploy:
      replicas: 3
    environment:
      - KONG_DATABASE=cassandra
      - KONG_CASSANDRA_CONTACT_POINTS=kong-database
      - KONG_PROXY_ACCESS_LOG=/dev/stdout
      - KONG_ADMIN_ACCESS_LOG=/dev/stdout
      - KONG_PROXY_ERROR_LOG=/dev/stderr
      - KONG_ADMIN_ERROR_LOG=/dev/stderr
      - KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl
    ports:
      - "8000:8000"
      - "8443:8443"
      - "8001:8001"
      - "8444:8444"
    networks:
      - kong-net

networks:
  kong-net:
部署:

$ docker stack deploy -c stack.yml gateway
检查服务:

$ docker service ls
ID                  NAME                      MODE                REPLICAS            IMAGE                                             PORTS
xg3qld08ziio        gateway_kong              replicated          1/3                 kong:latest                                       *:8000-8001->8000-8001/tcp, *:8443-8444->8443-8444/tcp
kam7fw265ons        gateway_kong-database     replicated          1/1                 cassandra:3                                       *:9042->9042/tcp
kr0vqoc66izn        gateway_kong-migration    replicated          0/1                 kong:latest
检查
gateway\u kong
log:

gateway_kong.2.zn0tfalwxylx@ip-1-2-3-4    |        [C]: in function 'error'
gateway_kong.2.zxuwxm5xbroe@ip-1-2-3-4    |        init_by_lua:3: in main chunk
gateway_kong.2.zxuwxm5xbroe@ip-1-2-3-4    | nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:172: [cassandra error] the current database schema does not match this version of Kong. Please run `kong migrations up` to update/initialize the database schema. Be aware that Kong migrations should only run from a single node, and that nodes running migrations concurrently will conflict with each other and might corrupt your database schema!
gateway_kong.1.zr8biqoaccfz@ip-1-2-3-4    |        init_by_lua:3: in main chunk
gateway_kong.1.zy0u3ul9gp0l@ip-1-2-3-4    |        init_by_lua:3: in main chunk
gateway_kong.2.zn0tfalwxylx@ip-1-2-3-4    |        /usr/local/share/lua/5.1/kong/init.lua:169: in function 'init'
gateway_kong.1.zy0u3ul9gp0l@ip-1-2-3-4    | nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:172: [cassandra error] the current database schema does not match this version of Kong. Please run `kong migrations up` to update/initialize the database schema. Be aware that Kong migrations should only run from a single node, and that nodes running migrations concurrently will conflict with each other and might corrupt your database schema!
gateway_kong.2.zxuwxm5xbroe@ip-1-2-3-4    | stack traceback:
gateway_kong.2.zxuwxm5xbroe@ip-1-2-3-4    |        [C]: in function 'assert'
gateway_kong.2.zn0tfalwxylx@ip-1-2-3-4    |        init_by_lua:3: in main chunk
gateway_kong.1.zy0u3ul9gp0l@ip-1-2-3-4    | stack traceback:
gateway_kong.1.zy0u3ul9gp0l@ip-1-2-3-4    |        [C]: in function 'assert'
gateway_kong.2.zxuwxm5xbroe@ip-1-2-3-4    |        /usr/local/share/lua/5.1/kong/init.lua:172: in function 'init'
gateway_kong.2.zxuwxm5xbroe@ip-1-2-3-4    |        init_by_lua:3: in main chunk
gateway_kong.1.zy0u3ul9gp0l@ip-1-2-3-4    |        /usr/local/share/lua/5.1/kong/init.lua:172: in function 'init'
gateway_kong.1.zy0u3ul9gp0l@ip-1-2-3-4    |        init_by_lua:3: in main chunk
gateway_kong.3.zq9rrsn2pd2r@ip-1-2-3-5    |       /usr/local/share/lua/5.1/kong/init.lua:172: in function 'init'
gateway_kong.3.zq9rrsn2pd2r@ip-1-2-3-5    |       init_by_lua:3: in main chunk

已经定义了
kong迁移
并设置了命令
kong迁移
。即使set dependens
dependens\u on
,为什么不能进行迁移?

因为这里没有答案,所以我将留下我最近学到的一些东西,即使它们与香港无关。这个问题似乎更多地与集装箱启动订单有关,而不是与香港本身有关

我尝试将Traefik部署到Swarm,配置存储在Consor中。 情况是:

  • 我必须首先部署我的存储后端:
    concur
  • 然后部署一个traefik实例,该实例将把配置上传到consur:
    traefik\u init
  • 最后,我可以使用concur后端部署所有traefik实例:
    traefik
我无法在同一堆栈中部署
concur
traefik_init
traefik
。 因为我一直在使用Ansible,所以我创建了一个剧本,做了以下工作

  • 部署
    concur
    stack
  • 等待同步所有领事节点
  • 启动
    traefik_init
    作为只有一个副本的服务
  • 等待配置存储在领事中
  • 部署
    traefik
    stack
如果我选择覆盖容器的
ENTRYPOINT
CMD
来使用一个脚本,等待所需的服务启动,然后在启动时执行命令,那么我可以在同一个堆栈中部署所有服务

如果我没有使用Ansible,我肯定会这样做

例如,您可以查看(用于测试和等待TCP主机和端口可用性的纯bash脚本)或(用于等待另一个服务可用的脚本)


你也可以在

上找到一个例子,你对教程做了哪些修改?@ShiheZhang添加了取决于。我想就这些了。@vv我知道我来晚了,但在YAML Dependes的第3版中,它被弃用了,而且根据docker文档,它不向后兼容。依赖于功能,可以使用docker文档中提到的shell脚本来实现。你能解决这个问题吗?