Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example for the service insight feature (VS and TS) #3691

Merged
merged 24 commits into from
Mar 30, 2023
Merged
Changes from 8 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e77cd7a
WIP - add NIC deployment example
jjngx Mar 23, 2023
afb4265
WIP - Add sections for VS and TS
jjngx Mar 23, 2023
f3223d9
Add service insight example for VS
jjngx Mar 27, 2023
1e777ef
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 27, 2023
49f6994
Update example
jjngx Mar 28, 2023
7cce25c
Merge branch 'main' into docs/service-insight-example
jjngx Mar 28, 2023
d03dce3
Update examples/custom-resources/service-insight/README.md
jjngx Mar 28, 2023
d6ff337
Update examples/custom-resources/service-insight/README.md
jjngx Mar 28, 2023
d3e19be
Update examples/custom-resources/service-insight/README.md
jjngx Mar 28, 2023
9ff35d9
Update examples/custom-resources/service-insight/README.md
jjngx Mar 28, 2023
0820251
Update examples/custom-resources/service-insight/README.md
jjngx Mar 28, 2023
1eeda91
Update examples/custom-resources/service-insight/README.md
jjngx Mar 28, 2023
a3ba4fb
Update examples/custom-resources/service-insight/README.md
jjngx Mar 28, 2023
fc0ec1a
Update examples/custom-resources/service-insight/README.md
jjngx Mar 28, 2023
378c0ec
Update examples/custom-resources/service-insight/README.md
jjngx Mar 28, 2023
20a95f3
Update examples/custom-resources/service-insight/README.md
jjngx Mar 28, 2023
ec1fd5b
Update examples/custom-resources/service-insight/README.md
jjngx Mar 28, 2023
330a9f4
Add TransportServer Service Insight example
jjngx Mar 28, 2023
c65c21f
Update examples/custom-resources/service-insight/README.md
jjngx Mar 28, 2023
faf4235
Merge branch 'main' into docs/service-insight-example
jjngx Mar 29, 2023
5111a20
Add example with TLS support
jjngx Mar 29, 2023
cd3e09d
Update examples/custom-resources/service-insight/README.md
jjngx Mar 29, 2023
9aba953
Merge branch 'main' into docs/service-insight-example
jjngx Mar 29, 2023
098df99
Merge branch 'main' into docs/service-insight-example
jjngx Mar 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 189 additions & 0 deletions examples/custom-resources/service-insight/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
# Support for Service Insight
jjngx marked this conversation as resolved.
Show resolved Hide resolved

> The Service Insight feature is available only for F5 NGINX Plus.

To use the [Service Insight](https://docs.nginx.com/nginx-ingress-controller/logging-and-monitoring/service-insight/) feature provided by NGINX Ingress Controller you must enable it by either setting `serviceInsight.create=true` in your `helm install/upgrade...` command OR [manifest](../../../deployments/deployment/nginx-plus-ingress.yaml) depending on your preferred installation method.
jjngx marked this conversation as resolved.
Show resolved Hide resolved

In the following example we'll enable the Service Insight in the NGINX Ingress Controller using [manifests (Deployment)](../../../deployments/deployment/nginx-plus-ingress.yaml):
jjngx marked this conversation as resolved.
Show resolved Hide resolved

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-ingress
namespace: nginx-ingress
spec:
replicas: 1
selector:
matchLabels:
app: nginx-ingress
template:
metadata:
labels:
app: nginx-ingress
app.kubernetes.io/name: nginx-ingress
spec:
serviceAccountName: nginx-ingress
automountServiceAccountToken: true
securityContext:
...
containers:
- image: nginx-plus-ingress:3.0.2
imagePullPolicy: IfNotPresent
name: nginx-plus-ingress
ports:
- name: http
containerPort: 80
- name: https
containerPort: 443
- name: readiness-port
containerPort: 8081
- name: prometheus
containerPort: 9113
- name: service-insight
containerPort: 9114
readinessProbe:
httpGet:
path: /nginx-ready
port: readiness-port
periodSeconds: 1
resources:
...
securityContext:
...
env:
...
args:
- -nginx-plus
- -nginx-configmaps=$(POD_NAMESPACE)/nginx-config
...
- -enable-service-insight

```

## Deployment

[Install NGINX Ingress Controller](https://docs.nginx.com/nginx-ingress-controller/installation/installation-with-manifests/). Remember to uncomment the `-enable-service-insight` option.

Enable access to the Ingress Controller. Examples below use the `nodeport` service.
jjngx marked this conversation as resolved.
Show resolved Hide resolved

## Configuration

Check nginx-ingress pod id:
jjngx marked this conversation as resolved.
Show resolved Hide resolved

```bash
kubectl get pods -n nginx-ingress
```

```
NAME READY STATUS RESTARTS AGE
nginx-ingress-5b99f485fb-vflb8 1/1 Running 0 72m
```

Forward service insight port 9114 to localhost port 9114:
jjngx marked this conversation as resolved.
Show resolved Hide resolved
```bash
kubectl port-forward -n nginx-ingress nginx-ingress-5b99f485fb-vflb8 9114:9114 &
jjngx marked this conversation as resolved.
Show resolved Hide resolved
```

## Virtual Servers

### Deployment

Follow the [basic configuration example](../basic-configuration/) to deploy `cafe` app and `cafe virtual server`.

### Testing

Verify that the virtual server is up and running and verify the hostname:
jjngx marked this conversation as resolved.
Show resolved Hide resolved
```bash
kubectl get vs cafe
NAME STATE HOST IP PORTS AGE
cafe Valid cafe.example.com 16m
```

Scale down `tea` and `caffee` deployments:
jjngx marked this conversation as resolved.
Show resolved Hide resolved

```bash
kubectl scale deployment tea --replicas=1
```

```bash
kubectl scale deployment coffee --replicas=1
```

Verify `tea` deployment:

```bash
kubectl get deployments.apps tea
```

```bash
NAME READY UP-TO-DATE AVAILABLE AGE
tea 1/1 1 1 19m
```

Verify `coffee` deployment:

```bash
kubectl get deployments.apps coffee
```

```bash
NAME READY UP-TO-DATE AVAILABLE AGE
coffee 1/1 1 1 20m
```

Send `GET` request to the service insight endpoint to check statistics:
jjngx marked this conversation as resolved.
Show resolved Hide resolved

Request:

```bash
curl http://localhost:9114/probe/cafe.example.com
```

Response:

```json
{"Total":2,"Up":2,"Unhealthy":0}
```

Scale up deployments:

```bash
kubectl scale deployment tea --replicas=3
```

```bash
kubectl scale deployment coffee --replicas=3
```

Verify deployments:

```bash
kubectl get deployments.apps tea
```

```bash
NAME READY UP-TO-DATE AVAILABLE AGE
tea 3/3 3 3 31m
```

```bash
kubectl get deployments.apps coffee
```

```bash
NAME READY UP-TO-DATE AVAILABLE AGE
coffee 3/3 3 3 31m
```

Send `GET` HTTP request to the service insight endpoint to check statistics:
jjngx marked this conversation as resolved.
Show resolved Hide resolved

```bash
curl http://localhost:9114/probe/cafe.example.com
```

Response:

```json
{"Total":6,"Up":6,"Unhealthy":0}
```