Best practice for organizing Kubernetes objects across multiple git repos?

Viewed 469

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:

  • An auth service (stores users and password hashes, accepts a username and password as input, outputs a JWT)
  • A product list service (stores products, accepts a JWT and product name, outputs product information)
  • A comment service (stores product IDs with comments, accepts a product ID, outputs all comments for the product)
  • etc

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

  • auth-deployment.yml
  • products-deployment.yml
  • comments-deployment.yml
  • etc

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?

1 Answers

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} 


  
Related