Aller au contenu principal

CD (GitOps)

1. Introduction

Our CD (Continuous Delivery) is based on the principle of GitOps. GitOps is a practice that involves conceptualizing and planning operations related to the evolution of an application environment based on one or more Git repositories. Our CD is managed by ArgoCD, a tool renowned for its efficiency.

2. ArgoCD

infra

2.1. Installation

In the Protobox software, the factory/argocd role allows deploying ArgoCD in the Kubernetes cluster.

- name: Setup supervisor host
hosts: supervisor-1
become: true
user: supervisor
gather_facts: false
roles:
...
- role: factory/argocd
...

2.2. Application Configuration

To establish the deployment mechanism for an application in the ArgoCD system, you need to create a Kubernetes object of type Application. The declaration is made in the following directory for each project:

factory > CD > argo > application.yml

Example Application

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: argo-docserver
namespace: argocd
spec:
project: default
source:
repoURL: http://192.168.1.7/gitlab/protobox1/docserver.git
targetRevision: CD
path: factory/CD/base
destination:
server: https://kubernetes.default.svc
syncPolicy:
syncOptions:
- CreateNamespace=true

infra

2.3. Improvements to be Made

Currently, there is a DNS resolution issue within the argocd-server container, which cannot resolve the domain names of private GitLab servers. In the example above, the repository link contains an IP address instead of the corresponding domain name. The argo-server logs the following message:

dial tcp: lookup git.protobox on 169.254.25.10:53: no such host

To address this issue, we have two potential solutions (at least for now):

1st Solution. Combine CoreDNS with Consul or DNSMASQ for DNS resolution of our Git repositories.

------------------
| CoreDNS/Consul |
------------------
apiVersion: v1
kind: ConfigMap
metadata:
labels:
addonmanager.kubernetes.io/mode: EnsureExists
name: coredns
namespace: kube-system
data:
Corefile: |
.:53 {
<Existing CoreDNS definition>
}
+ consul {
+ errors
+ cache 30
+ forward . <consul-address>
+ }
------------------
| CoreDNS/DNSMASQ |
------------------
apiVersion: v1
kind: ConfigMap
metadata:
labels:
addonmanager.kubernetes.io/mode: EnsureExists
name: coredns
namespace: kube-system
data:
Corefile: |
.:53 {
<Existing CoreDNS definition>
}
+ dnsmasq {
+ errors
+ cache 30
+ forward . <-dnsmasq-address>
+ }

2nd Solution. This solution involves forcing the /etc/hosts file of the host machine into the argocd-server container.