Skip to content

Instantly share code, notes, and snippets.

@LionelJouin
Created October 16, 2024 14:31
Show Gist options
  • Save LionelJouin/1a66509464843f669af1e36c27cd3dda to your computer and use it in GitHub Desktop.
Save LionelJouin/1a66509464843f669af1e36c27cd3dda to your computer and use it in GitHub Desktop.
l-3-4-gateway-api Config
---
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
  name: macvlan-nad-3
spec:
  config: '{
        "cniVersion":"0.4.0",
        "type":"macvlan",
        "master":"eth0",
        "mode":"bridge",
        "ipam":{
            "log_file":"/tmp/whereabouts.log",
            "type":"whereabouts",
            "ipRanges":[
                {
                    "range":"169.233.100.0/24"
                }
            ]
        }
    }'
---
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
  name: vlan-300
spec:
  config: '{
        "cniVersion":"0.4.0",
        "type":"vlan",
        "name":"vlan-300",
        "master": "eth0",
        "vlanId": 300,
        "linkInContainer": false,
        "ipam":{
            "log_file":"/tmp/whereabouts.log",
            "type":"whereabouts",
            "ipRanges":[
                {
                    "range":"169.254.100.0/24",
                    "exclude":[
                        "169.254.100.150/32"
                    ]
                }
            ]
        }
    }'
---
apiVersion: gateway.networking.k8s.io/v1beta1
kind: Gateway
metadata:
  name: my-stateless-lb-gateway-3
spec:
  gatewayClassName: l-3-4-gateway-api-poc/stateless-load-balancer
  listeners:
  - name: all # This is ignored as KPNG does not undertand these
    port: 4000
    protocol: TCP
  infrastructure:
    annotations: 
      k8s.v1.cni.cncf.io/networks: '[{"name":"vlan-300","interface":"vlan-300"},{"name":"macvlan-nad-3","interface":"net3"}]' # Networks attached to the gateway workloads
      l-3-4-gateway-api-poc/networks: '[{"name":"macvlan-nad-3","interface":"net3"}]' # Networks towards the service selected pods
---
apiVersion: l34.gateway.api.poc/v1alpha1
kind: GatewayRouter
metadata:
  name: gateway-b-v4-3
  labels:
    service.kubernetes.io/service-proxy-name: my-stateless-lb-gateway-3
spec:
  address: 169.254.100.150
  interface: vlan-300
  bgp:
    localASN: 8103
    remoteASN: 4248829953
    holdTime: 24s
    localPort: 10179
    remotePort: 10179
    bfd:
      switch: true
      minTx: 300ms
      minRx: 300ms
      multiplier: 5
---
apiVersion: l34.gateway.api.poc/v1alpha1
kind: L34Route
metadata:
  name: vip-20-0-0-1-port-4000-3
spec:
  parentRefs:
  - name: my-stateless-lb-gateway-3
  backendRefs:
  - name: service-b-3
    port: 4000 # This is ignored
  priority: 1
  destinationCIDRs:
  - 20.0.0.1/32
  sourceCIDRs:
  - 0.0.0.0/0
  sourcePorts:
  - 0-65535
  destinationPorts:
  - "4000"
  protocols:
  - TCP
---
apiVersion: v1
kind: Service
metadata:
  name: service-b-3
  labels:
    service.kubernetes.io/service-proxy-name: my-stateless-lb-gateway-3
spec:
  clusterIP: None
  selector:
    app: e
    l-3-4-gateway-api-poc/dummy-service-selector: "true"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment