How to add a static slave to Jenkins running in Kubernetes?
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: &quot;CentOS_7.1_k4.14.11_ssh_password&quot;
                      username: 'jenkins'
                      password: ${decodeBase64:BASE64ENCODEDPASSWD}
                      description: &quot;Username/Password Credentials for CentOS_7.1_k4.14.11&quot;
      permanent-nodes: |
        jenkins:
          nodes:
            - permanent:
                name: &quot;CentOS 7.1 k4.14.11&quot;
                remoteFS: &quot;/home/jenkins&quot;
                numExecutors: 2
                labelString: &quot;CentOS_7.1_k4.14.11&quot;
                mode: EXCLUSIVE
                retentionStrategy: &quot;always&quot;
                launcher:
                  SSH:
                    jvmOptions: &quot;-Xms256m -Xmx1024m -XX:MaxPermSize=1024m&quot;
                    credentialsId: &quot;CentOS_7.1_k4.14.11_ssh_password&quot;
                    host: &quot;10.1.66.120&quot;
                    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.