Communication between the application and the server in the same network

9/2/2019

I am in the process of developing a CI/CD tool that would be running on kubernetes. The application would be responsible for creating a k8s job object which would be treated as a slave in order to run a pipeline.

The image, the slave would be running is entirely up to the user, so I do not have any control over it except for the fact that it would be running in the same local network as the CI/CD application.

My question is; in this scenario, how can I make communication possible between the CI/CD tool and the slave?

To add more context to this, I want to create something similar to Jenkins. Jenkins, together with kubernetes plugin, runs on kubernetes and creates pods which are treated as slaves(agents) in order to run a pipeline. The image which would be running in the slave is entirely up to the user. The slaves have a JNLP as a side-car container which is used to establish the connection. How can I achieve the same architecture in golang or python?

What have I done so far?

I have tried researching on this and came across that Jenkins uses sockets to establish a connection. But, in order to use sockets I have to have sockets on both sides; on the server-side and as well as on the client-side. As far as I know, Jenkins uses the image that I, as the user, gave it to use in the slave, and it does NOT have server-side socket. So how is it able to establish the connection?

-- Harith
circleci
continuous-integration
go
kubernetes

1 Answer

9/2/2019

Since Kubernetes is natively Go, I think this could be achieved easily with a Golang solution. This is a list of some of the things worthy of research time that I can think about out of the box are, assuming that you are running your solution as a Kubernetes service:

  1. Research about Kubernetes operators. An operator will help you extend Kubernetes functionality easily. https://github.com/operator-framework/getting-started
  2. Raft. Raft is a consensus algorithm designed to be easily understandable. This can be used to achieve things like leader election in case you come across the need to implement one. https://raft.github.io/
  3. Golang has native SSH libraries so this should make your idea of using SSH very feasible. I, however, think there could be alternatives like using RPC for communications between the master and slaves as I can imagine it could be a nightmare to manage different certificates to authenticate the master against the slaves.
-- Julius
Source: StackOverflow