apiVersion: v1
kind: Pod
metadata:
  name: persisten-maven-build-env
spec:
    containers: # Container definition inside of the Pod
    - name: maven # Name of the Container
      image: maven:latest # Image of the Container
      imagePullPolicy: Always # Always pull Build Container because there might be updates
      command: [ "/bin/bash" ] # Execute Bash
      args: ["-c", 'run=1; while true; do echo "This is the $run run and I am still alive."; run=$((run+1)); sleep 3; done'] # A simple keepalive script to prevent the container from beeing closed and restarted.
      securityContext:
        runAsUser: 0 # Container will be run as user root (otherwise change user id)
      volumeMounts: # Defines Mount points for a specific container
          - name: m2-data # Mounts the persistent Maven Storage
            mountPath: /root/.m2 # mount Endpoint in the Container
          - name: docker-socket # Mounts the Docker Socket inside of the Container
            mountPath: /var/run/docker.sock
    volumes: # Defines Volumes
        - name: m2-data # Defines the volume for persisten maven Storage
          persistentVolumeClaim:
            claimName: build-dependencie-volume-claim
        - name: docker-socket # Creates a Share wich enable Docker Socket in the Container
          hostPath:
            path: /var/run/docker.sock # Path to Docker Socket
            type: Socket # Type Socket