Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
joohanhong
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
JooHan Hong
joohanhong
Commits
0c258506
Commit
0c258506
authored
2 years ago
by
JooHan Hong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
k8s rolling update pipeline script 변경
parent
3a8940b9
Pipeline
#6096
passed with stages
in 1 minute and 21 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
65 deletions
+36
-65
README.md
DEVOPS/K8S_BUILD/README.md
+36
-65
No files found.
DEVOPS/K8S_BUILD/README.md
View file @
0c258506
...
...
@@ -18,70 +18,43 @@ import java.text.SimpleDateFormat
def dateFormat = new SimpleDateFormat("yyyyMMdd")
def date = new Date()
def TODAY = dateFormat.format(date)
pipeline {
agent any
environment {
TODAY = dateFormat.format(date)
}
stages {
stage('[TB2-DOCKER] Docker Build') {
stage('Git Clone') {
steps {
script {
def remote = [:]
remote.name = 'TB2-DOCKER'
remote.host = 'IP'
remote.user = '사용자'
remote.port = 포트
remote.password = '패스워드'
remote.allowAnyHosts = true
sshCommand remote: remote, command: "cd /GIT/docker_hongsnet"
sshCommand remote: remote, command: "cd /GIT/docker_hongsnet; /usr/bin/docker build --rm -t hongsnet ."
//echo 'Clone'
sh 'mkdir -p docker_hongsnet'
dir("docker_hongsnet")
{
git branch: 'master', credentialsId: 'juhanida21', url: 'https://gitlab.hongsnet.net/joohan.hong/docker_hongsnet.git'
}
}
}
stage('
[TB2-DOCKER] Harbor Repository Image
Push') {
stage('
Container Image Build and
Push') {
steps {
script {
def remote = [:]
remote.name = 'TB2-DOCKER'
remote.host = 'IP'
remote.user = '사용자'
remote.port = PORT
remote.password = '패스워드'
remote.allowAnyHosts = true
sshCommand remote: remote, command: "/usr/bin/docker login -u admin -p 패스워드 harbor.hongsnet.net"
//sshCommand remote: remote, command: "echo TODAY: ${TODAY}"
//sshCommand remote: remote, command: "echo env.BUILD_ID: ${env.BUILD_ID}"
//sshCommand remote: remote, command: "echo env.JOB_NAME: ${env.JOB_NAME}"
sshCommand remote: remote, command: "/usr/bin/docker tag hongsnet:latest harbor.hongsnet.net/hongsnet/hongsnet:${TODAY}_${BUILD_ID}"
sshCommand remote: remote, command: "/usr/bin/docker push harbor.hongsnet.net/hongsnet/hongsnet:${TODAY}_${BUILD_ID}"
}
//sh 'echo ${TODAY}'
sh 'sudo /usr/bin/docker login -u admin -p 패스워드 harbor.hongsnet.net'
sh 'cd docker_test; sudo /usr/bin/docker build --rm -t hongsnet .'
sh 'sudo /usr/bin/docker tag hongsnet:latest harbor.hongsnet.net/hongsnet/hongsnet:${TODAY}_${BUILD_ID}'
sh 'sudo /usr/bin/docker push harbor.hongsnet.net/hongsnet/hongsnet:${TODAY}_${BUILD_ID}'
}
}
stage('
[TB2-DOCKER] K8s Image
Rolling Update') {
stage('
K8s
Rolling Update') {
steps {
script {
def remote = [:]
remote.name = 'TB2-DOCKER'
remote.host = 'IP'
remote.user = '사용자'
remote.port = 포트
remote.password = '패스워드'
remote.allowAnyHosts = true
sshCommand remote: remote, command: "/usr/bin/kubectl set image deployment/hongsnet-web hongsnet-web=harbor.hongsnet.net/hongsnet/hongsnet:${TODAY}_${BUILD_ID}"
sshCommand remote: remote, command: "/usr/bin/kubectl rollout history deployment/hongsnet-web"
sshCommand remote: remote, command: "/usr/bin/kubectl rollout status deployment/hongsnet-web"
VER = sshCommand remote: remote, command: "/usr/bin/cat /DOCKERS/K8S/hongsnet/hongsnet.yaml |grep hongsnet |grep \"image:\" |grep -v \"#\" |awk -F: '{ print \$3}'"
//sshCommand remote: remote, command: "echo ${VER}"
SED = sshCommand remote: remote, command: "/usr/bin/sed 's/${VER}/${TODAY}_${BUILD_ID}/g' -i /DOCKERS/K8S/hongsnet/hongsnet.yaml"
sshCommand remote: remote, command: "/usr/bin/kubectl describe deployments"
}
sh 'curl -sS http://K8S-MASTER:15999/api/rollup?deployment=hongsnet-web\'&\'cimage=harbor.hongsnet.net/hongsnet/hongsnet:${TODAY}_${BUILD_ID}'
}
}
...
...
@@ -95,17 +68,15 @@ pipeline {
## Source Code Deploy 시 세 가지 Stage로 진행된다.
-
**
Docker Build
**
-
Storage(TB2-DOCKER) 시스템에서 최신(
**.gitlab-ci.yaml**
먼저 수행)의 /GIT/docker_hongsnet 경로에서
Container Image를 Build한다.
-
**
Harbor Repository Image
Push**
-
Storage
시스템에서 harbor.hongsnet.net, Private Registry에 로그인을 수행
-
**
Git Clone
**
-
**Jenkins**
시스템에서 최신의 내용을 /GIT/docker_hongsnet 경로로 Pull 한 후
Container Image를 Build한다.
-
**
Container Image Build and
Push**
-
**Jenkins**
시스템에서 harbor.hongsnet.net, Private Registry에 로그인을 수행
-
Build 된 Container Image를
**Tagging**
한다.
-
Tagging된 Container Image를 저장소에
**Push**
한다.
-
**K8s Image Rolling Update**
-
Storage 시스템(
**K8s의 Master이기도 함**
)에서 업데이트 이미지에 대해
`Rolling Update`
를 수행한다.
**!참고**
: 현재
**kubectl**
명령을 사용하여 관리되기 때문에 yaml 파일에 sed 명령을 통해 Container Image의 최신화를 수행
-
**K8s Rolling Update**
-
**Jenkins**
시스템에서 업데이트 이미지에 대해
`Rolling Update`
를 수행한다.
-
**K8S-MASTER:15999**
는 직접 Golang을 사용한 RESTful API 이다.

...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment