ArgoCD Hands-on

- Jenkins configuration
- Jenkins installation and Plugin setting
- Pipeline configuration (Github, Docker Hub integration, etc.)
- ArgoCD
- ArgoCD installation
- ArgoCD CLI
- ArgoCD configuration (Project and Application creation, ArgoCD Image Updater setup)
Jenkins Installation
Section titled “Jenkins Installation”- Add helm repo
helm repo add jenkins https://charts.jenkins.io
# change Service Type to LoadBalancer for external Jenkins access and installhelm install [RELEASE_NAME] jenkins/jenkins- Integrate Jenkins with gitHub
- Create a Credential in GitHub: Go to the Github Setting > Developer settings menu, then go to the Personal access tokens menu as shown below. Next, select the Generate new token menu in the top right.
- Configure the GitHub connection in Jenkins: Go to the Jenkins > Manage Jenkins > Configure System menu and add the GitHub account configuration
- Integrate Jenkins with Docker Hub
- In the Jenkins > Manage Jenkins > Manage Credentials menu, add a ‘Username with password’ type Credential for Docker hub integration
- Pipeline configuration
- Dockerfile example
Dockerfile # base imageFROM adoptopenjdk/openjdk11# copy build/libs/*.jar from the temp image to app.jarCOPY build/libs/kiki.jar app.jar# expose container port 8080EXPOSE 8080CMD ["java","-jar","/app.jar"]- Jenkinsfile example
Jenkinsfile podTemplate(label: 'docker-build',containers: [22 collapsed linescontainerTemplate(name: 'git',image: 'alpine/git',command: 'cat',ttyEnabled: true),containerTemplate(name: 'docker',image: 'docker',command: 'cat',ttyEnabled: true),containerTemplate(name: 'gradle',image: 'gradle:7.1.0-jdk11',command: 'cat',ttyEnabled: true)],volumes: [hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'),]) {node('docker-build') {def dockerHubCred = "docker_hub_id"def appImagestage('Checkout'){git (branch: 'master',credentialsId: 'heyKim',url: 'https://github.com/heyKim/todo.git')}stage('Test'){container('gradle'){script {sh 'chmod 755 ./gradlew'sh 'java -version'sh 'printenv|sort'// sh './gradlew test'sh './gradlew build -x test'}}}stage('Build'){container('docker'){script {appImage = docker.build("jkk3366/jenkins")}}}stage('Push'){container('docker'){script {docker.withRegistry('https://registry.hub.docker.com', dockerHubCred){appImage.push("${env.BUILD_NUMBER}")appImage.push("latest")}}}}}}
ArgoCD Installation
Section titled “ArgoCD Installation”- Add helm repo
helm repo add argo https://argoproj.github.io/argo-helm- Download the source to modify the config, then install argocd after modifying the source
# download sourcehelm fetch argo/argo-cd
# modify source# change only Service Type from ClusterIP to LoadBalancer for external access to the argocd server
# install argocd via helm installhelm install "specify argo cd name" argo/argo-cd
# when you want to apply the values.yaml modified during installationhelm install "specify argo cd name" argo/argo-cd -f ./values.yaml- Check the password after installation
# check the password from the secret (id defaults to admin)kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
# `argocd-initial-admin-secret` reportedly needs the namespace removed after changing the password (per the official site).ArgoCD CLI
Section titled “ArgoCD CLI”Connect
Section titled “Connect”
ArgoCD Configuration
Section titled “ArgoCD Configuration”Overview
Section titled “Overview”
Application. An Application is a bundle of Kubernetes resources and is responsible for deployment.
Creating an Application
Section titled “Creating an Application”


- Application Name: Enter the name of the App.
- Project: The field for selecting a project. A concept similar to Kubernetes namespaces, it allows you to logically separate and manage multiple Apps into projects.
- Sync Policy: Determines how changes in the Git repository are synced. Auto automatically reflects changes in the Git repository into operations, while Manual requires the user to reflect them into operations directly via a button click or API.
- Repository URL: Means the Git repository that ArgoCD will watch
- Revision: Determines which revision of Git (HEAD, master branch, etc.) to watch
- Path: Determines which directory in the Git repository to watch. (In the case of a dot(.), the root path; if you enter a directory name, it tracks only the deployment manifest of that directory)
- Cluster: Determines which Kubernetes cluster to deploy to
- Namespace: Determines which namespace of the Kubernetes cluster to deploy to
- Select the Kubernetes manifests Tool: Select the tool to define the Kubernetes manifest and enter the configuration information.

OutOfSync state because it is before synchronization

ArgoCD Image Updater
Section titled “ArgoCD Image Updater”- A feature that automatically updates the container image of k8s workloads managed by Argo CD.
- Without needing to manually update the image version, etc. in the resource yaml, it automatically detects updates of new images and applies them to the k8s workload.
- It is configured by adding annotations to the Application resource managed by Argo CD.
NOTE: This is a feature still under development.
ArgoCD Image Updater Setup
Section titled “ArgoCD Image Updater Setup”- Install argocd-image-updater
# install on the k8s workload where argocd is installedgit clone https://github.com/argoproj-labs/argocd-image-updater/blob/master/manifests/install.yaml
# Apply the installation manifests¶kubectl apply -n argocd -f manifests/install.yaml- Grant Access permissions for the Docker Registry
- Add annotations to the ArgoCD Application To configure the Auto Image Updater, you need to add annotations. You can add the annotations with the command below
kubectl annotate app argocd-updater-test -n argocd\ argocd-image-updater.argoproj.io/image-list=registry-1.docker.io/jkk3366/jenkins \ argocd-image-updater.argoproj.io/todo.force-update=true \ argocd-image-updater.argoproj.io/write-back-method=gitYou can also add the annotations below in the ArgoCD UI.
argocd-image-updater.argoproj.io/image-list: jkk3366/jenkinsargocd-image-updater.argoproj.io/todo.force-update: trueargocd-image-updater.argoproj.io/write-back-method: gitPlatform CI/CD Improvement through ArgoCD
Section titled “Platform CI/CD Improvement through ArgoCD”- Easy Config modification
-
As-Is
The configuration information is included inside the Docker Image, so properties are managed statically.
Because the config is not separated from the application source, you have to go through the build process to modify the config. -
To-Be
Separate CI/CD and manage dynamically by leveraging the kustomize feature that creates properties as a ConfigMap.
- ConfigMap repository example.
- kustomization.yaml
Directoryprd
Directorybackend001
- application-api.yml
- application-db.yml
- application.yml
Directorybackend002
- application-api.yml
- application-db.yml
- application.yml
- Kustomization configMapGenerator example
apiVersion: kustomize.config.k8s.io/v1beta1kind: Kustomization...configMapGenerator:- name: accountfiles:- ./prd/backend001/application.yml- ./prd/backend001/application-api.yml- ./prd/backend001/application-db.yml- name: apigatewayfiles:- ./prd/backend002/application.yml- ./prd/backend002/application-api.yml- ./prd/backend002/application-db.yml
- Deployment (CD) without building is possible
- As-Is
Currently, when building monitoring, filebeat, metricbeat, prometheus, elasticsearch, etc. are installed manually via the
kubectl apply -forhelm installcommands, so change management and version management are absent and Human error easily occurs - To-Be
The state defined in the git repo and the cluster are kept identical, making management easy.
- Easy Multi Cluster management
-
As-Is
To install metricbeat on hundreds of clusters, you have to install it manually hundreds of times, which is inefficient
-
To-Be
Using argocd, even when a new cluster is added, you can simply add the cluster configuration and maintain the same shape across multiple clusters without separate processing.
- helm deployment without a Helm Chart Repo
- As-Is
The ICP Helm Chart Repo is in use, so an alternative is needed for helm deployment to a Native K8S Cluster that is not ICP.
- To-Be
Through ArgoCD-based helm deployment, it can be used without separately maintaining a helm chart repo.