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.