Skip to content

Commit 737e15d

Browse files
committed
write up running a worker node with systemd
Signed-off-by: Taylor Silva <[email protected]>
1 parent 1f0f9ab commit 737e15d

File tree

2 files changed

+112
-13
lines changed

2 files changed

+112
-13
lines changed

lit/docs/install/systemd.lit

+110-11
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This guide makes the following assumptions:
1414
You have generated the necessary
1515
\reference{generating-keys}{encryption Keys}.
1616
}{
17-
The web node will be directly exposed to the internet and can therefore
17+
The Web node will be directly exposed to the internet and can therefore
1818
accept inbound traffic on port 443.
1919
}{
2020
The Web and Worker node are being installed on separate servers and you
@@ -27,8 +27,8 @@ This guide makes the following assumptions:
2727
install the CLI in \code{/use/local/concourse}, but you can choose a
2828
different install location.
2929

30-
Run the following commands to install the Concourse CLI on both your
31-
Web and Worker servers:
30+
Run the following commands to install the Concourse CLI. \bold{You need to do
31+
this on both your Web and Worker servers.}
3232
\codeblock{bash}{{{
3333
CONCOURSE_VERSION="<select-a-concourse-version>"
3434
CONCOURSE_TAR="concourse.tgz"
@@ -45,12 +45,12 @@ This guide makes the following assumptions:
4545
PATH="$PATH:/usr/local/concourse/bin"
4646
}}}
4747

48-
You can move on to setting up the Web node.
48+
You can move on to setting up the Web and Worker servers.
4949
}
5050

