-2

I have a builder image / container which is supposed to run tests on a directory with tests sources.

The container is run in a Kubernetes pod, in AWS EKS, through helm test. I.e. not docker, so I can't simply use -v volume mount.

I am struggling to find the right way to bring this directory to the container, in a simple way. This is a Helm template I have. All works except for the volume.

apiVersion: v1
kind: Pod
metadata:
  name: "{{ .Release.Name }}-gatling-test"
  annotations:
    "helm.sh/hook": test-success
spec:
  restartPolicy: Never
  containers:
  - name: {{ .Release.Name }}-gatling-test
    image: {{ .Values.builderImage }}
    command: ["sh", "-c", 'mvn -B gatling:test -pl csa-testing -DCSA_SERVER={{ template "project.fullname" . }} -DCSA_PORT={{ .Values.service.appPort }}']
    ## TODO: The builder image also counts with having /tmp/build, so it needs a mount: -v '${job.WORKDIR}:/tmp/build'
    volumeMounts:
    - name: mavenRepoToBuild
      mountPath: /tmp/build
    volumes:
    - name: mavenRepoToBuild
      hostPath:
        path: {{.Values.fromJenkins.WORKDIR}}

I've read on few places that it can't be done directly. So what's the easy way to do it indirectly? Zip and upload to S3 and download? Or add it to the image as a layer? Or should I create a Kubernetes volume resource?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277
  • Have you looked at Configmaps? They might fit your need: https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#create-configmaps-from-directories – Winston RIley May 11 '18 at 20:52
  • Sure, `ConfigMap` is good, but I need to deliver a whole Git repo to the test container. – Ondra Žižka May 12 '18 at 03:52
  • Is this a clean state git repository you need? Would it be possible to clone it within your pod? – embik May 12 '18 at 16:18
  • I could clone it but I would need to distribute and set up the keys. So I am back the the same problem I think. Also. I need to transfer the test results back. – Ondra Žižka May 15 '18 at 11:05

1 Answers1

0

The hostPath directory or file must be existing on all your cluster nodes.

You can attach some types on the hostPath to determine whether its files or directories.

List of types you can use on hostpath can be found in kubernetes documentation.

https://kubernetes.io/docs/concepts/storage/volumes/

Btw, what error do you get? Permission denied? You can do helm dry-run to see the rendered template.

Bal Chua
  • 1,134
  • 9
  • 10