k8s 实验 helm jenkins deployment 部署

亡梦爱人 提交于 2020-10-24 08:51:18

# install jenkins ``` kubectl create -f serviceaccount.yaml helm install --name jenkins --set rbac.create=true,master.runAsUser=1000,master.fsGroup=1000 stable/jenkins ```

image

image

image

image

image

image

image

image

[root@k7smaster jenkins]# cat Jenkinsfile.build pipeline { agent { kubernetes { label 'helm-pod' containerTemplate { name 'helm' image 'wardviaene/helm-s3' ttyEnabled true command 'cat' } } } stages { stage('Run helm') { steps { container('helm') { git url: 'git://github.com/wardviaene/kubernetes-course.git', branch: 'master' sh ''' HELM_BUCKET=helm-rytcufor PACKAGE=demo-chart export AWS_REGION=eu-west-1 cp -r /home/helm/.helm ~ helm repo add my-charts s3://${HELM_BUCKET}/charts cd helm/${PACKAGE} helm dependency update helm package . helm s3 push --force ${PACKAGE}-*.tgz my-charts ''' } } } } }

复制jenkins pipline 进来

image

image

image

image

相同的创建部署pipline 脚本

Jenkinsfile.deploy pipeline { agent { kubernetes { label 'helm-pod' serviceAccount 'jenkins-helm' containerTemplate { name 'helm-pod' image 'wardviaene/helm-s3' ttyEnabled true command 'cat' } } } stages { stage('Run helm') { steps { container('helm-pod') { git url: 'git://github.com/wardviaene/kubernetes-course.git', branch: 'master' sh ''' HELM_BUCKET=helm-rytcufor PACKAGE=demo-chart export AWS_REGION=eu-west-1 cp -r /home/helm/.helm ~ helm repo add my-charts s3://${HELM_BUCKET}/charts DEPLOYED=$(helm list |grep -E "^${PACKAGE}" |grep DEPLOYED |wc -l) if [ $DEPLOYED == 0 ] ; then helm install --name ${PACKAGE} my-charts/${PACKAGE} else helm upgrade ${PACKAGE} my-charts/${PACKAGE} fi echo "deployed!" ''' } } } } }

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!