stevendesu
stevendesu

Reputation: 16831

Best practice for organizing Kubernetes objects across multiple git repos?

I know that "best practice" questions are very subjective and not a good fit for StackOverflow, but I'm not sure where else to ask so I figured I'd give it a try here.

I'm working on building a microservice application. I plan on having one git repostiory per service. So something like:

All of these services will run inside of a Kubernetes cluster. So for every service there will be a corresponding Deployment YAML file:

My question is: Should I create a separate "devops" repo which contains all of these YAML files (basically one place to see my entire infrastructure in one repository) or should each YAML file live with the code it deploys?

Upvotes: 5

Views: 1196

Answers (1)

Duleepa Wickramasinghe
Duleepa Wickramasinghe

Reputation: 300

My approach is, I have created a separate repository that contains my all deployment YAML files. I have applied CICD (Continues Integration and Continues Deployment) for my deployment. I mean I have integrated GitLab repository with Jenkins. If I will change something in YAML and push into the git branch, Jenkins will detect it automatically and deploy it in the Kubernetes environment. So actually I no need to build jar and image because there are no code changes. So I have created a separated repository and if there are changes in a YAML file, I manually pull those changes into the Kubernetes environment. Then I applied those changes by using Kubernetes apply command as below.

Kubectl apply -f {your file path} 


  

Upvotes: 2

Related Questions