1

I've installed a Kubernetes cluster and deployed Jenkins in it which dynamically starts slave machines using Kubernetes plugin for Jenkins.

Some builds require a specific build machine with GNU make and specific kernel packages and for that I have a dedicated static virtual machine.

How can I automatically add the static virtual machine to Jenkins as a permanent slave? so when a Jenkins pod goes down and another starts it would automatically connect to the static slave?

2
  • are using and cloud provider? like EKS,AKS or GKE ? Jan 8 at 11:35
  • You can run that machine as a k8s-node and use taints and tolerations to ensure that is used by jenkins/k8s only for appropriate jobs. That way you don't need to worry about static slaves. Jan 11 at 17:46
1

Since I'm using Jenkins official helm chart which contains JCasC plugin (Jenkins Configuration as Code), I was able to configure the static slave attachment using it including the creation of relevant credentials.

Here's the relevant section of the values.yaml file I use to install/upgrade the Jenkins helm chart:

JCasC:
    defaultConfig: true
    configScripts:
      credentials: |
        credentials:
          system:
            domainCredentials:
              - credentials:
                  - usernamePassword:
                      scope: GLOBAL
                      id: "CentOS_7.1_k4.14.11_ssh_password"
                      username: 'jenkins'
                      password: ${decodeBase64:BASE64ENCODEDPASSWD}
                      description: "Username/Password Credentials for CentOS_7.1_k4.14.11"
      permanent-nodes: |
        jenkins:
          nodes:
            - permanent:
                name: "CentOS 7.1 k4.14.11"
                remoteFS: "/home/jenkins"
                numExecutors: 2
                labelString: "CentOS_7.1_k4.14.11"
                mode: EXCLUSIVE
                retentionStrategy: "always"
                launcher:
                  SSH:
                    jvmOptions: "-Xms256m -Xmx1024m -XX:MaxPermSize=1024m"
                    credentialsId: "CentOS_7.1_k4.14.11_ssh_password"
                    host: "10.1.66.120"
                    port: 22
                    sshHostKeyVerificationStrategy:
                      manuallyTrustedKeyVerificationStrategy:
                        requireInitialManualTrust: false

Now whenever I re-deploy or upgrade Jenkins helm chart, it automatically configures these credentials and add the static slave.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.