{"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:45","modified_gmt":"2023-10-30T16:05:45","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>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>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>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>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>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>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>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>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>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>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>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>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;]<\/p>\n","protected":false},"author":72,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1320],"tags":[2667,2648,3028,2634],"type_dbi":[],"class_list":["post-28909","post","type-post","status-publish","format-standard","hentry","category-devops","tag-devops-2","tag-gitlab","tag-gitlabci-cd","tag-kubernetes-2"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.2) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Share Gitlab agent to deploy microservices projects - dbi 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;]\" \/>\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 Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-30T16:05:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-30T16:05:45+00:00\" \/>\n<meta name=\"author\" content=\"Nicolas Meunier\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\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\/2e08c09a2f083004587b54128684fefe\"},\"headline\":\"Share Gitlab agent to deploy microservices projects\",\"datePublished\":\"2023-10-30T16:05:43+00:00\",\"dateModified\":\"2023-10-30T16:05:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/share-gitlab-agent-to-deploy-microservices-projects\/\"},\"wordCount\":344,\"commentCount\":0,\"keywords\":[\"devops\",\"GitLab\",\"GitlabCI\/CD\",\"kubernetes\"],\"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 Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\"},\"datePublished\":\"2023-10-30T16:05:43+00:00\",\"dateModified\":\"2023-10-30T16:05:45+00:00\",\"author\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/2e08c09a2f083004587b54128684fefe\"},\"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\":\"Accueil\",\"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 Blog\",\"description\":\"\",\"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\":\"Person\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/2e08c09a2f083004587b54128684fefe\",\"name\":\"Nicolas Meunier\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g\",\"caption\":\"Nicolas Meunier\"},\"description\":\"Nicolas Meunier has more than 20 years of experience in IT web technologies as well as in development. He is specialized in Cloud solutions such as CI\/CD. His expertise also includes Kubernetes, Docker, Jenkins-X and Azure Devops. Florence Porret (FP is IT Consultant in Cloud solutions. Prior to joining dbi services, Nicolas Meunier was developer and maintainer of a CI\/CD pipelines at CEGID in Paris. He also worked as Lead Developer at KPMG. Florence Porret (FP holds a superior technical diploma in IT development. His branch-related experience covers software and cloud platform architecture.\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/author\/nicolasmeunier\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Share Gitlab agent to deploy microservices projects - dbi 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;]","og_url":"https:\/\/www.dbi-services.com\/blog\/share-gitlab-agent-to-deploy-microservices-projects\/","og_site_name":"dbi Blog","article_published_time":"2023-10-30T16:05:43+00:00","article_modified_time":"2023-10-30T16:05:45+00:00","author":"Nicolas Meunier","twitter_card":"summary_large_image","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\/2e08c09a2f083004587b54128684fefe"},"headline":"Share Gitlab agent to deploy microservices projects","datePublished":"2023-10-30T16:05:43+00:00","dateModified":"2023-10-30T16:05:45+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/share-gitlab-agent-to-deploy-microservices-projects\/"},"wordCount":344,"commentCount":0,"keywords":["devops","GitLab","GitlabCI\/CD","kubernetes"],"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 Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"datePublished":"2023-10-30T16:05:43+00:00","dateModified":"2023-10-30T16:05:45+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/2e08c09a2f083004587b54128684fefe"},"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":"Accueil","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 Blog","description":"","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":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/2e08c09a2f083004587b54128684fefe","name":"Nicolas Meunier","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g","caption":"Nicolas Meunier"},"description":"Nicolas Meunier has more than 20 years of experience in IT web technologies as well as in development. He is specialized in Cloud solutions such as CI\/CD. His expertise also includes Kubernetes, Docker, Jenkins-X and Azure Devops. Florence Porret (FP is IT Consultant in Cloud solutions. Prior to joining dbi services, Nicolas Meunier was developer and maintainer of a CI\/CD pipelines at CEGID in Paris. He also worked as Lead Developer at KPMG. Florence Porret (FP holds a superior technical diploma in IT development. His branch-related experience covers software and cloud platform architecture.","url":"https:\/\/www.dbi-services.com\/blog\/author\/nicolasmeunier\/"}]}},"_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":6,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/28909\/revisions"}],"predecessor-version":[{"id":29018,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/28909\/revisions\/29018"}],"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"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=28909"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}