新增 pipeline 流水线文件 K8s集群部署

This commit is contained in:
yovinchen 2024-01-25 14:18:51 +08:00
parent c0a7ff7b45
commit 4245cf60a1
3 changed files with 107 additions and 0 deletions

View File

@ -229,3 +229,13 @@ services:
retries: 3 retries: 3
start_period: 60s #⾸次检测延迟时间 start_period: 60s #⾸次检测延迟时间
``` ```
## K8s 集群部署
使用 jenkins 进行打包
构建参数
![image-20240125141417779](https://lsky.hhdxw.top/imghub/2024/01/image-202401251706163258.png)
具体 pipeline 参考各模块下文件

58
xlcs-parent/service-gateway/Jenkinsfile vendored Normal file
View File

@ -0,0 +1,58 @@
pipeline {
environment {
DOCKER_REGISTRY = "10.211.55.2:8083"
DOCKER_IMAGE_NAME = "service-gateway"
DOCKER_IMAGE_TAG = "${env.DATETIME}"
DOCKER_LOGIN_USERNAME = "admin"
DOCKER_LOGIN_PASSWORD = "adminadmin"
}
agent {
kubernetes {
inheritFrom 'maven'
containerTemplate {
name 'maven'
image 'maven:3.8.4-jdk-8'
}
}
}
stages {
stage('拉取代码') {
steps {
checkout([$class: 'GitSCM', branches: [[name: 'devops']],
extensions: [[$class: 'CloneOption', depth: 1, shallow: true]], userRemoteConfigs: [[url: 'http://gitea.hhdxw.top:3000/yovinchen/xlcs.git']]
])
}
}
stage('编译jar包') {
agent none
steps {
container('maven') {
sh 'mvn -f xlcs-parent/pom.xml -B clean package -Dmaven.test.skip=true -Dautoconfig.skip'
}
}
}
stage('保存制品') {
steps {
archiveArtifacts(artifacts: 'xlcs-parent/service-gateway/target/*.jar', followSymlinks: false)
}
}
stage('构建Docker镜像') {
steps {
sh "docker build -t ${DOCKER_REGISTRY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} xlcs-parent/service-gateway"
}
}
stage('登录仓库并推送镜像') {
steps {
sh "docker login -u ${DOCKER_LOGIN_USERNAME} -p ${DOCKER_LOGIN_PASSWORD} ${DOCKER_REGISTRY}"
sh "docker push ${DOCKER_REGISTRY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}"
}
}
}
}

View File

@ -0,0 +1,39 @@
pipeline {
agent {
kubernetes {
inheritFrom 'maven'
containerTemplate {
name 'maven'
image 'maven:3.8.4-jdk-8'
}
}
}
stages {
stage('拉取代码') {
steps {
checkout([$class: 'GitSCM', branches: [[name: 'devops']],
extensions: [[$class: 'CloneOption', depth: 1, shallow: true]], userRemoteConfigs: [[url: 'http://gitea.hhdxw.top:3000/yovinchen/xlcs.git']]
])
}
}
stage('编译jar包') {
agent none
steps {
container('maven') {
sh 'mvn -f xlcs-parent/pom.xml -B clean package -Dmaven.test.skip=true -Dautoconfig.skip'
}
}
}
stage('保存制品') {
steps {
archiveArtifacts(artifacts: 'xlcs-parent/service/service-acl/target/service-acl.jar', followSymlinks: false)
}
}
}
}