# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

kind: DaemonSet
apiVersion: apps/v1
metadata:
  name: drop-small-mss
  namespace: kube-system
  labels:
    app: drop-small-mss
spec:
  selector:
    matchLabels:
      app: drop-small-mss
  template:
    metadata:
      labels:
        app: drop-small-mss
      annotations:
        scheduler.alpha.kubernetes.io/critical-pod: ""
    spec:
      hostPID: true
      containers:
      - name: drop-small-mss
        image: k8s.gcr.io/startup-script:v2
        imagePullPolicy: Always
        securityContext:
          privileged: true
        env:
        - name: STARTUP_SCRIPT
          value: |
            #! /bin/bash

            set -o errexit
            set -o pipefail
            set -o nounset

            iptables -w -t mangle -I PREROUTING -m comment --comment "drop-small-mss" -p tcp -m tcpmss --mss 1:500 -j DROP
      priorityClassName: system-node-critical
      tolerations:
      - operator: Exists
