После официального руководства для написания файла развертывания стека:
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_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-migration
и задана команда kong migrations up
.Даже набор зависит от depends_on
, почему нельзя выполнить миграцию?