{"id":28909,"date":"2023-10-30T17:05:43","date_gmt":"2023-10-30T16:05:43","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/?p=28909"},"modified":"2023-10-30T17:05:43","modified_gmt":"2023-10-30T16:05:43","slug":"share-gitlab-agent-to-deploy-microservices-projects","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/share-gitlab-agent-to-deploy-microservices-projects\/","title":{"rendered":"Share Gitlab agent to deploy microservices projects"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In a microservice application, the code for each service has its own git repository. However, how do deploy without duplicating the Gitlab agents ?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In Gitlab, you can share an agent between several projects to deploy the application on a Kubernetes cluster !<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-define-and-configure-the-main-project\">Define and configure the main project<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The main project contains the agent for deploying the application. It installs in the usual way, without any difference. To declare the agent, see the article: <a href=\"https:\/\/www.dbi-services.com\/blog\/connect-a-kubernetes-cluster-to-gitlab\/\">Connect a Kubernetes cluster to GitLab<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To authorize other projects to access the agent, you must configure the main project:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In the project repository, create a folder .gitlab\/agents<\/li>\n\n\n\n<li>In .gitlab\/agents, add a directory with the same name as the agent you want to share. (You can see the list of agents in Operate &gt; Kubernetes Cluster)<\/li>\n\n\n\n<li>In the previous folder, create a file named config.yaml<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-the-config-yaml-file\">The config.yaml file<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To allow access to a <strong>group<\/strong> of project, add this configuration into the config.yaml:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ci_access:\n  groups:\n    - id: path\/to\/my_group<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">With this code, all the projects into my_group can use the agent to deploy into the Kubernetes cluster.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To allow acces to <strong>projects<\/strong> define this configuration into the config.yaml:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ci_access:\n  projects:\n    - id: path\/to\/my_project\n    - id: path\/to\/my_second_project<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This code allows specific projects to use the agent. By the way, all authorized projects must be listed one by one.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-using-the-agent-from-an-authorized-project\">Using the agent from an authorized project<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Projects or groups authorized by the main project can therefore use the agent to deploy. For more information about deployment, see the article : <a href=\"https:\/\/www.dbi-services.com\/blog\/deploy-an-application-with-gitlab-ci-cd\/\">Deploy an application with GitLab CI\/CD<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To target the main project agent, set the right path when defining the context in the before_script:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>deploy:\n  before_script:\n  - kubectl config use-context path\/to\/main\/project:agent-name\n  <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The path used in the &#8220;kubectl config use-context&#8221;, corresponds to the main project path, followed by : and the name of the agent in the main project.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In conclusion, it is perfectly possible to share an agent between several projects. This is particularly useful when an application is split into several git projects. As a result, maintenance is simpler because there&#8217;s only one agent to keep up to date.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a microservice application, the code for each service has its own git repository. However, how do deploy without duplicating the Gitlab agents ? In Gitlab, you can share an agent between several projects to deploy the application on a Kubernetes cluster ! Define and configure the main project The main project contains the agent&hellip;&nbsp;<\/p>\n","protected":false},"author":72,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","neve_meta_reading_time":"","_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[1320],"tags":[2648,3028],"class_list":["post-28909","post","type-post","status-publish","format-standard","category-devops","tag-gitlab","tag-gitlabci-cd"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v28.8 (Yoast SEO v28.8) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Share Gitlab agent to deploy microservices projects - dbi services Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/share-gitlab-agent-to-deploy-microservices-projects\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Share Gitlab agent to deploy microservices projects\" \/>\n<meta property=\"og:description\" content=\"In a microservice application, the code for each service has its own git repository. However, how do deploy without duplicating the Gitlab agents ? In Gitlab, you can share an agent between several projects to deploy the application on a Kubernetes cluster ! Define and configure the main project The main project contains the agent&hellip;&nbsp;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/share-gitlab-agent-to-deploy-microservices-projects\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi services Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/dbiservices\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-30T16:05:43+00:00\" \/>\n<meta name=\"author\" content=\"Nicolas Meunier\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@dbiservices\" \/>\n<meta name=\"twitter:site\" content=\"@dbiservices\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nicolas Meunier\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/share-gitlab-agent-to-deploy-microservices-projects\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/share-gitlab-agent-to-deploy-microservices-projects\\\/\"},\"author\":{\"name\":\"Nicolas Meunier\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/f7db0bacb346a357921356a06e563000\"},\"headline\":\"Share Gitlab agent to deploy microservices projects\",\"datePublished\":\"2023-10-30T16:05:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/share-gitlab-agent-to-deploy-microservices-projects\\\/\"},\"wordCount\":344,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/#organization\"},\"keywords\":[\"GitLab\",\"GitlabCI\\\/CD\"],\"articleSection\":[\"DevOps\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/share-gitlab-agent-to-deploy-microservices-projects\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/share-gitlab-agent-to-deploy-microservices-projects\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/share-gitlab-agent-to-deploy-microservices-projects\\\/\",\"name\":\"Share Gitlab agent to deploy microservices projects - dbi services Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\"},\"datePublished\":\"2023-10-30T16:05:43+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/share-gitlab-agent-to-deploy-microservices-projects\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/share-gitlab-agent-to-deploy-microservices-projects\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/share-gitlab-agent-to-deploy-microservices-projects\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Share Gitlab agent to deploy microservices projects\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\",\"name\":\"dbi services Blog\",\"description\":\"#BeSharing\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/#organization\",\"name\":\"dbi services\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/dbi-services-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/dbi-services-logo.png\",\"width\":512,\"height\":512,\"caption\":\"dbi services\"},\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/dbiservices\\\/\",\"https:\\\/\\\/x.com\\\/dbiservices\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/dbi-services\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/dbiservices\"],\"description\":\"Swiss IT consulting and services company specialized in efficient data infrastructures and platforms: databases, application servers, cloud, DevOps, digitalization, analytics, data quality and monitoring. Headquartered in Del\u00e9mont with offices in Nyon, Basel, Bern and Zurich.\",\"email\":\"info@dbi-services.com\",\"telephone\":\"+41 32 422 96 00\",\"legalName\":\"dbi services SA\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/f7db0bacb346a357921356a06e563000\",\"name\":\"Nicolas Meunier\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/NME_web-min-scaled.jpg\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/NME_web-min-scaled.jpg\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/NME_web-min-scaled.jpg\",\"caption\":\"Nicolas Meunier\"},\"description\":\"Nicolas Meunier specializes in cloud solutions and has more than 20 years of experience in IT web technologies and development, including CI\\\/CD, Kubernetes, Docker, Jenkins-X, and Azure DevOps. Prior to dbi services, he developed and maintained a CI\\\/CD pipeline at CEGID in Paris and worked as Lead Developer at KPMG. He holds a superior technical diploma in IT development. His background covers software and cloud platform architecture.\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/author\\\/nicolas-meunier\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Share Gitlab agent to deploy microservices projects - dbi services Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/share-gitlab-agent-to-deploy-microservices-projects\/","og_locale":"en_US","og_type":"article","og_title":"Share Gitlab agent to deploy microservices projects","og_description":"In a microservice application, the code for each service has its own git repository. However, how do deploy without duplicating the Gitlab agents ? In Gitlab, you can share an agent between several projects to deploy the application on a Kubernetes cluster ! Define and configure the main project The main project contains the agent&hellip;&nbsp;","og_url":"https:\/\/www.dbi-services.com\/blog\/share-gitlab-agent-to-deploy-microservices-projects\/","og_site_name":"dbi services Blog","article_publisher":"https:\/\/www.facebook.com\/dbiservices\/","article_published_time":"2023-10-30T16:05:43+00:00","author":"Nicolas Meunier","twitter_card":"summary_large_image","twitter_creator":"@dbiservices","twitter_site":"@dbiservices","twitter_misc":{"Written by":"Nicolas Meunier","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/share-gitlab-agent-to-deploy-microservices-projects\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/share-gitlab-agent-to-deploy-microservices-projects\/"},"author":{"name":"Nicolas Meunier","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/f7db0bacb346a357921356a06e563000"},"headline":"Share Gitlab agent to deploy microservices projects","datePublished":"2023-10-30T16:05:43+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/share-gitlab-agent-to-deploy-microservices-projects\/"},"wordCount":344,"commentCount":0,"publisher":{"@id":"https:\/\/www.dbi-services.com\/#organization"},"keywords":["GitLab","GitlabCI\/CD"],"articleSection":["DevOps"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/share-gitlab-agent-to-deploy-microservices-projects\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/share-gitlab-agent-to-deploy-microservices-projects\/","url":"https:\/\/www.dbi-services.com\/blog\/share-gitlab-agent-to-deploy-microservices-projects\/","name":"Share Gitlab agent to deploy microservices projects - dbi services Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"datePublished":"2023-10-30T16:05:43+00:00","breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/share-gitlab-agent-to-deploy-microservices-projects\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/share-gitlab-agent-to-deploy-microservices-projects\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/share-gitlab-agent-to-deploy-microservices-projects\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Share Gitlab agent to deploy microservices projects"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi services Blog","description":"#BeSharing","publisher":{"@id":"https:\/\/www.dbi-services.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.dbi-services.com\/#organization","name":"dbi services","url":"https:\/\/www.dbi-services.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2026\/09\/dbi-services-logo.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2026\/09\/dbi-services-logo.png","width":512,"height":512,"caption":"dbi services"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/dbiservices\/","https:\/\/x.com\/dbiservices","https:\/\/www.linkedin.com\/company\/dbi-services\/","https:\/\/www.youtube.com\/user\/dbiservices"],"description":"Swiss IT consulting and services company specialized in efficient data infrastructures and platforms: databases, application servers, cloud, DevOps, digitalization, analytics, data quality and monitoring. Headquartered in Del\u00e9mont with offices in Nyon, Basel, Bern and Zurich.","email":"info@dbi-services.com","telephone":"+41 32 422 96 00","legalName":"dbi services SA"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/f7db0bacb346a357921356a06e563000","name":"Nicolas Meunier","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/08\/NME_web-min-scaled.jpg","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/08\/NME_web-min-scaled.jpg","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/08\/NME_web-min-scaled.jpg","caption":"Nicolas Meunier"},"description":"Nicolas Meunier specializes in cloud solutions and has more than 20 years of experience in IT web technologies and development, including CI\/CD, Kubernetes, Docker, Jenkins-X, and Azure DevOps. Prior to dbi services, he developed and maintained a CI\/CD pipeline at CEGID in Paris and worked as Lead Developer at KPMG. He holds a superior technical diploma in IT development. His background covers software and cloud platform architecture.","url":"https:\/\/www.dbi-services.com\/blog\/author\/nicolas-meunier\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/28909","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/72"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=28909"}],"version-history":[{"count":0,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/28909\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=28909"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=28909"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=28909"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}