-
Notifications
You must be signed in to change notification settings - Fork 2
Running a Pod
We first must define all the parameters for our pod. We will use this minimalist example. There are many more optional parameters that you may be interested in depending on your compute needs. The full API documentation is here
The YAML we will use for basic Pod creation is shown below. This is identical to the sample YAML in the repo here.
apiVersion: v1
kind: Pod
metadata:
name: pod-name-sso # YOUR POD NAME HERE
spec:
containers:
- name: pod-name-sso # YOUR CONTAINER NAME HERE
image: ubuntu:20.04
command: ["sh", "-c", "echo 'Im a new pod' && sleep infinity"]
resources:
limits:
memory: 12Gi
cpu: 2
requests:
memory: 10Gi
cpu: 2We will now walk through each line/section to understand what we are specifying to Kubernetes:
apiVersion: v1The version of the Kubernetes API that we are using.
kind: PodSpecify the kind of resource we want to create. In this case, a pod
metadata:
name: pod-name-ssoThe metadata of the Pod. In this minimalist example, we specify only a name. Note that this must be unique in the namespace
spec:
containers:We are specifying what we need (spec), and our first set of needs is containers
- name: pod-name-sso # YOUR CONTAINER NAME HERE
image: ubuntu:20.04
command: ["sh", "-c", "echo 'Im a new pod' && sleep infinity"]
Here we are defining the basic paramters of our first (and only) container:
-
name: The name of the container, this can be the same as the pod or it can be different. In cases with multiple containers, this needs to be unique. -
image: Which docker image to load into the container. This must be publically accessible, either in Docker Hub or a public facing container registry -
command: The command to run when the pod starts. This should almost always besleep infinity
resources:
limits:
memory: 12Gi
cpu: 2
requests:
memory: 10Gi
cpu: 2We are defining the resources for the container, in two steps. The first is the limit, i.e., the highest amount of resources that should be made available. The second is the requested amount of resources.
Note: The pod will not be scheduled on a node (i.e., will not be created) until your requests are met, so do not specify too many resources.
Note: The max amount of resources for a pod is 12 GB of RAM and 2 CPU cores (and 2 NVIDIA GPUs). Any more, and you will receive an error. If you need more resources than that, you will need to create a job.
Once you have your YAML spec created, you can create your pod using the kubectl apply or kubectl create commands:
kubectl create -f MYFILE.ymlNote: Creation of a Pod will take time. It is not instantaneous. You can use kubectl get pods to check when your pod is running
For a running pod, you can attach to the pod using the kubectl exec command:
kubectl exec -it MYPOD -- /bin/bashFrom here, you can perform any/all compute that you need. Be sure to save any artifacts to your persistent volume or to copy it to your local machine with kubectl cp
Once you have finished using your pod and copied all necessary data from the local pod storage, delete the pod:
kubectl delete pod MYPODNote: On the Nautilus cluster, pods are automatically deleted 6 hours after creation. If you need longer running compute than that, you will need to use a job.
Docker
Nautilus Basics
Nautilus Advanced Usage
Jupyter