Skip to content

EPFL-IC/caas

Repository files navigation

Kubernetes

Step Zero: Prerequisites

  1. Clone this repo
  2. Request an account to the support (support-icit@epfl.ch)
  3. If you plan to use a shared storage, request a volume to the support
  4. Install and Set Up kubectl - https://kubernetes.io/docs/tasks/tools/install-kubectl/
  5. Check if you setup works correctly
$ kubectl get pods     
No resources found

Step One: Create your first Pod (Container)

$ kubectl create -f ubuntu.yaml     
pod "ubuntu" created

Now list all pods running:

$ kubectl get pods
NAME      READY     STATUS    RESTARTS   AGE
ubuntu    1/1       Running   0          13s

You can log in to your pod

$ kubectl exec -it ubuntu -- /bin/bash
root@ubuntu:/# exit
exit

Step Two: Using a shared storage across Pods

  1. Request a volume to the support (support-icit@epfl.ch)

  2. Create the Pods

    1.1. Change the values for the name and the label in yaml files

    1.2. Change the value for the "claimName" with the name provided by the support

    1.3. You can also change settings like the root password with the environment variables in the yaml file for mysql pod

  3. Create a nginx pod

$ kubectl create  -f pod-nginx.yaml
pod "caperez-pod-nginx" created

In this example, the sub folder "nginx" from the shared volume will be mounted /usr/share/nginx/html in the pod

Create a mysql pod

$ kubectl create -f pod-mysql.yaml
pod "caperez-pod-mysql" created

The sub folder "mysql" from the shared volume will be mounted /var/lib/mysql in the pod

Create a ubuntu pod to check the two folders

$ kubectl create -f pod-ubuntu-pvc.yaml
Error from server (AlreadyExists): error when creating "ubuntu.yaml": object is being deleted: pods "ubuntu" already exists

In this case, the ubuntu pod already exist. Suppress it, wait a while and try again.

$ kubectl delete -f ubuntu.yaml
pod "ubuntu" deleted
.... 
$ kubectl create -f pod-ubuntu-pvc.yaml
pod "ubuntu" created

$ kubectl exec -it ubuntu -- /bin/bash
root@ubuntu:/# ls -l /shared_volume
total 8
drwxr-xr-x 5  999  999 4096 Sep 26 11:33 mysql
drwxr-xr-x 2 root root 4096 Sep 26 11:32 nginx
root@ubuntu:/# 

We can see the two folders. The pod mounted the shared volume in /shared_volume (without sub folder)

Step Three: Accessing Pods from Outside of the Cluster

Create a service Load Balancer to access the nginx pod from outside the cluster

$ kubectl create -f svc-nginx.yaml
service "caperez-svc-nginx" created

The match between your service and the pod is done by the selector > name in the yaml file

$ kubectl get svc          
NAME                CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
caperez-svc-nginx   10.97.55.231   <pending>     80:31804/TCP   41s

In this example, the service is running on port 31804

Check the host where the service is running

$ kubectl get pod caperez-pod-nginx -o yaml | grep hostIP
 hostIP: 10.xx.yy.z

$ curl -v http://10.xx.yy.z:31804
* Rebuilt URL to: http://10.xx.yy.z:31804/
*   Trying 10.xx.yy.z...
......
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
...... 

Step Four: Using GPUs inside Pods

$ kubectl create -f pod-ubuntu-gpu.yaml 
pod "ubuntu-gpu" created

$ kubectl exec -it ubuntu-gpu -- /bin/bash
root@ubuntu-gpu:/# nvidia-smi                                                                                                                                         
Tue Sep 26 14:00:03 2017       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 375.66                 Driver Version: 375.66                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX TIT...  Off  | 0000:04:00.0     Off |                  N/A |
|  0%   38C    P0    52W / 250W |      0MiB / 12207MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID  Type  Process name                               Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+
root@ubuntu-gpu:/# 

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published