<p>I'm planning to use the <a href="https://github.com/jenkinsci/kubernetes-plugin" rel="nofollow noreferrer">Jenkins Kubernetes plugin</a> in  a setup where an existing Jenkins setup with master and slaves on VMs is split into the master remaining in the current setup and slaves being provisioned dynamically by Google Kubernetes Engine (GKE).</p>

<p>My aim is to reduce costs for the time where slaves can be auto-scaled down to a minimum and provide constant build speed by provisioning a large number of agents at the same time. I'm choosing this approach because it requires a minimum effort.</p>

<p>Afaik I need to forward ports 8080 and 50000 for the JNLP. This is a potential security risk since JNLP isn't protected by any form of encryption and credentials for Jenkins and third party system could be intercepted as well as arbitrary commands being run on the master.</p>

<p>There's the option to enable <a href="https://wiki.jenkins.io/display/JENKINS/Slave+To+Master+Access+Control" rel="nofollow noreferrer">Slave to master access control</a>, but as far as I understand it's not a protection against interception of credentials.</p>

<p>Is it possible to create an IP or other tunnel inside GKE? The IPs of the master nodes are not predictable and it seems like a lot of overhead to maintain the correct tunnel destination to potentially terminated and recreated node pools.</p>

<p>I'm aware that it's probably not rocket science to move the Jenkins master to Kubernetes as well and let it do it's magic with dynamic provisioning of agents in the contained and wonderful world of k8s. However I need to move it there and I don't want to invest time just to have a nice to look at solution if an easier approach does the job as well.</p>

Kalle Richter
<p>You can use Google Cloud VPN service to have secure connection from your VMs to the resources in GKE. <a href="https://cloud.google.com/vpn/docs/concepts/overview" rel="nofollow noreferrer">Here</a> you can find official documentation and <a href="https://sreeninet.wordpress.com/2019/08/11/gke-with-vpn-networking-options/" rel="nofollow noreferrer">here</a> example of practical use provided by third party.</p>
