4.4 部署持续集成工具 Jenkins
4.4.1 helm
安装 jenkins
helm repo add jenkins https://charts.jenkins.io
"jenkins" has been added to your repositories
helm repo update
helm fetch jenkins/jenkins --untar
cd jenkins
helm install jenkins jenkins/jenkins \
--set controller.imagePullPolicy=IfNotPresent \
--set controller.ingress.enabled=true \
--set controller.ingress.hostName=jenkins.hzde.com \
--set controller.ingress.annotations."kubernetes\.io/ingress\.class"=nginx \
--set backup.enabled=true \
-n devops
W0130 10:38:23.604618 60972 warnings.go:70] batch/v1beta1 CronJob is deprecated in v1.21+, unavailable in v1.25+; use batch/v1 CronJob
W0130 10:38:24.852312 60972 warnings.go:70] batch/v1beta1 CronJob is deprecated in v1.21+, unavailable in v1.25+; use batch/v1 CronJob
NAME: jenkins
LAST DEPLOYED: Sun Jan 30 10:38:22 2022
NAMESPACE: devops
STATUS: deployed
REVISION: 1
NOTES:
1. Get your 'admin' user password by running:
kubectl exec --namespace devops -it svc/jenkins -c jenkins -- /bin/cat /run/secrets/chart-admin-password && echo
2. Visit http://jenkins.hzde.com
3. Login with the password from step 1 and the username: admin
4. Configure security realm and authorization strategy
5. Use Jenkins Configuration as Code by specifying configScripts in your values.yaml file, see documentation: http://jenkins.hzde.com/configuration-as-code and examples: https://github.com/jenkinsci/configuration-as-code-plugin/tree/master/demos
For more information on running Jenkins on Kubernetes, visit:
https://cloud.google.com/solutions/jenkins-on-container-engine
For more information about Jenkins Configuration as Code, visit:
https://jenkins.io/projects/jcasc/
NOTE: Consider using a custom image with pre-installed plugins
# 检查运行状态
kubectl get po
NAME READY STATUS RESTARTS AGE
jenkins-0 2/2 Running 0 4m53s
kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
jenkins ClusterIP 10.98.242.15 <none> 8080/TCP 5m10s
jenkins-agent ClusterIP 10.104.142.198 <none> 50000/TCP 5m10s
配置 hosts
192.168.122.191 jenkins.hzde.com
打开浏览器,输入:http://jenkins.hzde.com 进行访问
# 用户名
kubectl get secrets -n devops jenkins -o jsonpath={.data.jenkins-admin-user} | base64 -d
# 密码
kubectl get secrets -n devops jenkins -o jsonpath={.data.jenkins-admin-password} | base64 -d
输入上面获取到的用户名和密码进行登录