Jenkin部署helm

文章详细描述了使用Jenkins构建一个包含拉取GitLab代码、执行Maven打包、推送到Docker私库以及使用Helm进行Kubernetes应用部署的流水线。此外,还提到了Helm仓库的使用,包括从GitHub下载Helm、安装Chartmuseum以创建私有仓库,以及如何在chartmuseum上发布和安装自定义Helm图表。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、完成语法步骤

pipeline {
    agent any

    stages {
        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)

下载地址:Tags · helm/chartmuseum · GitHubHost your own Helm Chart Repository. Contribute to helm/chartmuseum development by creating an account on GitHub.https://github.com/helm/chartmuseum/tags

 容器搭建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

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值