GitOps — How to deploy an app in Kubernetes with ArgoCD — Step2

Deploying and running application

Cesar Augusto
4 min readAug 14, 2023

To complete this article, you have to read the first part before or already have an Environment with ArgoCD and Kubernetes configured.

Why do I need to configure the integration with private repositories?

When you’re running applications with ArgoCD, by default ArgoCD will clone the repository and check the sync with the source of thurth, in this case, your private repository.

How to configure the integration with a private repository?

To configure the integration with a private repository, we will need to access the menu Settings > Repositories https://localhost:8443/settings/repos

Now, click on + CONNECT REPO and fill fields with your private repository.

Example

type: git
project: Default
repository: YOUR_REPOSITORY
username: YOUR_USERNAME
password: YOUR PASSWORD OR TOKEN

Check the option

In the password field, I’m using a Github Token, it is more secure than filling the field with my password.

https://docs.github.com/en/enterprise-server@3.6/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens

Click on Connect button

Expected output from ArgoCD

Check If the connection status is “Successful”, if yes, the configuration was made correctly, if no, please, review and try again.

Application Repository used in this article https://github.com/Cesaragsilva/app-handson-gitops.git

Deploying the application

To deploy the application, we need to create a namespace to run it. Let’s do it!

kubectl create namespace app-medium

Now, we need to configure credentials to access the Docker Hub private registry.

kubectl create secret docker-registry NAME — docker-server=DOCKER_SERVER — docker-username=DOCKER_USERNAME— docker-password=DOCKER_PASSWORD_OR_TOKENdocker-email=DOCKER_EMAIL — namespace NAMESPACE

kubectl create secret docker-registry dockerhub 
--docker-server=index.docker.io
--docker-username=USER
--docker-password=PASS
--docker-email=EMAIL --namespace app-medium
Expected output after running the command above

No, access the ArgoCD IU and create an application.

Configure the application

In this example, I’m using the SYNC POLICY Manual.

Sync Policy Manual: In this policy, we always need to sync manually the repository configuration with the ArgoCD.

Sync Policy Automatic: In this policy, when the repository receives a new configuration (image version, values changed, or others) the ArgoCD will start the rollout with the new configuration.

Fill the fields with the namespace created before app-medium and choose the type Helm. When you choose the Hem type, please, fill the field Values Files with the name of the file that exists on the repository.

Repository with helm charts
Application configured

Click on the Create button and wait for the results below.

Application successful created

Click on the application created and in the second view, click on the sync button

Click on the button Synchronize

Waiting a little bit to finish synchronization and deploying of the application

It’s Done! The application was deployed with success!

To access the application with this test environment, run the command below to expose the port from the application.

kubectl port-forward service/SERVICE_NAME— namespace NAMESPACE PORT_TO_EXPOSE:SERVICE_PORT

kubectl port-forward service/service-app-handson --namespace app-medium 9317:5000
The expected result after running the command.

Now, access the application at http://localhost:9317/swagger/index.html

Successful!

That’s all folks! I hope you have enjoyed the article :)

--

--

Cesar Augusto

Software & Solutions Architect | Software Engineer | 6X Microsoft Azure Certified | 4X AWS Certified