apiVersion: v1
kind: Pod
metadata:
  name: jenkins-slave-pod
  labels:
    slave-agent: jenkins
spec:
#  nodeSelector:
#    kubernetes.io/hostname: k8snodestf-worker-0
  affinity:
    podAntiAffinity:
      preferredDuringSchedulingIgnoredDuringExecution:
      - weight: 50
        podAffinityTerm:
          labelSelector:
            matchExpressions:
            - key: slave-agent
              operator: In
              values:
              - jenkins
          topologyKey: "kubernetes.io/hostname"
  hostNetwork: true
  dnsPolicy: ClusterFirstWithHostNet
  containers:
  - name: jenkins-slave-container
    image: demo4echo/alpine_openjdk8_k8scdk
#    image: demo4echo/ubuntu_k8scdk
    imagePullPolicy: Always
    command:
    - cat
    tty: true
    env:
    - name: CONTAINER_NAME_ENV_VAR
      valueFrom:
         fieldRef:
           fieldPath: metadata.name
    - name: NODE_HOST_NAME_ENV_VAR
      valueFrom:
        fieldRef:
          fieldPath: spec.nodeName
    volumeMounts:
    - name: docker-socket
      mountPath: /var/run/docker.sock
    - name: gradle-cache-vol
      mountPath: /root/.gradle
    - name: helm-cache-vol
      mountPath: /root/.helm
  volumes:
  - name: docker-socket
    hostPath:
      path: /var/run/docker.sock
  - name: gradle-cache-vol
    hostPath:
      path: /root/.gradle
  - name: helm-cache-vol
    hostPath:
      path: /root/.helm
