kamal 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kamal/cli/accessory.rb +5 -3
- data/lib/kamal/cli/app.rb +6 -3
- data/lib/kamal/cli/build.rb +13 -10
- data/lib/kamal/cli/healthcheck/poller.rb +2 -2
- data/lib/kamal/cli/main.rb +14 -2
- data/lib/kamal/cli/registry.rb +9 -10
- data/lib/kamal/cli/templates/sample_hooks/docker-setup.sample +1 -1
- data/lib/kamal/cli/traefik.rb +5 -3
- data/lib/kamal/cli.rb +1 -1
- data/lib/kamal/commands/accessory.rb +4 -4
- data/lib/kamal/commands/app/logging.rb +4 -4
- data/lib/kamal/commands/builder/base.rb +13 -0
- data/lib/kamal/commands/builder/multiarch/remote.rb +10 -0
- data/lib/kamal/commands/builder/multiarch.rb +4 -0
- data/lib/kamal/commands/builder/native/cached.rb +10 -1
- data/lib/kamal/commands/builder/native/remote.rb +8 -0
- data/lib/kamal/commands/builder.rb +17 -11
- data/lib/kamal/commands/registry.rb +4 -13
- data/lib/kamal/commands/traefik.rb +8 -47
- data/lib/kamal/configuration/accessory.rb +30 -41
- data/lib/kamal/configuration/boot.rb +9 -4
- data/lib/kamal/configuration/builder.rb +33 -33
- data/lib/kamal/configuration/docs/accessory.yml +90 -0
- data/lib/kamal/configuration/docs/boot.yml +19 -0
- data/lib/kamal/configuration/docs/builder.yml +107 -0
- data/lib/kamal/configuration/docs/configuration.yml +157 -0
- data/lib/kamal/configuration/docs/env.yml +72 -0
- data/lib/kamal/configuration/docs/healthcheck.yml +59 -0
- data/lib/kamal/configuration/docs/logging.yml +21 -0
- data/lib/kamal/configuration/docs/registry.yml +49 -0
- data/lib/kamal/configuration/docs/role.yml +52 -0
- data/lib/kamal/configuration/docs/servers.yml +27 -0
- data/lib/kamal/configuration/docs/ssh.yml +46 -0
- data/lib/kamal/configuration/docs/sshkit.yml +23 -0
- data/lib/kamal/configuration/docs/traefik.yml +62 -0
- data/lib/kamal/configuration/env/tag.rb +1 -1
- data/lib/kamal/configuration/env.rb +10 -14
- data/lib/kamal/configuration/healthcheck.rb +63 -0
- data/lib/kamal/configuration/logging.rb +33 -0
- data/lib/kamal/configuration/registry.rb +31 -0
- data/lib/kamal/configuration/role.rb +53 -65
- data/lib/kamal/configuration/servers.rb +18 -0
- data/lib/kamal/configuration/ssh.rb +11 -8
- data/lib/kamal/configuration/sshkit.rb +9 -7
- data/lib/kamal/configuration/traefik.rb +60 -0
- data/lib/kamal/configuration/validation.rb +27 -0
- data/lib/kamal/configuration/validator/accessory.rb +9 -0
- data/lib/kamal/configuration/validator/builder.rb +9 -0
- data/lib/kamal/configuration/validator/env.rb +54 -0
- data/lib/kamal/configuration/validator/registry.rb +25 -0
- data/lib/kamal/configuration/validator/role.rb +11 -0
- data/lib/kamal/configuration/validator/servers.rb +7 -0
- data/lib/kamal/configuration/validator.rb +140 -0
- data/lib/kamal/configuration.rb +41 -66
- data/lib/kamal/version.rb +1 -1
- data/lib/kamal.rb +2 -0
- metadata +49 -3
@@ -0,0 +1,157 @@
|
|
1
|
+
# Kamal Configuration
|
2
|
+
#
|
3
|
+
# Configuration is read from the `config/deploy.yml`
|
4
|
+
#
|
5
|
+
# When running commands, you can specify a destination with the `-d` flag,
|
6
|
+
# e.g. `kamal deploy -d staging`
|
7
|
+
#
|
8
|
+
# In this case the configuration will also be read from `config/deploy.staging.yml`
|
9
|
+
# and merged with the base configuration.
|
10
|
+
#
|
11
|
+
# The available configuration options are explained below.
|
12
|
+
|
13
|
+
# The service name
|
14
|
+
# This is a required value. It is used as the container name prefix.
|
15
|
+
service: myapp
|
16
|
+
|
17
|
+
# The Docker image name
|
18
|
+
#
|
19
|
+
# The image will be pushed to the configured registry.
|
20
|
+
image: my-image
|
21
|
+
|
22
|
+
# Labels
|
23
|
+
#
|
24
|
+
# Additional labels to add to the container
|
25
|
+
labels:
|
26
|
+
my-label: my-value
|
27
|
+
|
28
|
+
# Additional volumes to mount into the container
|
29
|
+
volumes:
|
30
|
+
- /path/on/host:/path/in/container:ro
|
31
|
+
|
32
|
+
# Registry
|
33
|
+
#
|
34
|
+
# The Docker registry configuration, see kamal docs registry
|
35
|
+
registry:
|
36
|
+
...
|
37
|
+
|
38
|
+
# Servers
|
39
|
+
#
|
40
|
+
# The servers to deploy to, optionally with custom roles, see kamal docs servers
|
41
|
+
servers:
|
42
|
+
...
|
43
|
+
|
44
|
+
# Environment variables
|
45
|
+
#
|
46
|
+
# See kamal docs env
|
47
|
+
env:
|
48
|
+
...
|
49
|
+
|
50
|
+
# Asset Bridging
|
51
|
+
#
|
52
|
+
# Used for asset bridging across deployments, default to `nil`
|
53
|
+
#
|
54
|
+
# If there are changes to CSS or JS files, we may get requests
|
55
|
+
# for the old versions on the new container and vice-versa.
|
56
|
+
#
|
57
|
+
# To avoid 404s we can specify an asset path.
|
58
|
+
# Kamal will replace that path in the container with a mapped
|
59
|
+
# volume containing both sets of files.
|
60
|
+
# This requires that file names change when the contents change
|
61
|
+
# (e.g. by including a hash of the contents in the name).
|
62
|
+
|
63
|
+
# To configure this, set the path to the assets:
|
64
|
+
asset_path: /path/to/assets
|
65
|
+
|
66
|
+
# Path to hooks, defaults to `.kamal/hooks`
|
67
|
+
# See https://kamal-deploy.org/docs/hooks for more information
|
68
|
+
hooks_path: /user_home/kamal/hooks
|
69
|
+
|
70
|
+
# Require destinations
|
71
|
+
#
|
72
|
+
# Whether deployments require a destination to be specified, defaults to `false`
|
73
|
+
require_destination: true
|
74
|
+
|
75
|
+
# The primary role
|
76
|
+
#
|
77
|
+
# This defaults to `web`, but if you have no web role, you can change this
|
78
|
+
primary_role: workers
|
79
|
+
|
80
|
+
# Allowing empty roles
|
81
|
+
#
|
82
|
+
# Whether roles with no servers are allowed. Defaults to `false`.
|
83
|
+
allow_empty_roles: false
|
84
|
+
|
85
|
+
# Stop wait time
|
86
|
+
#
|
87
|
+
# How long we wait for a container to stop before killing it, defaults to 30 seconds
|
88
|
+
stop_wait_time: 60
|
89
|
+
|
90
|
+
# Retain containers
|
91
|
+
#
|
92
|
+
# How many old containers and images we retain, defaults to 5
|
93
|
+
retain_containers: 3
|
94
|
+
|
95
|
+
# Minimum version
|
96
|
+
#
|
97
|
+
# The minimum version of Kamal required to deploy this configuration, defaults to nil
|
98
|
+
minimum_version: 1.3.0
|
99
|
+
|
100
|
+
# Readiness delay
|
101
|
+
#
|
102
|
+
# Seconds to wait for a container to boot after is running, default 7
|
103
|
+
# This only applies to containers that do not specify a healthcheck
|
104
|
+
readiness_delay: 4
|
105
|
+
|
106
|
+
# Run directory
|
107
|
+
#
|
108
|
+
# Directory to store kamal runtime files in on the host, default `.kamal`
|
109
|
+
run_directory: /etc/kamal
|
110
|
+
|
111
|
+
# SSH options
|
112
|
+
#
|
113
|
+
# See kamal docs ssh
|
114
|
+
ssh:
|
115
|
+
...
|
116
|
+
|
117
|
+
# Builder options
|
118
|
+
#
|
119
|
+
# See kamal docs builder
|
120
|
+
builder:
|
121
|
+
...
|
122
|
+
|
123
|
+
# Accessories
|
124
|
+
#
|
125
|
+
# Additionals services to run in Docker, see kamal docs accessory
|
126
|
+
accessories:
|
127
|
+
...
|
128
|
+
|
129
|
+
# Traefik
|
130
|
+
#
|
131
|
+
# The Traefik proxy is used for zero-downtime deployments, see kamal docs traefik
|
132
|
+
traefik:
|
133
|
+
...
|
134
|
+
|
135
|
+
# SSHKit
|
136
|
+
#
|
137
|
+
# See kamal docs sshkit
|
138
|
+
sshkit:
|
139
|
+
...
|
140
|
+
|
141
|
+
# Boot options
|
142
|
+
#
|
143
|
+
# See kamal docs boot
|
144
|
+
boot:
|
145
|
+
...
|
146
|
+
|
147
|
+
# Healthcheck
|
148
|
+
#
|
149
|
+
# Configuring healthcheck commands, intervals and timeouts, see kamal docs healthcheck
|
150
|
+
healthcheck:
|
151
|
+
...
|
152
|
+
|
153
|
+
# Logging
|
154
|
+
#
|
155
|
+
# Docker logging configuration, see kamal docs logging
|
156
|
+
logging:
|
157
|
+
...
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# Environment variables
|
2
|
+
#
|
3
|
+
# Environment variables can be set directory in the Kamal configuration or
|
4
|
+
# for loaded from a .env file, for secrets that should not be checked into Git.
|
5
|
+
|
6
|
+
# Reading environment variables from the configuration
|
7
|
+
#
|
8
|
+
# Environment variables can be set directly in the configuration file.
|
9
|
+
#
|
10
|
+
# These are passed to the docker run command when deploying.
|
11
|
+
env:
|
12
|
+
DATABASE_HOST: mysql-db1
|
13
|
+
DATABASE_PORT: 3306
|
14
|
+
|
15
|
+
# Using .env file to load required environment variables
|
16
|
+
#
|
17
|
+
# Kamal uses dotenv to automatically load environment variables set in the .env file present
|
18
|
+
# in the application root.
|
19
|
+
#
|
20
|
+
# This file can be used to set variables like KAMAL_REGISTRY_PASSWORD or database passwords.
|
21
|
+
# But for this reason you must ensure that .env files are not checked into Git or included
|
22
|
+
# in your Dockerfile! The format is just key-value like:
|
23
|
+
# ```
|
24
|
+
# KAMAL_REGISTRY_PASSWORD=pw
|
25
|
+
# DB_PASSWORD=secret123
|
26
|
+
# ```
|
27
|
+
# See https://kamal-deploy.org/docs/commands/envify/ for how to use generated .env files.
|
28
|
+
#
|
29
|
+
# To pass the secrets you should list them under the `secret` key. When you do this the
|
30
|
+
# other variables need to be moved under the `clear` key.
|
31
|
+
#
|
32
|
+
# Unlike clear valies, secrets are not passed directly to the container,
|
33
|
+
# but are stored in an env file on the host
|
34
|
+
# The file is not updated when deploying, only when running `kamal envify` or `kamal env push`.
|
35
|
+
env:
|
36
|
+
clear:
|
37
|
+
DB_USER: app
|
38
|
+
secret:
|
39
|
+
- DB_PASSWORD
|
40
|
+
|
41
|
+
# Tags
|
42
|
+
#
|
43
|
+
# Tags are used to add extra env variables to specific hosts.
|
44
|
+
# See kamal docs servers for how to tag hosts.
|
45
|
+
#
|
46
|
+
# Tags are only allowed in the top level env configuration (i.e not under a role specific env).
|
47
|
+
#
|
48
|
+
# The env variables can be specified with secret and clear values as explained above.
|
49
|
+
env:
|
50
|
+
tags:
|
51
|
+
<tag1>:
|
52
|
+
MYSQL_USER: monitoring
|
53
|
+
<tag2>:
|
54
|
+
clear:
|
55
|
+
MYSQL_USER: readonly
|
56
|
+
secret:
|
57
|
+
- MYSQL_PASSWORD
|
58
|
+
|
59
|
+
# Example configuration
|
60
|
+
env:
|
61
|
+
clear:
|
62
|
+
MYSQL_USER: app
|
63
|
+
secret:
|
64
|
+
- MYSQL_PASSWORD
|
65
|
+
tags:
|
66
|
+
monitoring:
|
67
|
+
MYSQL_USER: monitoring
|
68
|
+
replica:
|
69
|
+
clear:
|
70
|
+
MYSQL_USER: readonly
|
71
|
+
secret:
|
72
|
+
- READONLY_PASSWORD
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# Healthcheck configuration
|
2
|
+
#
|
3
|
+
# On roles that are running Traefik, Kamal will supply a default healthcheck to `docker run`.
|
4
|
+
# For other roles, by default no healthcheck is supplied.
|
5
|
+
#
|
6
|
+
# If no healthcheck is supplied and the image does not define one, they we wait for the container
|
7
|
+
# to reach a running state and then pause for the readiness delay.
|
8
|
+
#
|
9
|
+
# The default healthcheck is `curl -f http://localhost:<port>/<path>`, so it assumes that `curl`
|
10
|
+
# is available within the container.
|
11
|
+
|
12
|
+
# Healthcheck options
|
13
|
+
#
|
14
|
+
# These go under the `healthcheck` key in the root or role configuration.
|
15
|
+
healthcheck:
|
16
|
+
|
17
|
+
# Command
|
18
|
+
#
|
19
|
+
# The command to run, defaults to `curl -f http://localhost:<port>/<path>` on roles running Traefik
|
20
|
+
cmd: "curl -f http://localhost"
|
21
|
+
|
22
|
+
# Interval
|
23
|
+
#
|
24
|
+
# The Docker healthcheck interval, defaults to `1s`
|
25
|
+
interval: 10s
|
26
|
+
|
27
|
+
# Max attempts
|
28
|
+
#
|
29
|
+
# The maximum number of times we poll the container to see if it is healthy, defaults to `7`
|
30
|
+
# Each check is separated by an increasing interval starting with 1 second.
|
31
|
+
max_attempts: 3
|
32
|
+
|
33
|
+
# Port
|
34
|
+
#
|
35
|
+
# The port to use in the healthcheck, defaults to `3000`
|
36
|
+
port: "80"
|
37
|
+
|
38
|
+
# Path
|
39
|
+
#
|
40
|
+
# The path to use in the healthcheck, defaults to `/up`
|
41
|
+
path: /health
|
42
|
+
|
43
|
+
# Cords for zero-downtime deployments
|
44
|
+
#
|
45
|
+
# The cord file is used for zero-downtime deployments. The healthcheck is augmented with a check
|
46
|
+
# for the existance of the file. This allows us to delete the file and force the container to
|
47
|
+
# become unhealthy, causing Traefik to stop routing traffic to it.
|
48
|
+
#
|
49
|
+
# Kamal mounts a volume at this location and creates the file before starting the container.
|
50
|
+
# You can set the value to `false` to disable the cord file, but this loses the zero-downtime
|
51
|
+
# guarantee.
|
52
|
+
#
|
53
|
+
# The default value is `/tmp/kamal-cord`
|
54
|
+
cord: /cord
|
55
|
+
|
56
|
+
# Log lines
|
57
|
+
#
|
58
|
+
# Number of lines to log from the container when the healthcheck fails, defaults to `50`
|
59
|
+
log_lines: 100
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Custom logging configuration
|
2
|
+
#
|
3
|
+
# Set these to control the Docker logging driver and options.
|
4
|
+
|
5
|
+
# Logging settings
|
6
|
+
#
|
7
|
+
# These go under the logging key in the configuration file.
|
8
|
+
#
|
9
|
+
# This can be specified in the root level or for a specific role.
|
10
|
+
logging:
|
11
|
+
|
12
|
+
# Driver
|
13
|
+
#
|
14
|
+
# The logging driver to use, passed to Docker via `--log-driver`
|
15
|
+
driver: json-file
|
16
|
+
|
17
|
+
# Options
|
18
|
+
#
|
19
|
+
# Any logging options to pass to the driver, passed to Docker via `--log-opt`
|
20
|
+
options:
|
21
|
+
max-size: 100m
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# Registry
|
2
|
+
#
|
3
|
+
# The default registry is Docker Hub, but you can change it using registry/server:
|
4
|
+
#
|
5
|
+
# A reference to secret (in this case DOCKER_REGISTRY_TOKEN) will look up the secret
|
6
|
+
# in the local environment.
|
7
|
+
|
8
|
+
registry:
|
9
|
+
server: registry.digitalocean.com
|
10
|
+
username:
|
11
|
+
- DOCKER_REGISTRY_TOKEN
|
12
|
+
password:
|
13
|
+
- DOCKER_REGISTRY_TOKEN
|
14
|
+
|
15
|
+
# Using AWS ECR as the container registry
|
16
|
+
# You will need to have the aws CLI installed locally for this to work.
|
17
|
+
# AWS ECR’s access token is only valid for 12hrs. In order to not have to manually regenerate the token every time, you can use ERB in the deploy.yml file to shell out to the aws cli command, and obtain the token:
|
18
|
+
|
19
|
+
registry:
|
20
|
+
server: <your aws account id>.dkr.ecr.<your aws region id>.amazonaws.com
|
21
|
+
username: AWS
|
22
|
+
password: <%= %x(aws ecr get-login-password) %>
|
23
|
+
|
24
|
+
# Using GCP Artifact Registry as the container registry
|
25
|
+
# To sign into Artifact Registry, you would need to
|
26
|
+
# [create a service account](https://cloud.google.com/iam/docs/service-accounts-create#creating)
|
27
|
+
# and [set up roles and permissions](https://cloud.google.com/artifact-registry/docs/access-control#permissions).
|
28
|
+
# Normally, assigning a roles/artifactregistry.writer role should be sufficient.
|
29
|
+
#
|
30
|
+
# Once the service account is ready, you need to generate and download a JSON key, base64 encode it and add to .env:
|
31
|
+
#
|
32
|
+
# ```shell
|
33
|
+
# echo "KAMAL_REGISTRY_PASSWORD=$(base64 -i /path/to/key.json)" | tr -d "\\n" >> .env
|
34
|
+
# ```
|
35
|
+
# Use the env variable as password along with _json_key_base64 as username.
|
36
|
+
# Here’s the final configuration:
|
37
|
+
|
38
|
+
registry:
|
39
|
+
server: <your registry region>-docker.pkg.dev
|
40
|
+
username: _json_key_base64
|
41
|
+
password:
|
42
|
+
- KAMAL_REGISTRY_PASSWORD
|
43
|
+
|
44
|
+
# Validating the configuration
|
45
|
+
#
|
46
|
+
# You can validate the configuration by running:
|
47
|
+
# ```shell
|
48
|
+
# kamal registry login
|
49
|
+
# ```
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Roles
|
2
|
+
#
|
3
|
+
# Roles are used to configure different types of servers in the deployment.
|
4
|
+
# The most common use for this is to run a web servers and job servers.
|
5
|
+
#
|
6
|
+
# Kamal expects there to be a `web` role, unless you set a different `primary_role`
|
7
|
+
# in the root configuration.
|
8
|
+
|
9
|
+
# Role configuration
|
10
|
+
#
|
11
|
+
# Roles are specified under the servers key
|
12
|
+
servers:
|
13
|
+
|
14
|
+
# Simple role configuration
|
15
|
+
#
|
16
|
+
#
|
17
|
+
# This can be a list of hosts, if you don't need custom configuration for the role.
|
18
|
+
#
|
19
|
+
# You can set tags on the hosts for custom env variables (see kamal docs env)
|
20
|
+
web:
|
21
|
+
- 172.1.0.1
|
22
|
+
- 172.1.0.2: experiment1
|
23
|
+
- 172.1.0.2: [ experiment1, experiment2 ]
|
24
|
+
|
25
|
+
# Custom role configuration
|
26
|
+
#
|
27
|
+
# When there are other options to set, the list of hosts goes under the `hosts` key
|
28
|
+
#
|
29
|
+
# By default only the primary role uses Traefik, but you can set `traefik` to change
|
30
|
+
# it.
|
31
|
+
#
|
32
|
+
# You can also set a custom cmd to run in the container, and overwrite other settings
|
33
|
+
# from the root configuration.
|
34
|
+
workers:
|
35
|
+
hosts:
|
36
|
+
- 172.1.0.3
|
37
|
+
- 172.1.0.4: experiment1
|
38
|
+
traefik: true
|
39
|
+
cmd: "bin/jobs"
|
40
|
+
options:
|
41
|
+
memory: 2g
|
42
|
+
cpus: 4
|
43
|
+
healthcheck:
|
44
|
+
...
|
45
|
+
logging:
|
46
|
+
...
|
47
|
+
labels:
|
48
|
+
my-label: workers
|
49
|
+
env:
|
50
|
+
...
|
51
|
+
asset_path: /public
|
52
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Servers
|
2
|
+
#
|
3
|
+
# Servers are split into different roles, with each role having its own configuration.
|
4
|
+
#
|
5
|
+
# For simpler deployments though where all servers are identical, you can just specify a list of servers
|
6
|
+
# They will be implicitly assigned to the `web` role.
|
7
|
+
servers:
|
8
|
+
- 172.0.0.1
|
9
|
+
- 172.0.0.2
|
10
|
+
- 172.0.0.3
|
11
|
+
|
12
|
+
# Tagging servers
|
13
|
+
#
|
14
|
+
# Servers can be tagged, with the tags used to add custom env variables (see kamal docs env).
|
15
|
+
servers:
|
16
|
+
- 172.0.0.1
|
17
|
+
- 172.0.0.2: experiments
|
18
|
+
- 172.0.0.3: [ experiments, three ]
|
19
|
+
|
20
|
+
# Roles
|
21
|
+
#
|
22
|
+
# For more complex deployments (e.g. if you are running job hosts), you can specify roles, and configure each separately (see kamal docs role)
|
23
|
+
servers:
|
24
|
+
web:
|
25
|
+
...
|
26
|
+
workers:
|
27
|
+
...
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# SSH configuration
|
2
|
+
#
|
3
|
+
# Kamal uses SSH to connect run commands on your hosts.
|
4
|
+
# By default it will attempt to connect to the root user on port 22
|
5
|
+
#
|
6
|
+
# If you are using non-root user, you may need to bootstrap your servers manually, before using them with Kamal. On Ubuntu, you’d do:
|
7
|
+
#
|
8
|
+
# ```shell
|
9
|
+
# sudo apt update
|
10
|
+
# sudo apt upgrade -y
|
11
|
+
# sudo apt install -y docker.io curl git
|
12
|
+
# sudo usermod -a -G docker app
|
13
|
+
# ```
|
14
|
+
|
15
|
+
|
16
|
+
# SSH options
|
17
|
+
#
|
18
|
+
# The options are specified under the ssh key in the configuration file.
|
19
|
+
ssh:
|
20
|
+
|
21
|
+
# The SSH user
|
22
|
+
#
|
23
|
+
# Defaults to `root`
|
24
|
+
#
|
25
|
+
user: app
|
26
|
+
|
27
|
+
# The SSH port
|
28
|
+
#
|
29
|
+
# Defaults to 22
|
30
|
+
port: "2222"
|
31
|
+
|
32
|
+
# Proxy host
|
33
|
+
#
|
34
|
+
# Specified in the form <host> or <user>@<host>
|
35
|
+
proxy: root@proxy-host
|
36
|
+
|
37
|
+
# Proxy command
|
38
|
+
#
|
39
|
+
# A custom proxy command, required for older versions of SSH
|
40
|
+
proxy_command: "ssh -W %h:%p user@proxy"
|
41
|
+
|
42
|
+
# Log level
|
43
|
+
#
|
44
|
+
# Defaults to `fatal`. Set this to debug if you are having
|
45
|
+
# SSH connection issues.
|
46
|
+
log_level: debug
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# SSHKit
|
2
|
+
#
|
3
|
+
# [SSHKit](https://github.com/capistrano/sshkit) is the SSH toolkit used by Kamal.
|
4
|
+
#
|
5
|
+
# The default settings should be sufficient for most use cases, but
|
6
|
+
# when connecting to a large number of hosts you may need to adjust
|
7
|
+
|
8
|
+
# SSHKit options
|
9
|
+
#
|
10
|
+
# The options are specified under the sshkit key in the configuration file.
|
11
|
+
sshkit:
|
12
|
+
|
13
|
+
# Max concurrent starts
|
14
|
+
#
|
15
|
+
# Creating SSH connections concurrently can be an issue when deploying to many servers.
|
16
|
+
# By default Kamal will limit concurrent connection starts to 30 at a time.
|
17
|
+
max_concurrent_starts: 10
|
18
|
+
|
19
|
+
# Pool idle timeout
|
20
|
+
#
|
21
|
+
# Kamal sets a long idle timeout of 900 seconds on connections to try to avoid
|
22
|
+
# re-connection storms after an idle period, like building an image or waiting for CI.
|
23
|
+
pool_idle_timeout: 300
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# Traefik
|
2
|
+
#
|
3
|
+
# Traefik is a reverse proxy, used by Kamal for zero-downtime deployments.
|
4
|
+
#
|
5
|
+
# We start an instance on the hosts in it's own container.
|
6
|
+
#
|
7
|
+
# During a deployment:
|
8
|
+
# 1. We start a new container which Traefik automatically detects due to the labels we have applied
|
9
|
+
# 2. Traefik starts routing traffic to the new container
|
10
|
+
# 3. We force the old container to fail it's healthcheck, causing Traefik to stop routing traffic to it
|
11
|
+
# 4. We stop the old container
|
12
|
+
|
13
|
+
# Traefik settings
|
14
|
+
#
|
15
|
+
# Traekik is configured in the root configuration under `traefik`.
|
16
|
+
traefik:
|
17
|
+
|
18
|
+
# Image
|
19
|
+
#
|
20
|
+
# The Traefik image to use, defaults to `traefik:v2.10`
|
21
|
+
image: traefik:v2.9
|
22
|
+
|
23
|
+
# Host port
|
24
|
+
#
|
25
|
+
# The host port to publish the Traefik container on, defaults to `80`
|
26
|
+
host_port: "8080"
|
27
|
+
|
28
|
+
# Disabling publishing
|
29
|
+
#
|
30
|
+
# To avoid publishing the Traefik container, set this to `false`
|
31
|
+
publish: false
|
32
|
+
|
33
|
+
# Labels
|
34
|
+
#
|
35
|
+
# Additional labels to apply to the Traefik container
|
36
|
+
labels:
|
37
|
+
traefik.http.routers.catchall.entryPoints: http
|
38
|
+
traefik.http.routers.catchall.rule: PathPrefix(`/`)
|
39
|
+
traefik.http.routers.catchall.service: unavailable
|
40
|
+
traefik.http.routers.catchall.priority: "1"
|
41
|
+
traefik.http.services.unavailable.loadbalancer.server.port: "0"
|
42
|
+
|
43
|
+
# Arguments
|
44
|
+
#
|
45
|
+
# Additional arguments to pass to the Traefik container
|
46
|
+
args:
|
47
|
+
entryPoints.http.address: ":80"
|
48
|
+
entryPoints.http.forwardedHeaders.insecure: true
|
49
|
+
accesslog: true
|
50
|
+
accesslog.format: json
|
51
|
+
|
52
|
+
# Options
|
53
|
+
#
|
54
|
+
# Additional options to pass to `docker run`
|
55
|
+
options:
|
56
|
+
cpus: 2
|
57
|
+
|
58
|
+
# Environment variables
|
59
|
+
#
|
60
|
+
# See kamal docs env
|
61
|
+
env:
|
62
|
+
...
|
@@ -1,18 +1,15 @@
|
|
1
1
|
class Kamal::Configuration::Env
|
2
|
-
|
3
|
-
delegate :argumentize, to: Kamal::Utils
|
4
|
-
|
5
|
-
def self.from_config(config:, secrets_file: nil)
|
6
|
-
secrets_keys = config.fetch("secret", [])
|
7
|
-
clear = config.fetch("clear", config.key?("secret") || config.key?("tags") ? {} : config)
|
2
|
+
include Kamal::Configuration::Validation
|
8
3
|
|
9
|
-
|
10
|
-
|
4
|
+
attr_reader :secrets_keys, :clear, :secrets_file, :context
|
5
|
+
delegate :argumentize, to: Kamal::Utils
|
11
6
|
|
12
|
-
def initialize(
|
13
|
-
@clear = clear
|
14
|
-
@secrets_keys =
|
7
|
+
def initialize(config:, secrets_file: nil, context: "env")
|
8
|
+
@clear = config.fetch("clear", config.key?("secret") || config.key?("tags") ? {} : config)
|
9
|
+
@secrets_keys = config.fetch("secret", [])
|
15
10
|
@secrets_file = secrets_file
|
11
|
+
@context = context
|
12
|
+
validate! config, context: context, with: Kamal::Configuration::Validator::Env
|
16
13
|
end
|
17
14
|
|
18
15
|
def args
|
@@ -33,8 +30,7 @@ class Kamal::Configuration::Env
|
|
33
30
|
|
34
31
|
def merge(other)
|
35
32
|
self.class.new \
|
36
|
-
|
37
|
-
|
38
|
-
secrets_file: secrets_file
|
33
|
+
config: { "clear" => clear.merge(other.clear), "secret" => secrets_keys | other.secrets_keys },
|
34
|
+
secrets_file: secrets_file || other.secrets_file
|
39
35
|
end
|
40
36
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
class Kamal::Configuration::Healthcheck
|
2
|
+
include Kamal::Configuration::Validation
|
3
|
+
|
4
|
+
attr_reader :healthcheck_config
|
5
|
+
|
6
|
+
def initialize(healthcheck_config:, context: "healthcheck")
|
7
|
+
@healthcheck_config = healthcheck_config || {}
|
8
|
+
validate! @healthcheck_config, context: context
|
9
|
+
end
|
10
|
+
|
11
|
+
def merge(other)
|
12
|
+
self.class.new healthcheck_config: healthcheck_config.deep_merge(other.healthcheck_config)
|
13
|
+
end
|
14
|
+
|
15
|
+
def cmd
|
16
|
+
healthcheck_config.fetch("cmd", http_health_check)
|
17
|
+
end
|
18
|
+
|
19
|
+
def port
|
20
|
+
healthcheck_config.fetch("port", 3000)
|
21
|
+
end
|
22
|
+
|
23
|
+
def path
|
24
|
+
healthcheck_config.fetch("path", "/up")
|
25
|
+
end
|
26
|
+
|
27
|
+
def max_attempts
|
28
|
+
healthcheck_config.fetch("max_attempts", 7)
|
29
|
+
end
|
30
|
+
|
31
|
+
def interval
|
32
|
+
healthcheck_config.fetch("interval", "1s")
|
33
|
+
end
|
34
|
+
|
35
|
+
def cord
|
36
|
+
healthcheck_config.fetch("cord", "/tmp/kamal-cord")
|
37
|
+
end
|
38
|
+
|
39
|
+
def log_lines
|
40
|
+
healthcheck_config.fetch("log_lines", 50)
|
41
|
+
end
|
42
|
+
|
43
|
+
def set_port_or_path?
|
44
|
+
healthcheck_config["port"].present? || healthcheck_config["path"].present?
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_h
|
48
|
+
{
|
49
|
+
"cmd" => cmd,
|
50
|
+
"interval" => interval,
|
51
|
+
"max_attempts" => max_attempts,
|
52
|
+
"port" => port,
|
53
|
+
"path" => path,
|
54
|
+
"cord" => cord,
|
55
|
+
"log_lines" => log_lines
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
def http_health_check
|
61
|
+
"curl -f #{URI.join("http://localhost:#{port}", path)} || exit 1" if path.present? || port.present?
|
62
|
+
end
|
63
|
+
end
|