{"id":3213,"date":"2021-10-07T13:09:09","date_gmt":"2021-10-07T12:09:09","guid":{"rendered":"https:\/\/inlab.fib.upc.edu\/?p=3213"},"modified":"2023-05-24T09:21:45","modified_gmt":"2023-05-24T08:21:45","slug":"runners-2","status":"publish","type":"post","link":"https:\/\/inlab.fib.upc.edu\/es\/noticias\/runners-2","title":{"rendered":"Runners"},"content":{"rendered":"<p class=\"rtejustify\"><strong style=\"font-size: 13px;\">Gitlab&nbsp;CI\/CD<\/strong><span style=\"font-size: 13px;\"> es una herramienta de&nbsp;DevOps&nbsp;integrada en&nbsp;Gitlab&nbsp;para poder hacer integraci\u00f3n continua, entrega continua y desarrollo continuo. Para poder utilizar esta herramienta se han de usar los&nbsp;Gitlab&nbsp;Runners, los cuales son unas aplicaciones que se encargan de ejecutar los trabajos de los pipelines de&nbsp;Gitlab&nbsp;CI\/CD.<\/span><\/p>\n<p class=\"rtejustify\">Aunque los servidores de&nbsp;Gitlab&nbsp;pueden tener&nbsp;Runners&nbsp;compartidos que puede utilizar cualquier usuario, nos puede interesar tener uno o m\u00e1s&nbsp;Runners&nbsp;en nuestra propia m\u00e1quina. En este art\u00edculo explicaremos c\u00f3mo puede hacerse de forma r\u00e1pida y sencilla.<\/p>\n<h2 class=\"rtejustify\"><strong>Instalaci\u00f3n usando contenedores Docker&nbsp;<\/strong><\/h2>\n<p class=\"rtejustify\">Existen m\u00faltiples maneras de instalar un&nbsp;Runner&nbsp;en una m\u00e1quina, pero la forma m\u00e1s flexible y la que explicaremos en este art\u00edculo es utilizando contenedores Docker.<\/p>\n<p class=\"rtejustify\">Los requisitos para poder instalar y utilizar un&nbsp;Runner&nbsp;con Docker son los siguientes:<\/p>\n<ul>\n<li class=\"rtejustify\">Tener una m\u00e1quina con Docker instalado y entender su funcionamiento b\u00e1sico<\/li>\n<li class=\"rtejustify\">Tener un&nbsp;<strong>token<\/strong>&nbsp;de registro de&nbsp;Runners&nbsp;en un grupo o proyecto de&nbsp;Gitlab<\/li>\n<\/ul>\n<p class=\"rtejustify\">Para obtener el&nbsp;<strong>token<\/strong>&nbsp;de registro \u00fanicamente hay que ir al grupo o proyecto donde queramos registrar&nbsp;Runner&nbsp;y acceder a \u00ab<strong>Settings&nbsp;-&gt; CI\/CD -&gt; Runners<\/strong>\u00ab. Es importante que el&nbsp;<strong>token<\/strong> se mantenga en secreto, ya que utilizando este&nbsp;token&nbsp;cualquier persona puede registrar un&nbsp;Runner&nbsp;en su proyecto y potencialmente obtener acceso a los archivos. En caso de que se filtre, pulse el bot\u00f3n \u00ab<strong>Reset&nbsp;registration&nbsp;token<\/strong>\u00bb para obtener uno nuevo.<\/p>\n<p class=\"rtejustify\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<img fetchpriority=\"high\" decoding=\"async\" class=\" size-full wp-image-3174\" alt=\"\" src=\"https:\/\/inlab.fib.upc.edu\/wp-content\/uploads\/2021\/10\/runner-1.png\" style=\"width: 715px; height: 486px;\" width=\"715\" height=\"486\" srcset=\"https:\/\/inlab.fib.upc.edu\/wp-content\/uploads\/2021\/10\/runner-1.png 715w, https:\/\/inlab.fib.upc.edu\/wp-content\/uploads\/2021\/10\/runner-1-300x204.png 300w, https:\/\/inlab.fib.upc.edu\/wp-content\/uploads\/2021\/10\/runner-1-370x251.png 370w\" sizes=\"(max-width: 715px) 100vw, 715px\" \/><\/p>\n<p class=\"rtejustify\">Una vez obtenido el&nbsp;token&nbsp;de registro hay que crear el contenedor que se encargar\u00e1 de ejecutar los&nbsp;Runners. Para ello hay que ejecutar los siguientes comandos con permisos de administrador:<\/p>\n<pre class=\"rtejustify\">\r\ndocker volume create gitlab-runner-config\r\ndocker run -d --name gitlab-runner --restart always \\\r\n    -v \/var\/run\/docker.sock:\/var\/run\/docker.sock \\\r\n    -v gitlab-runner-config:\/etc\/gitlab-runner \\\r\n    gitlab\/gitlab-runner:latest\r\n<\/pre>\n<p class=\"rtejustify\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <img decoding=\"async\" class=\" size-full wp-image-3177\" alt=\"\" src=\"https:\/\/inlab.fib.upc.edu\/wp-content\/uploads\/2021\/10\/runner-2.png\" style=\"width: 713px; height: 273px;\" width=\"713\" height=\"273\" srcset=\"https:\/\/inlab.fib.upc.edu\/wp-content\/uploads\/2021\/10\/runner-2.png 713w, https:\/\/inlab.fib.upc.edu\/wp-content\/uploads\/2021\/10\/runner-2-300x115.png 300w, https:\/\/inlab.fib.upc.edu\/wp-content\/uploads\/2021\/10\/runner-2-370x142.png 370w\" sizes=\"(max-width: 713px) 100vw, 713px\" \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<\/p>\n<p class=\"rtejustify\">El siguiente paso es registrar un&nbsp;Runner para que ejecute&nbsp;nuestras pipelines. Esto se puede hacer ejecutando el siguiente comando y suministrar los datos que pide:<\/p>\n<pre class=\"rtejustify\">\r\ndocker run --rm -it -v gitlab-runner-config:\/etc\/gitlab-runner \r\ngitlab\/gitlab-runner:latest register \r\n<\/pre>\n<p class=\"rtejustify\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<img decoding=\"async\" class=\" size-full wp-image-3180\" alt=\"\" src=\"https:\/\/inlab.fib.upc.edu\/wp-content\/uploads\/2021\/10\/runner-3.png\" style=\"text-align: justify; width: 823px; height: 236px;\" width=\"823\" height=\"236\" srcset=\"https:\/\/inlab.fib.upc.edu\/wp-content\/uploads\/2021\/10\/runner-3.png 823w, https:\/\/inlab.fib.upc.edu\/wp-content\/uploads\/2021\/10\/runner-3-300x86.png 300w, https:\/\/inlab.fib.upc.edu\/wp-content\/uploads\/2021\/10\/runner-3-768x220.png 768w, https:\/\/inlab.fib.upc.edu\/wp-content\/uploads\/2021\/10\/runner-3-370x106.png 370w\" sizes=\"(max-width: 823px) 100vw, 823px\" \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<\/p>\n<p class=\"rtejustify\">Ya para terminar, hay que ir a&nbsp;Settings, CI\/CD,&nbsp;Runners&nbsp;y mirar si el&nbsp;Runner&nbsp;aparece en la secci\u00f3n \u00abAvailable&nbsp;specific&nbsp;runners\u00bb.<\/p>\n<p class=\"rtejustify\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-3183\" alt=\"\" src=\"https:\/\/inlab.fib.upc.edu\/wp-content\/uploads\/2021\/10\/runner-4.png\" style=\"width: 557px; height: 149px;\" width=\"557\" height=\"149\" srcset=\"https:\/\/inlab.fib.upc.edu\/wp-content\/uploads\/2021\/10\/runner-4.png 557w, https:\/\/inlab.fib.upc.edu\/wp-content\/uploads\/2021\/10\/runner-4-300x80.png 300w, https:\/\/inlab.fib.upc.edu\/wp-content\/uploads\/2021\/10\/runner-4-370x99.png 370w\" sizes=\"(max-width: 557px) 100vw, 557px\" \/><\/p>\n<p class=\"rtejustify\">Si aparece es que todo ha ido bien y ya lo podemos utilizar para ejecutar&nbsp;nuestras pipelines. En caso de que haga falta tener m\u00e1s&nbsp;Runners&nbsp;solamente&nbsp;hay que repetir el comando utilizado para registrar uno nuevo.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Gitlab&nbsp;CI\/CD es una herramienta de&nbsp;DevOps&nbsp;integrada en&nbsp;Gitlab&nbsp;para poder hacer integraci\u00f3n continua, entrega continua y desarrollo continuo. Para poder utilizar esta herramienta se han de usar los&nbsp;Gitlab&nbsp;Runners, los cuales son unas aplicaciones que se encargan de ejecutar los trabajos de los pipelines de&nbsp;Gitlab&nbsp;CI\/CD. Aunque los servidores de&nbsp;Gitlab&nbsp;pueden tener&nbsp;Runners&nbsp;compartidos que puede utilizar cualquier usuario, nos puede interesar tener [&hellip;]<\/p>\n","protected":false},"author":594,"featured_media":3171,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[495],"tags":[],"experteses":[],"class_list":["post-3213","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-noticias"],"acf":[],"_links":{"self":[{"href":"https:\/\/inlab.fib.upc.edu\/es\/wp-json\/wp\/v2\/posts\/3213","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/inlab.fib.upc.edu\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/inlab.fib.upc.edu\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/inlab.fib.upc.edu\/es\/wp-json\/wp\/v2\/users\/594"}],"replies":[{"embeddable":true,"href":"https:\/\/inlab.fib.upc.edu\/es\/wp-json\/wp\/v2\/comments?post=3213"}],"version-history":[{"count":1,"href":"https:\/\/inlab.fib.upc.edu\/es\/wp-json\/wp\/v2\/posts\/3213\/revisions"}],"predecessor-version":[{"id":20843,"href":"https:\/\/inlab.fib.upc.edu\/es\/wp-json\/wp\/v2\/posts\/3213\/revisions\/20843"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/inlab.fib.upc.edu\/es\/wp-json\/wp\/v2\/media\/3171"}],"wp:attachment":[{"href":"https:\/\/inlab.fib.upc.edu\/es\/wp-json\/wp\/v2\/media?parent=3213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/inlab.fib.upc.edu\/es\/wp-json\/wp\/v2\/categories?post=3213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/inlab.fib.upc.edu\/es\/wp-json\/wp\/v2\/tags?post=3213"},{"taxonomy":"experteses","embeddable":true,"href":"https:\/\/inlab.fib.upc.edu\/es\/wp-json\/wp\/v2\/experteses?post=3213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}