Kubernetes notes

A simple collection of notes from my explorations of Kubeflow cluster.

Kubernetes debug and data transfer pod (06/15/2021)

I could not make kubectl cp work to transfer some files from my pod molbartpytorch2-0 running docker image pytorch:1.8.0-cuda11.1-cudnn8-devel-rdkit2 to my local machine. It must be some problem with tar in the docker image, kubectl cp always throwing error: archive/tar: invalid tar header.

So I decided a workaround. I deployed a container ubuntu-pvc running ubuntu docker image that mounts the persistent volume claim named deepchem2 (also mounted and used by molbartpytorch2-0) that sleeps for a year. The sleep is necessary to make sure the container keeps on running and does not exit immediately.

The yaml file ubuntupvc.yaml to deplying thepod running ubuntu is given below:

apiVersion: v1
kind: Pod
metadata:
  name: ubuntu-pvc
  labels:
    app: ubuntu-pvc
spec:
  volumes:
    - name: deepchem2
      persistentVolumeClaim:
        claimName: deepchem2
  containers:
  - name: ubuntu-pvc
    image: ubuntu:latest
    volumeMounts:
      - mountPath: "/storage"
        name: deepchem2
    command: ["/bin/sleep", "3650d"]
    imagePullPolicy: IfNotPresent
  restartPolicy: Always

Just to kubectl apply -f ubuntupvc.yaml to deploy the ubuntu container.

Then kubectl get pod ubuntu-pvc shows

NAME READY STATUS RESTARTS AGE
ubuntu-pvc 1/1 Running 0 3m

Once the pod is running, kubectl exec ubuntu-pvc -- ls /storage/ showed me that the persistent volume claim deepchem2 is mounted at /storage. Also I could have checked it my first getting a terminal to the container using kubectl exec --tty --stdin ubuntu-pvc -- /bin/bash

Now to copy my required files from /storage/data to folder mydata, I do: kubectl cp ubuntu-pvc:storage/data mydata. This works!!

Written on June 20, 2021