apiVersion: apps/v1
kind: Deployment
metadata:
  name: test-nodeX
  labels:
    app: multi-node-test
spec:
  replicas: 1
  selector:
    matchLabels:
      host: test-nodeX
  template:
    metadata:
      labels:
        host: test-nodeX
    spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 100
              podAffinityTerm:
                labelSelector:
                  matchExpressions:
                    - key: app
                      operator: In
                      values:
                        - multi-node-test
                topologyKey: kubernetes.io/hostname
      containers:
      - image: openjdk:11
        command: ["sleep", "infinity"]
        resources:
          requests:
            memory: "3Gi"
            cpu: "2800m"
          limits:
            memory: "3Gi"
        lifecycle:
          postStart:
            exec:
              command:
                - /bin/sh
                - -c
                - truncate --size -1 /etc/hosts && echo " test-nodeX" >> /etc/hosts
        imagePullPolicy: Always
        name: multi-test-nodeX
        volumeMounts:
          - mountPath: /opt/volumes/media-driver
            name: media-driver
        ports:
        - name: web
          containerPort: 80
          protocol: TCP
        - name: ssh
          containerPort: 22
          protocol: TCP
        - name: multi-node
          containerPort: 5000
          protocol: TCP
        - name: multi-node2
          containerPort: 5001
          protocol: TCP
        - name: multi-node-udp
          containerPort: 6000
          protocol: UDP
        - name: multi-node-udp2
          containerPort: 6001
          protocol: UDP
        - name: server-multi
          containerPort: 4711
          protocol: TCP
      volumes:
        # Needed for Aeron tests: https://github.com/real-logic/aeron/blob/master/README.md#troubleshooting
        - name: media-driver
          emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
  name: test-nodeX
  labels:
    app: multi-node-test
spec:
  selector:
    host: test-nodeX
  ports:
    - protocol: TCP
      name: ssh
      port: 22
      targetPort: 22
    - protocol: TCP
      name: server-multi
      port: 4711
      targetPort: 4711
    - protocol: TCP
      name: multi-node
      port: 5000
      targetPort: 5000
    - protocol: TCP
      name: multi-node2
      port: 5001
      targetPort: 5001
    - protocol: UDP
      name: multi-node-udp
      port: 6000
      targetPort: 6000
    - protocol: UDP
      name: multi-node-udp2
      port: 6001
      targetPort: 6001
