![인프런워밍업클럽4기 devops - [미션6] ArgoCD Github 업데이트](https://cdn.inflearn.com/public/files/blogs/fcfc3efa-4674-4735-bc70-ee56359aaed3/4-devops.png)
인프런워밍업클럽4기 devops - [미션6] ArgoCD Github 업데이트
1. ArgoCD로 App 생성 및 배포 - 2232-build-push-git
1-1. App 생성 하기 - [+ NEW APP] 클릭
▶ GENERAL
Application Name : api-tester-2232-build-push-git
Project Name : default
SYNC POLICY : Manual
▶ SOURCE
※ <Github-Useranme>은 본인의 Username으로 수정
Repository URL : https://github.com/<Github-Useranme>/kubernetes-anotherclass-sprint2.git
Revision : main
Path : 2232-build-push-git/deploy/helm/api-tester
▶ DESTINATION
Cluster URL : https://kubernetes.default.svc
Namespace : anotherclass-223
▶ HELM 확인 후 Values files 지정
VALUES FILES : values-dev.yaml
▶ 화면 상단 [CREATE] 클릭
1-2. 자동 배포 설정 - api-tester-2232-build-push-git > details > SYNC POLICY
1-3. 자동 배포 확인 - ArgoCD 상태 및 Dashboard Pod 생성 유무
2. Jenkins에 Github Token 등록
2-1. Github에서 Credential 확인
▶ GitHub → Settings
▶ Developer settings : 왼쪽 메뉴 가장 하단에 위치
▶ Personal access tokens (classic) 선택 후 [Generate new token]
▶ 권한 설정
Note : Update for Jenkins
Expiration : No expiration
Select scopes : repo [체크]
▶ 생성 후 발급된 키를 별도로 보관
2-2. Jenkins에 Credential 등록
▶ Dashboard > Jenkins 관리 > Credentials > System > Global credentials (unrestricted) 에서 [Add Credentials] 클릭 후 아래 내용 입력
Kind : Username with password
Scope : Global
Username : <Github-Username>
Password : <Github에서 발급 받은 토큰>
ID : github_token
Description : Github 업데이트 토큰
2-3. Jekninsfile 에서 Credential 사용 확인
▶ 2232-build-push-git > Jenkinsfile
def valuesFile = "./${CLASS_NUM}/deploy/helm/api-tester/values-${params.PROFILE}.yaml"
// image 수정
sh """
sed -i 's|^ repository:.*| repository: ${DOCKERHUB_USERNAME}/api-tester|' ${valuesFile}
sed -i 's|^ tag:.*| tag: "${TAG}"|' ${valuesFile}
"""
// github로 업데이트
withCredentials([usernamePassword(credentialsId: 'github_token', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh """
git config user.email "${GITHUB_USERNAME}@email.com"
git config user.name "${GITHUB_USERNAME}"
git remote set-url origin https://${USERNAME}:${PASSWORD}@github.com/${GITHUB_USERNAME}/kubernetes-anotherclass-sprint2.git
git add ${valuesFile}
git commit -m "Update ${valuesFile} with new image tag: ${TAG}"
git push origin HEAD:main
"""
}
3. Jeknins에서 Source/Container 빌드 후 Docker로 업로드 하기
3-1.새보기 및 item 생성
[새보기] 만들기
조회명 : 223
Type : List View
[item name] 만들기
Enter an item name : 2232-build-push-git
[Pipeline] 선택
[OK] 버튼 클릭
3-2. Configure
▶ Configure > General > GitHub project > Project url
※ <Github-Useranme>은 본인의 Username으로 수정
Project url : https://github.com/<Github-Useranme>/kubernetes-anotherclass-sprint2/
▶ Configure > Advanced Project Options > Pipeline > [저장]
※ <Github-Useranme>은 본인의 Username으로 수정
Definition : Pipeline script from SCM
Definition > SCM : Git
Definition > SCM > Repositories > Repository URL : https://github.com/<Github_Username>/kubernetes-anotherclass-sprint2.git
Definition > SCM > Branches to build > Branch Specifier : */main
Definition > SCM > Branches to build > Additional Behaviours > Sparse Checkout paths > Path : 2232-build-push-git
Definition > Script Path : 2232-build-push-git/Jenkinsfile
3-3.[저장] 후 [지금 빌드] 실행 (이때는 파라미터가 없어서 실행되지 않아요!)
3-4.[파라미터와 함께 빌드] 선택 후 본인의 DockerHub와 Github의 Username 입력 후 [빌드] 실행
3-5.Stage View결과 확인
3-6. ArgoCD에서 자동 배포 확인
3-7. 다시 빌드 후 재확인
출처
댓글을 작성해보세요.
일단 먼저 제출하고.. 꼭 실습해보고 미션수행해보기