Skip to content

Commit f6faf61

Browse files
committed
Ported lab 4
1 parent 67423e7 commit f6faf61

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+232
-247
lines changed

content/nginx-one/workshops/lab1/getting-started-with-nginx-one.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ You can only delete a key after you revoke it.
116116

117117
Now that you’ve explored NGINX One Console and created a key, you’re ready to connect your first NGINX instance.
118118

119-
[Go to Lab 2: Run workshop components with Docker]({{< ref "nginx-one/workshops/lab2/run-workshop-components-with-docker.md" >}})
119+
Go to [Lab 2: Run workshop components with Docker]({{< ref "nginx-one/workshops/lab2/run-workshop-components-with-docker.md" >}})
120120

121121
---
122122

content/nginx-one/workshops/lab2/run-workshop-components-with-docker.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ Make sure you have:
4545
2. **Change to the Lab 2 directory**
4646

4747
```shell
48-
cd workshops/nginx-one/lab2
48+
cd static/workshops/nginx-one/lab2
4949
```
5050

5151
This folder contains `docker-compose.yml` and `generate_certs.sh`.
5252

53+
{{<fa "download">}} {{<link "/workshops/nginx-one/lab2/docker-compose.yml" "Download docker-compose.yaml">}}
54+
55+
{{<fa "download">}} {{<link "/workshops/nginx-one/lab2/generate_certs.sh" "Download generate_certs.sh">}}
56+
5357
---
5458

5559
## Set environment variables
@@ -141,7 +145,7 @@ If you don’t see them, double-check your `$TOKEN` or generate a new data plane
141145

142146
Now that your containers are up and registered, go on to explore NGINX One Console features in Lab 3.
143147

144-
[Go to Lab 3](../lab3/readme.md)
148+
Go to [Lab 3: Explore NGINX One Console features]({{< ref "nginx-one/workshops/lab3/explore-nginx-one-console-and-features.md" >}})
145149

146150
---
147151

content/nginx-one/workshops/lab3/explore-nginx-one-console-and-features.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,14 @@ By the end of this tutorial, you’ll know how to:
3333
Make sure you have:
3434

3535
- An F5 Distributed Cloud (XC) account with NGINX One enabled
36-
- All containers from Lab 2 running and registered
36+
- All containers from [Lab 2](nginx-one/workshops/lab2/run-workshop-components-with-docker.md) running and registered
37+
- Your unique identifier in the `NAME` environment variable (set in Lab 2), for example `s.jobs`:
38+
39+
```shell
40+
export NAME="s.jobs"
41+
```
42+
3743
- Basic NGINX and Linux knowledge
38-
- Your `$NAME` environment variable set (from [Lab 2]({{< ref "nginx-one/workshops/lab2/run-workshop-components-with-docker.md" >}}))
3944

4045
---
4146

@@ -174,7 +179,7 @@ Try it on:
174179

175180
## Next steps
176181

177-
When you’re ready, move on to [Lab 4](../lab4/readme.md)
182+
Go to [Lab 4: Config Sync Groups]({{< ref "nginx-one/workshops/lab4/config-sync-groups.md" >}})
178183

