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

feat: Contribute an NGINX Gateway Fabric example and article #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The following examples are provided:
| [Preview Stack Testing](examples/preview-testing) | Rollout which launches an experiment that tests a preview stack (which receives no production traffic) |
| [Canary with istio (1)](examples/istio) | Rollout which uses host-level traffic splitting during update |
| [Canary with istio (2)](examples/istio-subset) | Rollout which uses subset-level traffic splitting during update |
| [Canary Analysis with NGINX Gateway Fabric](examples/nginx-gateway-fabric) | Rollout which performs canary analysis as part of the update. Uses the prometheus metric provider, and requires the [Argo Rollouts Gateway API Plugin](https://rollouts-plugin-trafficrouter-gatewayapi.readthedocs.io/en/latest/) |

Before running an example:

Expand Down
323 changes: 323 additions & 0 deletions examples/nginx-gateway-fabric/ARTICLE.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions examples/nginx-gateway-fabric/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Argo Rollouts Example for NGINX Gateway Fabric

This directory contains a [walkthrough article](ARTICLE.md) and example manifests to perform a Canary rollout (with Analysis) of the demo application using NGINX Gateway Fabric.
29 changes: 29 additions & 0 deletions examples/nginx-gateway-fabric/analysis-success-rate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
name: success-rate
spec:
args:
- name: namespace
- name: service-name
- name: service-port
metrics:
- name: success-rate
interval: 1m
successCondition: len(result) == 0 || result[0] >= 0.99
failureLimit: 0
provider:
prometheus:
address: http://prometheus-server.prometheus
query: >+
sum(rate(
nginx_gateway_fabric_upstream_server_responses{upstream="{{args.namespace}}_{{args.service-name}}_{{args.service-port}}",
code!~"[4-5].*"}[1m])
) by (upstream)
/
sum(rate(
nginx_gateway_fabric_upstream_server_responses{upstream="{{args.namespace}}_{{args.service-name}}_{{args.service-port}}"}[1m])
) by (upstream)
unless sum(rate(
nginx_gateway_fabric_upstream_server_responses{upstream="{{args.namespace}}_{{args.service-name}}_{{args.service-port}}"}[1m])
) by (upstream) == 0
12 changes: 12 additions & 0 deletions examples/nginx-gateway-fabric/canary-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: rollouts-demo-canary-service
spec:
ports:
- port: 8080
targetPort: 8080
protocol: TCP
name: http
selector:
app: rollouts-demo
10 changes: 10 additions & 0 deletions examples/nginx-gateway-fabric/gateway.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: gateway.networking.k8s.io/v1beta1
kind: Gateway
metadata:
name: rollouts-demo-gateway
spec:
gatewayClassName: nginx
listeners:
- protocol: HTTP
name: web
port: 80
18 changes: 18 additions & 0 deletions examples/nginx-gateway-fabric/httproute.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: rollouts-demo-httproute
spec:
parentRefs:
- name: rollouts-demo-gateway
rules:
- matches:
- path:
type: PathPrefix
value: /
backendRefs:
- name: rollouts-demo-stable-service
port: 8080
- name: rollouts-demo-canary-service
port: 8080
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/nginx-gateway-fabric/images/ui-blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions examples/nginx-gateway-fabric/rollout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: rollouts-demo
spec:
replicas: 5
revisionHistoryLimit: 1
selector:
matchLabels:
app: rollouts-demo
strategy:
canary:
analysis:
templates:
- templateName: success-rate
args:
- name: namespace
value: default
- name: service-name
value: rollouts-demo-canary-service
- name: service-port
value: "8080"
canaryService: rollouts-demo-canary-service # our created canary service
stableService: rollouts-demo-stable-service # our created stable service
trafficRouting:
plugins:
argoproj-labs/gatewayAPI:
httpRoute: rollouts-demo-httproute # our created httproute
namespace: default # namespace where this rollout resides
steps:
- setWeight: 30
- pause: {}
- setWeight: 40
- pause:
duration: 1m
- setWeight: 60
- pause:
duration: 1m
- setWeight: 80
- pause:
duration: 1m
template:
metadata:
labels:
app: rollouts-demo
spec:
containers:
- name: rollouts-demo
image: argoproj/rollouts-demo:blue
ports:
- name: http
containerPort: 8080
protocol: TCP
resources:
requests:
memory: 32Mi
cpu: 5m
12 changes: 12 additions & 0 deletions examples/nginx-gateway-fabric/stable-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: rollouts-demo-stable-service
spec:
ports:
- port: 8080
targetPort: 8080
protocol: TCP
name: http
selector:
app: rollouts-demo