一、完成语法步骤
pipeline {
agent anystages {
stage('Pull GitLab') {
steps {
checkout scmGit(branches: [[name: '$tag']], extensions: [], userRemoteConfigs: [[url: 'http://192.168.72.110/root/huahua-project']])
}
}
stage('Maven Build') {
steps {
sh '/usr/local/maven/bin/mvn package'
}
}
stage('Pull Harbor') {
steps {
sshPublisher(publishers: [sshPublisherDesc(configName: 'target15', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: '', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '', remoteDirectorySDF: false, removePrefix: 'target', sourceFiles: 'target/*.jar'), sshTransfer(cleanRemote: false, excludes: '', execCommand: '''docker build -t 192.168.72.15:80/public/huahua:$tag /usr/local/docker
docker login -u admin -p Harbor12345 192.168.72.15:80
docker push 192.168.72.15:80/public/huahua:$tag''', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '', remoteDirectorySDF: false, removePrefix: 'docker', sourceFiles: 'docker/*')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
}
}
stage('Helm Build') {
steps {
sshPublisher(publishers: [sshPublisherDesc(configName: 'target14', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: '''helm uninstall huahua
helm repo update
helm install huahua myrepo/huahua-charts --set tag=$tag --set replicas=$replicas''', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '', remoteDirectorySDF: false, removePrefix: '', sourceFiles: '')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
}
}
}
}
二、helm下载
Tags · helm/helm · GitHubThe Kubernetes Package Manager. Contribute to helm/helm development by creating an account on GitHub.https://github.com/helm/helm/tagsmv -f linux-amd64/helm /usr/bin
helm仓库官网:Artifact Hub
举个安装例子:
卸载:helm uninstall my-replease
三、helm私库
安装chartmuseum(192.168.72.112:8080)
容器搭建chartmuseum
前置条件:
四、创建
helm create huahua-charts
修改创建模板目录下的value.yaml
清空templates文件夹,然后创建huahua-deployment.yml,huahua-service.yml
修改 Chart.yaml里面的版本号
value.yaml
打包:
helm package .
上传:
curl --data-binary "@huahua-charts-1.0.1.tgz" http://192.168.72.112:8080/api/charts(chartmuseum私服)
安装:
helm uninstall huahua
kubectl delete deployment huahua-deployment
kubectl delete service huahua-service
helm repo add myrepo http://192.168.72.112:8080
helm repo update
helm search repo myrepo
helm install huahua myrepo/huahua-charts
helm list