Skip to content

ch007m/howto-quarkus-argocd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

A quarkus hello deployed on kubernetes using argocd

Prerequisites

Instructions

  • As we will deploy the Argocd applications using different namespaces, then create the following Argocd ConfigMap file
echo "apiVersion: v1
data:
  application.namespaces: user1,user2,user3,user4,user5
kind: ConfigMap
metadata:
  labels:
    app.kubernetes.io/name: argocd-cmd-params-cm
    app.kubernetes.io/part-of: argocd
  name: argocd-cmd-params-cm
  namespace: argocd
" > argocd-cm.yaml
  • Create a new kind cluster using idpbuilder and set the path of the ConfigMap file using the flag -c
idpbuilder create \
  --color \
  --name quarkus \
  -c argocd:<PROJECT_PATH>/argocd-cm.yaml
  • Generate a Quarkus Hello project and add the needed extensions
rm -rf my-quarkus-hello
quarkus create app \
  --name my-quarkus-hello \
  dev.snowdrop:my-quarkus-hello:0.1.0 \
  -x helm,container-image-podman \
  --wrapper
  
cd my-quarkus-hello
  • Edit the pom.xml to add the argocd extension
<dependency>
    <groupId>io.quarkiverse.argocd</groupId>
    <artifactId>quarkus-argocd</artifactId>
    <version>0.1.0</version>
</dependency> 
  • Get the credentials to access the argocd and gitea servers.
idpbuilder get secrets
  • Create a .env, set the following variables and source it
REGISTRY_USERNAME=<REGISTRY_USERNAME> // giteaAdmin
REGISTRY_PASSWORD=<REGISTRY_PASSWORD> // Use idpbuilder get secrets gitea command to got it
GITEA_TOKEN=<GITEA_TOKEN> // Use idpbuilder get secrets gitea command to got it
HELM_PROJECT_PATH=<HELM_PROJECT_PATH>
  • Create a new gitea organization quarkus and repository my-quarkus-hello on https://gitea.cnoe.localtest.me:8443/
curl -k -X POST \
  "https://gitea.cnoe.localtest.me:8443/api/v1/orgs" \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -u "$REGISTRY_USERNAME:$REGISTRY_PASSWORD" \
  -d '{"username": "quarkus"}'

curl -k \
  "https://gitea.cnoe.localtest.me:8443/api/v1/orgs/quarkus/repos" \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -u "$REGISTRY_USERNAME:$REGISTRY_PASSWORD" \
  -d '{
     "auto_init": true,
     "default_branch": "main",
     "description": "my-quarkus-hello",
     "name": "my-quarkus-hello",
     "readme": "Default",
     "private": true
}'  

Trick: To delete the repository

curl -k -X 'DELETE' \
  "https://gitea.cnoe.localtest.me:8443/api/v1/repos/quarkus/my-quarkus-hello" \
  -u "$REGISTRY_USERNAME:$REGISTRY_PASSWORD" \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json'
  • Add your project to the git repository (e.g.: gitea.cnoe.localtest.me:8443, etc.)
git init
git add .
git commit -asm "Initial commit"
git remote add origin https://$GITEA_TOKEN@gitea.cnoe.localtest.me:8443/quarkus/my-quarkus-hello.git
git push --set-upstream origin main
  • Login to the registry
podman login \
  -u=$REGISTRY_USERNAME \
  -p=$REGISTRY_PASSWORD \
  gitea.cnoe.localtest.me:8443 \
  --tls-verify=false
  • Build the image and push it on the registry using podman
set -x DOCKER_HOST unix:///run/user/501/podman/podman.sock
quarkus build \
  -Dquarkus.container-image.build=true \
  -Dquarkus.container-image.push=true \
  -Dquarkus.container-image.image=gitea.cnoe.localtest.me:8443/quarkus/my-quarkus-hello \
  -Dquarkus.container-image.insecure=true \
  -Dquarkus.podman.tls-verify=false
  • Create a namespace for the user to be tested
kubectl create ns user1
  • Populate the helm chart like the argocd resources at the root of the project
mvn clean package \
  -Dquarkus.helm.output-directory=$HELM_PROJECT_PATH \
  -Dquarkus.container-image.image=gitea.cnoe.localtest.me:8443/quarkus/my-quarkus-hello \
  -Dquarkus.kubernetes.namespace=user1 \
  -Dquarkus.argocd.namespace=user1

Important: As we are deploying the Argocd application in a namespace not managed by an AppProject created under argocd namespace, then argocd will not been able to deploy the my-quarkus-hello application. See the issue here: argoproj/argo-cd#21150 and trick hereafter

echo "apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
  name: my-quarkus-hello
  namespace: argocd
spec:
  clusterResourceWhitelist:
    - group: '*'
      kind: '*'
  destinations:
    - namespace: '*'
      server: '*'
  sourceRepos:
    - '*'
  sourceNamespaces:
    - '*'" | kubectl apply -f -
  • Deploy the argocd resources
kubectl -n user1 apply -f .argocd
kubectl -n user1 delete -f .argocd

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published