Skip to content

Commit d27d9b9

Browse files
committed
WIP - simplify VSR/VS examples
1 parent 962781d commit d27d9b9

24 files changed

+278
-78
lines changed
Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
# Cross-Namespace Configuration
1+
# Basic, single-namespace VirtualServerRoute Selector
22

33
In this example we use the [VirtualServer and
44
VirtualServerRoute](https://docs.nginx.com/nginx-ingress-controller/configuration/virtualserver-and-virtualserverroute-resources/)
55
resources to configure load balancing for the modified cafe application from the [Basic
66
Configuration](../basic-configuration/) example. We have put the load balancing configuration as well as the deployments
7-
and services into multiple namespaces. Instead of one namespace, we now use three: `tea`, `coffee`, and `cafe`.
7+
and services into one default namespace.
88

9-
- In the tea namespace, we create the tea deployment, service, and the corresponding load-balancing configuration.
10-
- In the coffee namespace, we create the coffee deployment, service, and the corresponding load-balancing configuration.
11-
- In the cafe namespace, we create the cafe secret with the TLS certificate and key and the load-balancing configuration
12-
for the cafe application. That configuration references the coffee and tea configurations.
9+
- In the default namespace, we create the tea deployment, service, and the corresponding load-balancing configuration.
10+
- In the same namespace, we create the cafe secret with the TLS certificate and key and the load-balancing configuration
11+
for the cafe application. That configuration references the tea configuration.
1312

1413
## Prerequisites
1514

15+
16+
## Step 1 - Install NGINX Ingress COntroller
17+
1618
1. Follow the [installation](https://docs.nginx.com/nginx-ingress-controller/installation/installation-with-manifests/)
1719
instructions to deploy the Ingress Controller with custom resources enabled.
20+
1821
1. Save the public IP address of the Ingress Controller into a shell variable:
1922

2023
```console
@@ -27,13 +30,6 @@ and services into multiple namespaces. Instead of one namespace, we now use thre
2730
IC_HTTPS_PORT=<port number>
2831
```
2932

30-
## Step 1 - Create Namespaces
31-
32-
Create the required tea, coffee, and cafe namespaces:
33-
34-
```console
35-
kubectl create -f namespaces.yaml
36-
```
3733

3834
## Step 2 - Deploy the Cafe Application
3935

@@ -43,33 +39,33 @@ kubectl create -f namespaces.yaml
4339
kubectl create -f tea.yaml
4440
```
4541

46-
1. Create the coffee deployment and service in the coffee namespace:
42+
1. Create the coffee deployment and service in the default namespace:
4743

4844
```console
4945
kubectl create -f coffee.yaml
5046
```
5147

5248
## Step 3 - Configure Load Balancing and TLS Termination
5349

54-
1. Create the VirtualServerRoute resource for tea in the tea namespace:
50+
1. Create the VirtualServerRoute resource for tea:
5551

5652
```console
5753
kubectl create -f tea-virtual-server-route.yaml
5854
```
5955

60-
1. Create the VirtualServerRoute resource for coffee in the coffee namespace:
56+
1. Create the VirtualServerRoute resource for coffee:
6157

6258
```console
6359
kubectl create -f coffee-virtual-server-route.yaml
6460
```
6561

66-
1. Create the secret with the TLS certificate and key in the cafe namespace:
62+
1. Create the secret with the TLS certificate and key:
6763

6864
```console
6965
kubectl create -f cafe-secret.yaml
7066
```
7167

72-
1. Create the VirtualServer resource for the cafe app in the cafe namespace:
68+
1. Create the VirtualServer resource for the cafe app:
7369

7470
```console
7571
kubectl create -f cafe-virtual-server.yaml
@@ -85,37 +81,23 @@ kubectl create -f namespaces.yaml
8581
```
8682

8783
```text
88-
. . .
89-
Events:
90-
Type Reason Age From Message
91-
---- ------ ---- ---- -------
92-
Warning NoVirtualServersFound 2m nginx-ingress-controller No VirtualServer references VirtualServerRoute tea/tea
93-
Normal AddedOrUpdated 1m nginx-ingress-controller Configuration for tea/tea was added or updated
84+
WIP - add an example
9485
```
9586

9687
```console
97-
kubectl describe virtualserverroute coffee -n coffee
88+
kubectl describe virtualserverroute coffee
9889
```
9990

10091
```text
101-
. . .
102-
Events:
103-
Type Reason Age From Message
104-
---- ------ ---- ---- -------
105-
Warning NoVirtualServersFound 2m nginx-ingress-controller No VirtualServer references VirtualServerRoute coffee/coffee
106-
Normal AddedOrUpdated 1m nginx-ingress-controller Configuration for coffee/coffee was added or updated
92+
WIP - add an example
10793
```
10894

10995
```console
110-
kubectl describe virtualserver cafe -n cafe
96+
kubectl describe virtualserver cafe
11197
```
11298

11399
```text
114-
. . .
115-
Events:
116-
Type Reason Age From Message
117-
---- ------ ---- ---- -------
118-
Normal AddedOrUpdated 1m nginx-ingress-controller Configuration for cafe/cafe was added or updated
100+
WIP - add example
119101
```
120102

121103
1. Access the application using curl. We'll use curl's `--insecure` option to turn off certificate verification of our
@@ -144,3 +126,4 @@ kubectl create -f namespaces.yaml
144126
Server address: 10.16.0.157:80
145127
Server name: tea-7d57856c44-674b8
146128
...
129+

examples/custom-resources/vsr-route-selector/api-key-secret.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
kind: Secret
33
metadata:
44
name: api-key-client-secret
5-
namespace: cafe
5+
namespace: default
66
type: nginx.org/apikey
77
data:
88
client1: cGFzc3dvcmQ= # password

examples/custom-resources/vsr-route-selector/cafe-secret.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
kind: Secret
33
metadata:
44
name: cafe-secret
5-
namespace: cafe
5+
namespace: default
66
type: kubernetes.io/tls
77
data:
88
tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURMakNDQWhZQ0NRREFPRjl0THNhWFdqQU5CZ2txaGtpRzl3MEJBUXNGQURCYU1Rc3dDUVlEVlFRR0V3SlYKVXpFTE1Ba0dBMVVFQ0F3Q1EwRXhJVEFmQmdOVkJBb01HRWx1ZEdWeWJtVjBJRmRwWkdkcGRITWdVSFI1SUV4MApaREViTUJrR0ExVUVBd3dTWTJGbVpTNWxlR0Z0Y0d4bExtTnZiU0FnTUI0WERURTRNRGt4TWpFMk1UVXpOVm9YCkRUSXpNRGt4TVRFMk1UVXpOVm93V0RFTE1Ba0dBMVVFQmhNQ1ZWTXhDekFKQmdOVkJBZ01Ba05CTVNFd0h3WUQKVlFRS0RCaEpiblJsY201bGRDQlhhV1JuYVhSeklGQjBlU0JNZEdReEdUQVhCZ05WQkFNTUVHTmhabVV1WlhoaApiWEJzWlM1amIyMHdnZ0VpTUEwR0N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sr-route-selector/cafe-virtual-server.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: k8s.nginx.org/v1
22
kind: VirtualServer
33
metadata:
44
name: cafe
5-
namespace: cafe
5+
namespace: default
66
spec:
77
host: cafe.example.com
88
tls:

examples/custom-resources/vsr-route-selector/coffee-virtual-server-route.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: k8s.nginx.org/v1
22
kind: VirtualServerRoute
33
metadata:
44
name: coffee
5-
namespace: coffee
5+
namespace: default
66
labels:
77
app: cafe
88
route: coffee

examples/custom-resources/vsr-route-selector/coffee.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: apps/v1
22
kind: Deployment
33
metadata:
44
name: coffee
5-
namespace: coffee
5+
namespace: default
66
spec:
77
replicas: 1
88
selector:
@@ -23,7 +23,7 @@ apiVersion: v1
2323
kind: Service
2424
metadata:
2525
name: coffee-svc
26-
namespace: coffee
26+
namespace: default
2727
spec:
2828
ports:
2929
- port: 80

examples/custom-resources/vsr-route-selector/namespaces.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

examples/custom-resources/vsr-route-selector/rate-limit.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

examples/custom-resources/vsr-route-selector/tea-virtual-server-route.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: k8s.nginx.org/v1
22
kind: VirtualServerRoute
33
metadata:
44
name: tea
5-
namespace: tea
5+
namespace: default
66
labels:
77
route: tea
88
app: cafe

examples/custom-resources/vsr-route-selector/tea.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: apps/v1
22
kind: Deployment
33
metadata:
44
name: tea
5-
namespace: tea
5+
namespace: default
66
spec:
77
replicas: 1
88
selector:
@@ -23,7 +23,7 @@ apiVersion: v1
2323
kind: Service
2424
metadata:
2525
name: tea-svc
26-
namespace: tea
26+
namespace: default
2727
spec:
2828
ports:
2929
- port: 80

0 commit comments

Comments
 (0)