Skip to content

Commit

Permalink
Fix Ingress and add stress test example
Browse files Browse the repository at this point in the history
  • Loading branch information
vmleon committed May 9, 2022
1 parent 12130be commit f1c4483
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 16 deletions.
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ This project is composed of:
## TODO

- Query the logs in Logging Analytics
- Ingress controller with Load Balancer
- Add policies and Dynamic group
- Fix Ingress Controller

## Enable access to Log Group with Instance Principal

Expand Down Expand Up @@ -86,18 +84,28 @@ If deployed from your local machine, you can run `export KUBECONFIG=$(pwd)/gener

With the `KUBECONFIG` exported you can use `kubectl get nodes` to get the Kubernetes worker nodes and list the helm releases with `helm list`.

Create a port forward (only if you deploy on the local terminal):
Get the public IP of the load balancer:

Go to **Menu** > **Networking** > **Load Balancers** > **Administration**.

![Load Balancer Public IP](images/loadbalancer-public-ip.png)

Get the Public IP from the column:

```
kubectl port-forward service/hello-api 3000:3000
export LB_PUBLIC_IP=<VALUE_FROM_UI>
```

> WIP: Include ingress-nginx-controller
> If you are deploying from your local terminal:
>
> ```
> export LB_PUBLIC_IP=$(kubectl get services -o jsonpath='{.items[?(@.spec.type=="LoadBalancer")].status.loadBalancer.ingress[0].ip}')
> ```
You have two options to generate some workload and therefore logs to be explored with Logging Analytics.
- Option 1: `podman run -i grafana/k6 run - <load/test.js`
- Option 2: Run a bunch of `curl -s localhost:3000/hello`.
- Option 1: `podman run -i grafana/k6 run -e LB_PUBLIC_IP=$LB_PUBLIC_IP - <load/test.js`
- Option 2: Run a bunch of `curl -s http://$LB_PUBLIC_IP/hello`.
## Destroy
Expand Down
7 changes: 3 additions & 4 deletions helm-charts/hello-api/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ spec:
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
{{- range .Values.ingress.rules }}
- http:
paths:
{{- range .paths }}
{{- range .http.paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
Expand Down
15 changes: 10 additions & 5 deletions helm-charts/hello-api/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,16 @@ ingress:
service.beta.kubernetes.io/oci-load-balancer-shape-flex-max: "20Mbps"
# kubernetes.io/tls-acme: "true"
# https://github.com/oracle/oci-cloud-controller-manager
hosts:
- host: chart-example.local
paths:
- path: /
pathType: ImplementationSpecific
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: hello-api
port:
number: 3000
tls: []
# - secretName: chart-example-tls
# hosts:
Expand Down
Binary file added images/loadbalancer-public-ip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions load/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { check } from "k6";
import http from "k6/http";

export const options = {
vus: 10,
duration: "20s",
};

export default function () {
const res = http.get(`http://${__ENV.LB_PUBLIC_IP}/hello`);
check(res, {
"Is 200 OK": (r) => r.status === 200,
"Valid Response": (r) => r.body.includes("Hello"),
});
}

0 comments on commit f1c4483

Please sign in to comment.