From 51f08ef3d6bed8f66607de507b7f424ba4dd664e Mon Sep 17 00:00:00 2001 From: Rob Szumski Date: Wed, 29 Apr 2015 17:41:32 -0700 Subject: [PATCH 1/3] docs: expand systemd examples --- Documentation/using-rkt-with-systemd.md | 38 +++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/Documentation/using-rkt-with-systemd.md b/Documentation/using-rkt-with-systemd.md index 75fadb1..024afd9 100644 --- a/Documentation/using-rkt-with-systemd.md +++ b/Documentation/using-rkt-with-systemd.md @@ -10,21 +10,55 @@ rkt is designed and intended to be used with init systems like [systemd](http:// Since rkt consists only of a simple CLI that directly executes processes and writes to stdout/stderr (i.e. it does not daemonize), the lifecycle of rkt pods can be directly managed by systemd. Consequently, standard systemd idioms like `systemctl start` and `systemctl stop` work out of the box. -## Example unit file +## Simple Unit File The following is a simple example of a unit file using rkt to run an nginx image: + ``` [Unit] Description=nginx [Service] -ExecStart=/usr/bin/rkt --insecure-skip-verify run docker://nginx +ExecStart=/usr/bin/rkt --insecure-skip-verify run docker://nginx:latest Restart=always ``` This unit can now be managed using the standard `systemctl` commands: + ``` systemctl start nginx.service systemctl stop nginx.service systemctl restart nginx.service ``` + +## Advanced Unit File + +A more advanced unit example takes advantage of a few convinient systemd features: + +1. Inheriting environment variables specified in the unit with `--inherit-env`. This functionality keeps your units clear and concise instead of layering on a ton of flags to `rkt run`. +2. Using the dependency graph to start our pod after networking has come online. This is helpful if your application requires outside connectivity to fetch remote configuration (for exmaple, from etcd). +3. Set resource limits for this rkt pod. This can also be done in the unit instead of passing in a mess of flags to `rkt run`. + +Here's what it looks like altogether: + +``` +[Unit] +# Metadata +Description=MyApp +Documentation=https://myapp.com/docs/1.3.4 +# Wait for networking +Requires=network-online.target +After=network-online.target + +[Service] +# Resource limits +CPUShares=512 +MemoryLimit=1G +# Env vars +Environment=HTTP_PROXY=192.0.2.3:5000 +Environment=STORAGE_PATH=/opt/myapp +Environment=TMPDIR=/var/tmp +# Start the app +ExecStart=/usr/bin/rkt run --inherit-env --private-net --port=http:8888 myapp.com/myapp-1.3.4 +Restart=always +``` From f852f7e2aec2f90fc5f291613918ec7460669236 Mon Sep 17 00:00:00 2001 From: Rob Szumski Date: Wed, 29 Apr 2015 17:50:07 -0700 Subject: [PATCH 2/3] docs: fix spelling/grammar --- Documentation/using-rkt-with-systemd.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/using-rkt-with-systemd.md b/Documentation/using-rkt-with-systemd.md index 024afd9..aec09fa 100644 --- a/Documentation/using-rkt-with-systemd.md +++ b/Documentation/using-rkt-with-systemd.md @@ -33,13 +33,13 @@ systemctl restart nginx.service ## Advanced Unit File -A more advanced unit example takes advantage of a few convinient systemd features: +A more advanced unit example takes advantage of a few convenient systemd features: 1. Inheriting environment variables specified in the unit with `--inherit-env`. This functionality keeps your units clear and concise instead of layering on a ton of flags to `rkt run`. -2. Using the dependency graph to start our pod after networking has come online. This is helpful if your application requires outside connectivity to fetch remote configuration (for exmaple, from etcd). -3. Set resource limits for this rkt pod. This can also be done in the unit instead of passing in a mess of flags to `rkt run`. +2. Using the dependency graph to start our pod after networking has come online. This is helpful if your application requires outside connectivity to fetch remote configuration (for example, from etcd). +3. Set resource limits for this rkt pod. This can also be done in the unit instead of `rkt run`. -Here's what it looks like altogether: +Here's what it looks like all together: ``` [Unit] From 10c8668cb6c9c37dd122287508c4804d420dfba2 Mon Sep 17 00:00:00 2001 From: Rob Szumski Date: Mon, 11 May 2015 09:46:16 -0700 Subject: [PATCH 3/3] docs: remove unused image tag --- Documentation/using-rkt-with-systemd.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/using-rkt-with-systemd.md b/Documentation/using-rkt-with-systemd.md index aec09fa..fda6675 100644 --- a/Documentation/using-rkt-with-systemd.md +++ b/Documentation/using-rkt-with-systemd.md @@ -19,7 +19,7 @@ The following is a simple example of a unit file using rkt to run an nginx image Description=nginx [Service] -ExecStart=/usr/bin/rkt --insecure-skip-verify run docker://nginx:latest +ExecStart=/usr/bin/rkt --insecure-skip-verify run docker://nginx Restart=always ```