Automatically create new PODS on Kubernetes with Jenkins when Jira bug is created

12/13/2017

I just have this concept that i want to implement on our environment and i just want to ask if there is any way i can do it.

So, I want to configure Jenkins and GKE to automatically provision a pod with the current state of an application, and database, when creating a bug in Jira. Basically I want Jenkins to get triggered by an issue created by an user, in Jira, and then build a replica of the application when the issue got created.

My question is this: Can GKE be manipulated or linked in some way with Jenkins so that it'll create a snapshot of the App + Database and then create a new Pod based on those 2 snapshots?

The workflow should be something like this:
Jira => Jenkins => GKE (snapshots) => GKE (Pods creating)

I would like Jenkins to communicate with GKE and get on creating a new set of Pods automatically, so that i won't have to intervene in any way.

Is there any way i can do something like this? This is just a concept for now, I'm not rushing on anything, just asking for some opinions on this.

Any ideas or suggestions?
Thank you

-- Caranfil Alegzandru
jenkins
jira
kubernetes

2 Answers

12/15/2017

Here is how you could do. For each new Jira task:

  • Create a new branch in the code repository, from the "live" one.
  • Take a backup of the database.
  • Deploy a new instance of the application with this branch and database backup. You probably want to use a cluster or a namespace per Jira task.

To deploy Kubernetes resources from Jenkins you can use the DevOps steps of the Kubernetes Pipeline plugin.

You can use Jobs to run the database backup and restore tasks.

-- Matt-y-er
Source: StackOverflow

12/14/2017

Your question is not specific to GKE. It's about Kubernetes. You probably need to write some code and use the Kubernetes API to achieve what you described, which is a pretty custom use case/workflow.

Some pointers on using the Kubernetes API: https://kubernetes.io/docs/reference/

-- AhmetB - Google
Source: StackOverflow