ngrok / kubernetes-ingress-controller

The official ngrok Ingress Controller for Kubernetes
https://ngrok.com
MIT License
183 stars 20 forks source link

modules to traffic policy #370

Closed OfTheDelmer closed 2 months ago

OfTheDelmer commented 2 months ago

What

Updates the https edge ingress route spec with either the annotated modset policy or the annotated traffic policy policy

How

Validation

ingress_trafficpolicy_crd_test.yml

---
kind: NgrokTrafficPolicy
apiVersion: ngrok.k8s.ngrok.com/v1alpha1
metadata:
  name: traffic-policy-2
spec:
    policy:
      inbound:
        - name: "test_in"
          expressions:
            - "req.Method == 'PUT'"
          actions:
            - type: "deny"
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
  annotations:
    k8s.ngrok.com/traffic-policy: traffic-policy-2
spec:
  ingressClassName: ngrok
  rules:
    - host: trafficpolicyingress-test.ngrok.dev
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: game-2048
                port:
                  number: 80

2048.yml

apiVersion: v1
kind: Service
metadata:
  name: game-2048
  namespace: ngrok-ingress-controller
spec:
  ports:
    - name: http
      port: 80
      targetPort: 80
  selector:
    app: game-2048
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: game-2048
  namespace: ngrok-ingress-controller
spec:
  replicas: 1
  selector:
    matchLabels:
      app: game-2048
  template:
    metadata:
      labels:
        app: game-2048
    spec:
      containers:
        - name: backend
          image: alexwhen/docker-2048
          ports:
            - name: http
              containerPort: 80