Jenkins 添加node节点

安装SSH插件
Jenkins- 插件管理- 可选插件- 搜索SSH Agent

Jenkins 添加node节点_第1张图片

配置启用SSH Server
Jenkins- 系统管理 - 全局安全配置, 把 SSH Server 设置为启用(默认是禁用)

Jenkins 添加node节点_第2张图片
新增节点

Jenkins 添加node节点_第3张图片

第一种方式(SSH密钥连接):

1.Jenkins主机生成SSH密钥

[root@k8s-master ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:oI7S4uwjskL1wGBt04Xq3F2huICMKSZ8jBTfwiROlNk root@971e942b7a70
The key's randomart image is:
+---[RSA 3072]----+
|.=*.. o.         |
|o*=E.o   .       |
|*oB+o.o . .      |
|=* O.o o .       |
|+ = * o S        |
| o = + .         |
|+ o .            |
|*+               |
|*=.              |
+----[SHA256]-----+

2.发送Jenkins主机公钥至要远程主机上

[root@k8s-master ~]# ssh-copy-id 192.168.1.20

3.测试Jenkins主机免密连接远程主机

[root@k8s-master ~]# ssh root@192.168.1.20
Last login: Fri Mar  4 10:44:53 2022 from k8s-master
[root@k8s-node2 ~]#

4.添加Jenkins主机SSH私钥key为凭据

[root@k8s-master ~]# cat /root/.ssh/id_rsa
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA0le59pH7mp+XHxmkoEbX8SyXcZ+dmcyhrS1HbqtfnWVoSqai
MrQijlIDv66bFDg9VnbFUKiXrcbzC+wVh8zuuy4Zl9OyvUEOC/YSHwaBvqMwPqgw
nipCRoNNq3MQMBr7T6r7SWA0CCP2IPCl+q0W/HHI5LRk8FT7rGH/hdufwYn8rJxM
B7jntBXMKZJzIQRMyVkZ0vlAla/2/t33dQVRLKNF8//G3wEKQL1yGMgmCXtAj/rn
M96T4qIq4DpkELUFR52ql5SjSFZ3MLQ5Wey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5r7J
S5Cq1PG7F5oof5ptr0VCis9vqLITJoc9/n5GyuovwEAMcQkdWtl/21DEyWb74Lds
Mw+JPQKBgQCiKGvd+YXzPgh3BJoguaMAIrcrlr0iGAEU5y2qi4xgqfyp4Wcb+RHx
LAF7Uz2aT5oj4GP7HVBN7E2OyBe9TjOATnRRb+lSTKNMYYV20av5LaahtlN5URYu
JC7glE/aMXR60Fx4E0iajzZpDKFyQSfc1TqReBQQF+qR0c5QeQSbRw==
-----END RSA PRIVATE KEY-----

Jenkins 添加node节点_第4张图片

5.添加从节点

Jenkins 添加node节点_第5张图片

添加节点页面解释:

  • 名称:自定义一个节点名称
  • 执行器数量:可以同时执行的job线程数,随便写个数字
  • 远程工作目:宿主机上Workspace目录
  • 标签:自定义,方便后期识别
  • 用法:尽可能的使用这个节点
  • 启动方式:Launch agent agents via SSH
  • 主机:输入要远程的宿主机IP地址
  • Credentials:将Jenkins本机生成的SSH密钥的公钥发送至要远程的宿主机上,并且添加Jenkins主机的私钥key为凭据进行远程连接
  • Host Key Verification Strategy:这项选择Known hosts file Verification Strategy
    Jenkins 添加node节点_第6张图片

Jenkins 添加node节点_第7张图片

第二种方式:(ROOT账密连接)
1.添加远程主机的ROOT账号密码为凭据
Jenkins 添加node节点_第8张图片

2.添加从节点

Jenkins 添加node节点_第9张图片
添加节点页面解释:

  • 名称:自定义一个节点名称
  • 执行器数量:可以同时执行的job线程数,随便写个数字
  • 远程工作目:宿主机上Workspace目录
  • 标签:自定义,方便后期识别
  • 用法:尽可能的使用这个节点
  • 启动方式:Launch agent agents via SSH
  • 主机:输入要远程的宿主机IP地址
  • Credentials:添加要远程的宿主机的ROOT账号和密码的凭据
  • Host Key Verification Strategy:这项选择Non verifying Verifcation Stragegy

Jenkins 添加node节点_第10张图片

你可能感兴趣的:(jenkins,运维)