container fails after executing command: [wget url]

5/13/2020

i'm trying to download gzip file from a remote location, after download is complete the container Status changes to Completed then CrashLoopBackOff. the image below shows results of kubectl log my-service and kubectl describe pod my-service displays CrashLoopBackOff restarting failed container.

so i want this wget command to get executed during container initialization so i can gunzip and have the files accessed in a mounted volume. but this fails at container initialization

enter image description here

      containers:
      - name: my-service
        image: docker.source.co.za/azp/my-service:1.0.0-SNAPSHOT
        imagePullPolicy: Always
        command:
          - wget
          - http://www.source.co.za/download/attachments/627674073/refpolicies.tar.gz
        volumeMounts:
        - name: my-service
          mountPath: /test/
      volumes:
      - name: my-service
        emptyDir: {}
-- muzi jack
containers
kubectl
kubernetes
pod

1 Answer

5/13/2020

The container stops after the command is executed. Kubernetes expects the container to run forever.

You can configure as below to achieve the same

command: ["/bin/sh","-c"]
args: ["wget url && sleep infinity"]

sleep infinity makes the container run forever doing nothing.

-- Tummala Dhanvi
Source: StackOverflow