apiVersion: apps/v1
kind: Deployment
metadata:
  name: vegeta-controller
spec:
  replicas: 4
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 1
  selector:
    matchLabels:
      app: vegeta-controller
  template:
    metadata:
      labels:
        app: vegeta-controller
    spec:
      serviceAccountName: vegeta-controller
      securityContext:
        sysctls:
          # https://github.com/kubernetes/kubernetes/pull/54896
          #- name: net.core.somaxconn
          #  value: "65535"
          - name: net.ipv4.ip_local_port_range
            value: "10000 65535"
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - podAffinityTerm:
                labelSelector:
                  matchExpressions:
                    - key: app
                      operator: In
                      values:
                        - vegeta-controller
                topologyKey: kubernetes.io/hostname
              weight: 100
      containers:
        - name: controller
          image: ghcr.io/kaidotdev/vegeta-controller:v0.3.4
          imagePullPolicy: Always
          args:
            - --metrics-addr=0.0.0.0:8080
            - --enable-leader-election
            - --vegeta-image=peterevans/vegeta:6.7
          ports:
            - containerPort: 8080