179184
---
180185

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
---
2+
title: "Lab 4: Config Sync Groups"
3+
weight: 400
4+
toc: true
5+
nd-content-type: tutorial
6+
nd-product: nginx-one
7+
---
8+
9+
## Overview
10+
11+
In this lab, you create and manage Config Sync Groups in NGINX One Console. Config Sync Groups keep your NGINX instances in sync with a shared configuration. You learn to create a group, add instances, apply a shared config, and fix sync errors.
12+
13+
## What you’ll learn
14+
15+
By the end of this lab, you'll know how to:
16+
17+
- Create a Config Sync Group
18+
- Add instances to a Config Sync Group
19+
- Update the shared configuration for a Config Sync Group
20+
21+
## Before you begin
22+
23+
Make sure you have:
24+
25+
- Completed [Lab 2: Run workshop components with Docker]({{< ref "nginx-one/workshops/lab2/run-workshop-components-with-docker.md" >}})
26+
- Docker and Docker Compose installed and running
27+
- Your data plane key in the `TOKEN` environment variable (set in Lab 2):
28+
29+
```shell
30+
export TOKEN="your-data-plane-key"
31+
```
32+
33+
- Your NGINX Plus JWT license file saved as `nginx-repo.jwt`, and `JWT` set (set in Lab 2):
34+
35+
```shell
36+
export JWT=$(cat path/to/nginx-repo.jwt)
37+
```
38+
39+
- Your unique identifier in the NAME environment variable (set in Lab 2), for example `s.jobs`:
40+
41+
```shell
42+
export NAME="s.jobs"
43+
```
44+
45+
- Basic familiarity with Linux command line and NGINX concepts
46+
47+
---
48+
49+
## Exercise 1: Create a Config Sync Group
50+
51+
A Config Sync Group lets you apply one configuration to multiple NGINX instances and keep them in sync.
52+
53+
1. In the NGINX One Console, select **Manage > Config Sync Groups**.
54+
2. In the **Config Sync Groups** pane, select **Add Config Sync Group**.
55+
3. In the **Add Config Sync Group** form, in the **Name** field, enter `$NAME-sync-group` (for example, `s.jobs-sync-group`).
56+
4. Select **Create**. The new group appears with **Details** and **Configuration** tabs.
57+
- The **Details** tab shows:
58+
- Object ID
59+
- Last publication status and config version ID
60+
- Config Sync Status (for example, Unknown)
61+
- Instance status counts (In Sync, Out of Sync, Offline, Unavailable)
62+
5. Switch to the **Configuration** tab to view your group’s configuration files. It’s empty for now. You’ll add one in Exercise 2.
63+
64+
---
65+
66+
## Exercise 2: Add instances to the Config Sync Group
67+
68+
{{< call-out "note" "Note" "" >}} You can mix OSS and Plus instances in one group. But any config feature you use must work on every instance. If you need Plus-only features, put them in a separate group. {{</ call-out >}}
69+
70+
When you create a Config Sync Group, it has no shared config to begin with. You can add a shared config in two ways:
71+
72+
- **Define config manually**: select your group, go to the **Configuration** tab, then select **Edit Configuration**. Add or paste your NGINX config, select **Next**, review the diff, and select **Save and Publish**.
73+
- **Populate from first instance**: add one NGINX instance. The console uses that instance’s existing config as the group’s shared config.
74+
75+
### Populate group config from first instance
76+
77+
Add a single NGINX instance so the console uses its existing config as the group’s shared config.
78+
79+
1. Select **Manage > Config Sync Groups**.
80+
2. Select your `$NAME-sync-group` group. (For example, `s.jobs-sync-group`.)
81+
3. On the **Details** tab, in the **Instances** pane, select **Add Instance to Config Sync Group**.
82+
4. Select **Register a new instance with NGINX One then add to config sync group**, then select **Next**.
83+
5. Select **Use existing key**, paste `$TOKEN` (or your actual data plane key) into the **Data Plane Key** box.
84+
6. Select the **Docker Container** tab. The tab shows sample commands for logging in, pulling an image, and running the container. Copy those sample commands and modify them as follows:
85+
86+
7. Log in to the private registry:
87+
88+
```shell
89+
echo "$JWT" \
90+
| docker login private-registry.nginx.com \
91+
--username "$JWT" --password-stdin
92+
```
93+
94+
8. Pull a Docker (replace version as needed). Subject to availability, you can replace the agent with the specific NGINX Plus version, OS type, and OS version you need. Here we are going to pull the r31 version of NGINX+ on alpine to demonstrate that.See [Pulling the image]({{< ref "nginx/admin-guide/installing-nginx/installing-nginx-docker.md#pull-the-image" >}}).
95+
96+
```shell
97+
docker pull private-registry.nginx.com/nginx-plus/agent:nginx-plus-r31-alpine-3.19-20240522
98+
```
99+
100+
9. Copy the docker run command from the user interface and modify it as follows:
101+
102+
- Replace `YOUR_JWT_HERE` in `--env NGINX_LICENSE_JWT` with `$JWT`
103+
- Replace `YOUR_DATA_PLANE_KEY` in `--env NGINX_AGENT_SERVER_TOKEN` with `$TOKEN`
104+
- Add `--hostname "$NAME-one-manual"` and `--name "$NAME-one-manual"` flags
105+
- Ensure `--env NGINX_AGENT_INSTANCE_GROUP="$NAME-sync-group"` is set
106+
107+
```shell
108+
docker run \
109+
--hostname "$NAME-one-manual" \
110+
--name "$NAME-one-manual" \
111+
--env NGINX_LICENSE_JWT="$JWT" \
112+
--env NGINX_AGENT_SERVER_GRPCPORT=443 \
113+
--env NGINX_AGENT_SERVER_HOST=agent.connect.nginx.com \
114+
--env NGINX_AGENT_SERVER_TOKEN="$TOKEN" \
115+
--env NGINX_AGENT_INSTANCE_GROUP="$NAME-sync-group" \
116+
--env NGINX_AGENT_TLS_ENABLE=true \
117+
--restart always \
118+
--runtime runc \
119+
-d private-registry.nginx.com/nginx-plus/agent:nginx-plus-r31-alpine-3.19-20240522
120+
```
121+
122+
10. In the **Config Sync Groups** panel, select **Refresh**. The new instance appears and the shared config populates. The first instance added becomes the default config source.
123+
11. Select the **Configuration** tab to view the shared config.
124+
125+
#### Add instances using Docker Compose
126+
127+
Instead of registering each container manually, you can set the sync group in your compose file and restart all containers at once.
128+
129+
You can edit the `docker-config.yaml` file to add those instances to the config sync group:
130+
131+
1. Stop the running containers:
132+
133+
```shell
134+
docker compose down
135+
```
136+
137+
2. Open `docker-compose.yaml` in a text editor.
138+
3. Uncomment the lines beginning with:
139+
140+
```yaml
141+
NGINX_AGENT_INSTANCE_GROUP: $NAME-sync-group
142+
```
143+
144+
4. Restart all containers:
145+
146+
```shell
147+
docker compose up --force-recreate -d
148+
```
149+
150+
5. In the NGINX One Console, select **Refresh**. The instances with `NGINX_AGENT_INSTANCE_GROUP` set appear in the Config Sync Group.
151+
152+
6. Instances automatically sync the existing NGINX config. When the sync finishes, the **Config Sync Status** shows `In Sync`.
153+
154+
<span style="display: inline-block;">
155+
{{< img src="nginx-one/images/config-sync-status.png"
156+
alt="Table showing hostnames, NGINX versions, operating systems, availability status, and green In Sync indicators for each instance in the config sync group" >}}
157+
</span>
158+
159+
160+
## Exercise 3: Edit the group config and sync changes
161+
162+
Modify the shared group configuration and apply those changes to all group members.
163+
164+
1. Select **Manage > Config Sync Groups**, then choose your `$NAME-sync-group` (for example, `s-jobs-sync-group`).
165+
2. Select the **Configuration** tab.
166+
3. Select **Edit Configuration** (pencil icon).
167+
4. In the file list, select `default.conf`.
168+
5. In the editor pane, add these lines at 21–24:
169+
170+
```yaml
171+
location /test_header {
172+
add_header X-Test-App true;
173+
return 200 'HTTP/1.1 200 OK\nContent-Type: text/html\n\n<html><body>Welcome to Lab 4 of the NGINX One Console Workshop!</body></html>';
174+
}
175+
```
176+
177+
<span style="display: inline-block;">
178+
{{< img src="nginx-one/images/config-sync-edits.png"
179+
alt="" >}}
180+
</span>
181+
182+
When you make these edits, the file is marked "modified" and the validator shows **NGINX Config OK**.
183+
6. Select **Next**, review the diff, then select **Save and Publish**.
184+
7. Select the **Details** tab and confirm **Last Publication Status** shows **Succeeded**.
185+
8. In the **Instances** table, confirm each host shows **Config Sync Status** = **In Sync**.
186+
9. Test your change by curling any instance’s HTTP endpoint. Replace `<HOST>` and `<PORT>` with your instance’s host name or IP and the port shown in the Instances table (for example, `localhost:80`):
187+
188+
```shell
189+
curl http://localhost:80/test_header
190+
```
191+
192+
You should see:
193+
194+
```text
195+
HTTP/1.1 200 OK
196+
Content-Type: text/html
197+
198+
<html><body>Welcome to Lab 4 of the NGINX One Console Workshop!</body></html>
199+
```
200+
201+
---
202+
203+
## Next steps
204+
205+
You have created a Config Sync Group and added instances. In Lab 5, you will install your NGINX Plus license (JWT) on each instance so you can upgrade them to NGINX R34.
206+
207+
Go to [Lab 5: Upgrade to R34]()
208+
209+
---
210+
211+
## References
212+
213+
- [NGINX One Console docs](https://docs.nginx.com/nginx-one/)
451 KB
Loading
136 KB
Loading

0 commit comments

Comments
 (0)