---
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
  name: bridge-static
spec:
  config: |
    {
      "cniVersion": "0.3.1",
      "name": "bridge-static",
      "plugins": [
        {
          "type": "bridge",
          "bridge": "testbr0",
          "ipam": {
            "type": "static",
            "addresses": [
              {
                "address": "10.0.183.229/20",
                "gateway": "10.0.176.1"
              }
            ]
          }
        },
        {
          "type": "custom-route"
        }
      ]
    }
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      annotations:
        k8s.v1.cni.cncf.io/networks: '[{ "name": "bridge-static", "interface": "mv0", "default-route": ["10.0.176.1"] }]'
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80
        volumeMounts:
        - name: html
          mountPath: /usr/share/nginx/html
      - name: utility
        command: ["/bin/ash", "-c", "trap : TERM INT; sleep infinity & wait"]
        image: nicolaka/netshoot
        securityContext:
          capabilities:
            add:
            - NET_ADMIN
            - NET_RAW
      volumes:
      - name: html
        configMap:
          name: nginx-html

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-html
data:
  index.html: |
    <!DOCTYPE html>
    <html>
    <head>
        <title>Hello World</title>
    </head>
    <body>
        <h1>Hello, World!</h1>
    </body>
    </html>
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
  type: ClusterIP
