Despliegue de Boinc en K8S

por | agosto 8, 2020

Cuando comencé a contribuir al proyecto WCG lo hice primero con máquinas virtuales (KVM) para pasar posteriormente a contenedores orquestados con Docker Swarm y finalmente el último cambio que he hecho ha sido pasar el proyecto a un clúster de K8S, aprovechando la infraestructura que monté con Kubespray.

En primer lugar he creado un namespace dedicado para los agentes Boinc:

[root@srvk8s1 deployments]# kubectl create namespace boinc
namespace/boinc created
[root@srvk8s1 deployments]# kubectl get namespaces
NAME                   STATUS   AGE
boinc                  Active   2s
default                Active   169d
kube-node-lease        Active   169d
kube-public            Active   169d
kube-system            Active   169d
kubernetes-dashboard   Active   169d

Posteriormente creamos el fichero de despliegue boinc_client.yaml. En mi caso he creado 3 réplicas, utilizando la imagen disponible en Docker Hub. Tenemos que pasarle al contenedor la variable con la clave de proyecto para que conecte con la web de WCG y empiece a trabajar en los proyectos a los que nos hemos suscrito:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: boinc-deployment
  labels:
    app: boinc
spec:
  replicas: 3
  selector:
    matchLabels:
      app: boinc
  template:
    metadata:
      labels:
        app: boinc
    spec:
      containers:
      - name: boinc
        image: boinc/client
        env:
        - name: BOINC_CMD_LINE_OPTIONS
          value: "--attach_project http://www.worldcommunitygrid.org <KEY>"

Desplegamos:

[root@srvk8s1 deployments]# kubectl apply -f boinc_client.yaml 
deployment.apps/boinc-deployment created

Comprobamos que los PODS estén corriendo:

[root@srvk8s1 deployments]# kubectl get pods
NAME                                READY   STATUS    RESTARTS   AGE
boinc-deployment-7b5469b87d-pq57l   1/1     Running   0          16s
boinc-deployment-7b5469b87d-rhb22   1/1     Running   0          16s
boinc-deployment-7b5469b87d-tfgsc   1/1     Running   0          16s

Podemos ver detalles de los PODS, por ejemplo:

[root@srvk8s1 ~]# kubectl describe pod boinc-deployment-7b5469b87d-pq57l
Name:         boinc-deployment-7b5469b87d-pq57l
Namespace:    default
Priority:     0
Node:         srvk8s3/192.168.1.103
Start Time:   Wed, 13 May 2020 19:49:40 +0200
Labels:       app=boinc
              pod-template-hash=7b5469b87d
Annotations:  <none>
Status:       Running
IP:           10.233.102.53
IPs:
  IP:           10.233.102.53
Controlled By:  ReplicaSet/boinc-deployment-7b5469b87d
Containers:
  boinc:
    Container ID:   docker://bc578e4b740f574d59b84cb7e06453a4fc8adf19cd106e750721e42327dd2cfe
    Image:          boinc/client
    Image ID:       docker-pullable://boinc/client@sha256:3fd53a8f7196f5b8a7787c22364136cdc537774ded5f7084fefde9a03f8dc7e5
    Port:           <none>
    Host Port:      <none>
    State:          Running
      Started:      Mon, 06 Jul 2020 19:20:18 +0200
    Last State:     Terminated
      Reason:       Error
      Exit Code:    137
      Started:      Wed, 13 May 2020 19:49:50 +0200
      Finished:     Wed, 13 May 2020 21:49:33 +0200
    Ready:          True
    Restart Count:  1
    Environment:
      BOINC_CMD_LINE_OPTIONS:  --attach_project http://www.worldcommunitygrid.org ********
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-wdjg8 (ro)

Y también revisar cómo van procesando tareas:

[root@srvk8s1 ~]# kubectl logs -f boinc-deployment-7b5469b87d-pq57l
13-May-2020 19:50:01 [---] cc_config.xml not found - using defaults
13-May-2020 19:50:01 [---] Starting BOINC client version 7.17.0 for x86_64-pc-linux-gnu
13-May-2020 19:50:01 [---] Libraries: libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3
13-May-2020 19:50:01 [---] Data directory: /var/lib/boinc
13-May-2020 19:50:01 [---] No usable GPUs found
13-May-2020 19:50:01 [---] Creating new client state file
13-May-2020 19:50:01 [---] libc: Ubuntu GLIBC 2.31-0ubuntu9 version 2.31
13-May-2020 19:50:01 [---] Host name: boinc-deployment-7b5469b87d-pq57l
13-May-2020 19:50:01 [---] Processor: 1 GenuineIntel Westmere E56xx/L56xx/X56xx (Nehalem-C) [Family 6 Model 44 Stepping 1]
13-May-2020 19:50:01 [---] Processor features: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm constant_tsc rep_good nopl xtopology eagerfpu pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 x2apic popcnt aes hypervisor lahf_lm arat
13-May-2020 19:50:01 [---] OS: Linux Ubuntu: Ubuntu 20.04 LTS [3.10.0-957.21.3.el7.x86_64|libc 2.31 (Ubuntu GLIBC 2.31-0ubuntu9)]
13-May-2020 19:50:01 [---] Memory: 3.86 GB physical, 0 bytes virtual
13-May-2020 19:50:01 [---] Disk: 24.99 GB total, 19.46 GB free
...

Con esto ya tendríamos nuestros agentes Boinc desplegados en K8S, con toda la flexibilidad y escalabilidad que nos aporta el orquestador.