Auto deploy on kubernetes

6/27/2021

I have a branch on Github that I do pull request from it and add some feature and create a new feature branch .So I have master branch ,feature 1 Branch ,feature 2 branch..etc . what I want is to auto build docker image of each image of each feature branch of them then deploy them on kubernetes and expose a service of them with url(kubernetes is on AWS).After that if I approve the feature branch after pull request to the master,delete its deployment on k8s.Thanks in advance

-- ahmed ahmed
amazon-web-services
git
github
github-actions
kubernetes

2 Answers

6/27/2021

This can possibly be done by using githooks on the server-side, and/or triggering your CI to accomplish what you are looking to do.

-- Vijay Raghavan Aravamudhan
Source: StackOverflow

6/27/2021

If you are using GitHub you can achieve this using GitHub action and if you are on GitLab you can also do it using the GitLab CI pipeline.

here is whole example with configuration : https://about.gitlab.com/blog/2017/09/21/how-to-create-ci-cd-pipeline-with-autodeploy-to-kubernetes-using-gitlab-and-helm/

For feature branch you can keep different config name, service name, deployment name. 

in CI add the logic if branch name if staging 
apply the feature Yaml with command 

kubectl delete -f .....if branch name is feature apply the yaml with command

kubectl apply -f

it's simple thing however you might have to update question with more details.

-- Harsh Manvar
Source: StackOverflow