Skip to content

Commit a1bb1da

Browse files
authored
Improve user experience in Get Started guide for NGF (#799)
1 parent d1bb519 commit a1bb1da

File tree

1 file changed

+128
-21
lines changed

1 file changed

+128
-21
lines changed

content/ngf/get-started.md

Lines changed: 128 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,76 @@ The YAML code in the following sections can be found in the [cafe-example folder
132132

133133
### Create the application resources
134134

135-
Create the file _cafe.yaml_ with the following contents:
136-
137-
{{< ghcode `https://raw.githubusercontent.com/nginx/nginx-gateway-fabric/refs/heads/main/examples/cafe-example/cafe.yaml`>}}
138-
139-
Apply it using `kubectl`:
140-
141-
```shell
135+
Run the following command to create the file _cafe.yaml_, which is then used to deploy the *coffee* application to your cluster:
136+
137+
```yaml
138+
cat <<EOF > cafe.yaml
139+
apiVersion: apps/v1
140+
kind: Deployment
141+
metadata:
142+
name: coffee
143+
spec:
144+
replicas: 1
145+
selector:
146+
matchLabels:
147+
app: coffee
148+
template:
149+
metadata:
150+
labels:
151+
app: coffee
152+
spec:
153+
containers:
154+
- name: coffee
155+
image: nginxdemos/nginx-hello:plain-text
156+
ports:
157+
- containerPort: 8080
158+
---
159+
apiVersion: v1
160+
kind: Service
161+
metadata:
162+
name: coffee
163+
spec:
164+
ports:
165+
- port: 80
166+
targetPort: 8080
167+
protocol: TCP
168+
name: http
169+
selector:
170+
app: coffee
171+
---
172+
apiVersion: apps/v1
173+
kind: Deployment
174+
metadata:
175+
name: tea
176+
spec:
177+
replicas: 1
178+
selector:
179+
matchLabels:
180+
app: tea
181+
template:
182+
metadata:
183+
labels:
184+
app: tea
185+
spec:
186+
containers:
187+
- name: tea
188+
image: nginxdemos/nginx-hello:plain-text
189+
ports:
190+
- containerPort: 8080
191+
---
192+
apiVersion: v1
193+
kind: Service
194+
metadata:
195+
name: tea
196+
spec:
197+
ports:
198+
- port: 80
199+
targetPort: 8080
200+
protocol: TCP
201+
name: http
202+
selector:
203+
app: tea
204+
EOF
142205
kubectl apply -f cafe.yaml
143206
```
144207

@@ -163,13 +226,22 @@ tea-6fbfdcb95d-9lhbj 1/1 Running 0 9s
163226

164227
### Create Gateway and HTTPRoute resources
165228

166-
Create the file _gateway.yaml_ with the following contents:
167-
168-
{{< ghcode `https://raw.githubusercontent.com/nginx/nginx-gateway-fabric/refs/heads/main/examples/cafe-example/gateway.yaml`>}}
169-
170-
Apply it using `kubectl`:
171-
172-
```shell
229+
Run the following command to create the file _gateway.yaml_, which is then used to deploy a Gateway to your cluster:
230+
231+
```yaml
232+
cat <<EOF > gateway.yaml
233+
apiVersion: gateway.networking.k8s.io/v1
234+
kind: Gateway
235+
metadata:
236+
name: gateway
237+
spec:
238+
gatewayClassName: nginx
239+
listeners:
240+
- name: http
241+
port: 80
242+
protocol: HTTP
243+
hostname: "*.example.com"
244+
EOF
173245
kubectl apply -f gateway.yaml
174246
```
175247

@@ -190,13 +262,48 @@ gateway-nginx-66b5d78f8f-4fmtb 1/1 Running 0 13s
190262
tea-6fbfdcb95d-9lhbj 1/1 Running 0 31s
191263
```
192264

193-
Create the file _cafe-routes.yaml_ with the following contents:
194-
195-
{{< ghcode `https://raw.githubusercontent.com/nginx/nginx-gateway-fabric/refs/heads/main/examples/cafe-example/cafe-routes.yaml`>}}
196-
197-
Apply it using `kubectl`:
198-
199-
```shell
265+
Run the following command to create the file _cafe-routes.yaml_. It is then used to deploy two *HTTPRoute* resources in your cluster: one each for _/coffee_ and _/tea_.
266+
267+
```yaml
268+
cat <<EOF > cafe-routes.yaml
269+
apiVersion: gateway.networking.k8s.io/v1
270+
kind: HTTPRoute
271+
metadata:
272+
name: coffee
273+
spec:
274+
parentRefs:
275+
- name: gateway
276+
sectionName: http
277+
hostnames:
278+
- "cafe.example.com"
279+
rules:
280+
- matches:
281+
- path:
282+
type: PathPrefix
283+
value: /coffee
284+
backendRefs:
285+
- name: coffee
286+
port: 80
287+
---
288+
apiVersion: gateway.networking.k8s.io/v1
289+
kind: HTTPRoute
290+
metadata:
291+
name: tea
292+
spec:
293+
parentRefs:
294+
- name: gateway
295+
sectionName: http
296+
hostnames:
297+
- "cafe.example.com"
298+
rules:
299+
- matches:
300+
- path:
301+
type: Exact
302+
value: /tea
303+
backendRefs:
304+
- name: tea
305+
port: 80
306+
EOF
200307
kubectl apply -f cafe-routes.yaml
201308
```
202309

0 commit comments

Comments
 (0)