5151
\section{
5252
\title{Web Node}{systemd-web}
53-
First lets create a new user and group for the web node to run as:
53+
First lets create a new user and group for the Web node to run as:
5454

5555
\codeblock{bash}{{{
5656
addgroup --system "concourse"
@@ -75,10 +75,19 @@ This guide makes the following assumptions:
7575
}
7676

7777
Next create a file named \code{web.env} in \code{/usr/local/concourse/} that
78-
will be used to configure the web node. This is where you can \reference{configuring-auth}{configure
78+
will be used to configure the Web node. This is where you can \reference{configuring-auth}{configure
7979
authentication} to Concourse and all other settings found when you run
8080
\code{concourse web --help}.
8181

82+
Change the following values:
83+
\list{
84+
\code{CONCOURSE_POSTGRES_*} - Used to tell Concourse how to connect to PostgreSQL
85+
}{
86+
\code{CONCOURSE_EXTERNAL_URL} - The URL users will use to access the web
87+
UI. A Let's Encrypt certificate will also be generated for the hostname in
88+
this URL.
89+
}
90+
8291
\codeblock{}{{{
8392
PATH=/usr/local/concourse/bin
8493
CONCOURSE_EXTERNAL_URL=https://ci.example.com
@@ -96,9 +105,7 @@ This guide makes the following assumptions:
96105
CONCOURSE_ADD_LOCAL_USER=local:local
97106
}}}
98107

99-
Set the file permissions to read-only and restricted to the \code{concourse}
100-
user and group:
101-
108+
Set the file permissions to read-only:
102109
\codeblock{bash}{{{
103110
chmod 0444 web.env
104111
}}}
@@ -116,7 +123,7 @@ This guide makes the following assumptions:
116123

117124
\codeblock{}{{{
118125
[Unit]
119-
Description=Concourse web node
126+
Description=Concourse Web node
120127
[Service]
121128
User=concourse
122129
Group=concourse
@@ -130,7 +137,7 @@ This guide makes the following assumptions:
130137
WantedBy=default.target
131138
}}}
132139

133-
Finally enable and start the web service:
140+
Finally enable and start the Web service:
134141
\codeblock{bash}{{{
135142
systemctl daemon-reload
136143
systemctl enable concourse-web
@@ -151,5 +158,97 @@ This guide makes the following assumptions:
151158

152159
\section{
153160
\title{Worker Node}{systemd-worker}
161+
The Worker has to run as root so there is no user to create. We can go
162+
straight to configuring the Worker.
163+
164+
Ensure the following keys (previously generated) are located in
165+
\code{/usr/local/concourse/keys/}:
166+
\list{
167+
\code{tsa_host_key.pub}
168+
}{
169+
\code{worker_key}
170+
}
171+
172+
Create the directory \code{/opt/concourse} where the worker will place
173+
runtime artifacts. Files in this directory are temporary and are managed by
174+
the worker.
175+
176+
Next create a file named \code{worker.env} in \code{/usr/local/concourse/}
177+
that will be used to configure the Worker. To see all possible configuration
178+
options run \code{concourse worker --help} and read more about
179+
\reference{worker-node}{running a worker node}.
180+
181+
Change the following values:
182+
\list{
183+
\code{CONCOURSE_TSA_HOST} - This should be set to a hostname or IP that the
184+
worker can use to reach the Web node, including the TSA port, which defaults
185+
to port 2222.
186+
}
187+
188+
\codeblock{}{{{
189+
PATH=/usr/local/concourse/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
190+
CONCOURSE_NAME=worker-01
191+
CONCOURSE_WORK_DIR=/opt/concourse/worker
192+
CONCOURSE_TSA_HOST="<web-hostname-or-ip>:2222"
193+
CONCOURSE_TSA_PUBLIC_KEY=/usr/local/concourse/keys/tsa_host_key.pub
194+
CONCOURSE_TSA_WORKER_PRIVATE_KEY=/usr/local/concourse/keys/worker_key
195+
CONCOURSE_RUNTIME=containerd
196+
CONCOURSE_BAGGAGECLAIM_DRIVER=overlay
197+
}}}
198+
199+
\aside{
200+
If you're having issues with DNS resolution please read
201+
\reference{worker-troubleshoot-dns}{this section}.
202+
}
203+
204+
The \code{CONCOURSE_NAME} must be unique per worker. Having two workers with
205+
the same name will result in a lot of weirdness.
206+
207+
Set the file permissions to read-only:
208+
\codeblock{bash}{{{
209+
chmod 0444 worker.env
210+
}}}
211+
212+
We can now created a new Systemd Unit file at
213+
\code{/etc/systemd/system/} named \code{concourse-worker.service}. Place
214+
the following configuration in the unit file:
215+
216+
\codeblock{}{{{
217+
[Unit]
218+
Description=Concourse Worker
219+
[Service]
220+
User=root
221+
Group=root
222+
EnvironmentFile=/usr/local/concourse/worker.env
223+
ExecStart=/usr/local/concourse/bin/concourse worker
224+
Restart=on-failure
225+
RestartSec=3
226+
KillSignal=SIGUSR2
227+
SendSIGKILL=yes
228+
TimeoutStopSec=300
229+
[Install]
230+
WantedBy=default.target
231+
}}}
232+
233+
Finally enable and start the Worker service:
234+
\codeblock{bash}{{{
235+
systemctl daemon-reload
236+
systemctl enable concourse-worker
237+
systemctl start concourse-worker
238+
}}}
239+
240+
Check the status of the service:
241+
\codeblock{bash}{{{
242+
systemctl status concourse-worker
243+
}}}
244+
245+
If the service isn't staying up, check the logs:
246+
\codeblock{bash}{{{
247+
journalctl -u concourse-worker
248+
}}}
249+
250+
Using the \reference{fly} you should be able to see the worker successfully
251+
connected to the Web node by running \code{fly workers}.
154252

253+
Congratulations, you've successfully deployed a Concourse cluster!
155254
}

lit/docs/install/worker.lit

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ decide much on its own.
99
\table-of-contents
1010

1111
\section{
12-
\title{Prerequisites}{worker-prerequisites}
12+
\title{prerequisites}{worker-prerequisites}
1313

1414
\list{
1515
Linux: We test and support the following distributions. Minimum kernel
@@ -653,7 +653,7 @@ decide much on its own.
653653
}
654654

655655
\section{
656-
\title{Troubleshooting and fixing DNS resolution}
656+
\title{Troubleshooting and fixing DNS resolution}{worker-troubleshoot-dns}
657657

658658
\aside{
659659
\bold{Note}: The Guardian runtime took care of a lot of container

0 commit comments

Comments
 (0)