Jenkins在Debian上的集群部署方案可以參考以下步驟:
硬件與操作系統選擇:
安裝依賴與Jenkins:
sudo apt update && sudo apt install -y openjdk-11-jdk
sudo yum install -y java-11-openjdk-devel
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc https://pkg.jenkins.io/debian-stable/jenkins.io.key
echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/" | sudo tee /etc/apt/sources.list.d/jenkins.list
sudo apt update && sudo apt install -y jenkins
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
sudo yum install -y jenkins
sudo systemctl enable jenkins
sudo systemctl start jenkins
sudo systemctl status jenkins # 確認狀態為Active
sudo ufw allow 8080/tcp
sudo ufw allow 50000/tcp
sudo ufw reload
http://<服務器IP>:8080
,輸入初始密碼:sudo cat /var/lib/jenkins/secrets/initialAdminPassword
。Manage Jenkins -> Plugin Manager -> Advanced
,替換 Update Site URL
為:https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
,安裝必備插件:Pipeline、GitHub Integration、Docker、Kubernetes CLI、Credentials Binding。Manage Jenkins -> Security -> Enable security
,選擇 Logged-in users can do anything
,創建管理員用戶,設置用戶名、密碼和郵箱,避免使用默認賬號“admin”。ssh-keygen -t rsa -b 4096 -f ~/.ssh/jenkins_github
,復制公鑰到GitHub的Deploy Keys。Manage Jenkins -> Credentials -> System -> Global credentials
,添加SSH私鑰(類型:SSH Username with private key),ID命名為 github-ssh
。Pipeline script from SCM
,配置Git倉庫地址與憑據。docker run -d --name jenkins-agent \
-v /var/run/docker.sock:/var/run/docker.sock \
-e JENKINS_URL=http://master-ip:8080 \
-e JENKINS_AGENT_NAME=agent
以上步驟提供了一個基本的Jenkins集群部署方案,具體配置可能需要根據實際環境和需求進行調整。