Skip to content

Commit 95f30ca

Browse files
committed
Add Kubernetes and systemd integration examples.
1 parent 43686c5 commit 95f30ca

File tree

1 file changed

+65
-1
lines changed

1 file changed

+65
-1
lines changed

guides/deployment/readme.md

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Deployment
22

3-
This guide explains how to use Falcon in production environments.
3+
This guide explains how to deploy applications using the Falcon web server. It covers the recommended deployment methods, configuration options, and examples for different environments, including systemd and kubernetes.
44

55
Falcon can be deployed into production either as a standalone application server, or as a virtual host routing to multiple applications. Both configurations can run behind a load balancer, but `falcon virtual` is designed to be zero-configuration deployment option.
66

@@ -145,6 +145,50 @@ service hostname do
145145
require_relative "config/environment"
146146
~~~
147147

148+
### Kubernetes Integration
149+
150+
Falcon can be deployed in a Kubernetes cluster using the `falcon host` command. You can use the following example to create a Kubernetes deployment for Falcon:
151+
152+
```yaml
153+
apiVersion: apps/v1
154+
kind: Deployment
155+
metadata:
156+
name: falcon
157+
spec:
158+
replicas: 1
159+
selector:
160+
matchLabels:
161+
app: falcon
162+
template:
163+
metadata:
164+
labels:
165+
app: falcon
166+
spec:
167+
containers:
168+
- name: my-app
169+
image: my-app-image:latest
170+
env:
171+
- name: NOTIFY_LOG
172+
value: "/tmp/notify.log"
173+
ports:
174+
- containerPort: 9292
175+
readinessProbe:
176+
exec:
177+
command: ["bundle", "exec", "bake", "async:container:notify:log:ready?"]
178+
initialDelaySeconds: 5
179+
periodSeconds: 5
180+
failureThreshold: 12
181+
182+
# Assuming you are running Rails and have bound to port 3000:
183+
livenessProbe:
184+
httpGet:
185+
path: /up
186+
port: 3000
187+
initialDelaySeconds: 10
188+
periodSeconds: 10
189+
failureThreshold: 3
190+
```
191+
148192
## Falcon Virtual
149193
150194
Falcon virtual provides a virtual host proxy and HTTP-to-HTTPS redirection for multiple applications. It is designed to be a zero-configuration deployment option, allowing you to run multiple applications on the same server.
@@ -164,3 +208,23 @@ falcon virtual /srv/http/*/falcon.rb
164208
By default, it binds to both HTTP and HTTPS ports, and automatically redirects HTTP requests to HTTPS. It also supports TLS SNI for resolving the certificates.
165209

166210
See the [docker example](https://github.com/socketry/falcon-virtual-docker-example) for a complete working example.
211+
212+
### systemd Service File
213+
214+
You can create a systemd service file to manage the Falcon virtual service. Here is an example of a systemd service file for Falcon:
215+
216+
```ini
217+
[Unit]
218+
Description=Falcon Virtual Service
219+
After=network.target
220+
221+
[Service]
222+
Type=notify
223+
User=http
224+
WorkingDirectory=/srv/http
225+
ExecStart=/usr/local/bin/falcon virtual /srv/http/*/falcon.rb
226+
Restart=always
227+
228+
[Install]
229+
WantedBy=multi-user.target
230+
```

0 commit comments

Comments
 (0)