Skip to content

Instantly share code, notes, and snippets.

@metacoma
Forked from skinny/00_readme.md
Last active August 13, 2020 07:28
Show Gist options
  • Save metacoma/af7fbc280da0633643d7c8cb057afbfd to your computer and use it in GitHub Desktop.
Save metacoma/af7fbc280da0633643d7c8cb057afbfd to your computer and use it in GitHub Desktop.
ArgoCD & Kapitan configuration

Using ArgoCD together with Kapitan is actually pretty easy and only requires the kapitan binary in the argo-repo-server and a ConfigManagement plugin in ArgocD (https://argoproj.github.io/argo-cd/user-guide/config-management-plugins/)

1. Edit argocd-cm configmap and add :

  configManagementPlugins: |
    - name: kapitan
      init:
        command: [sh]
        args: ["kapitan-base-compile.sh"]
      generate:
        command: [sh]
        args: ["kapitan-release.sh"]

2. Edit the argocm-repo-server deployment and add/update the following elements :

volumes
initContainers

See the file below for an example

3. place the following files in the root of your git repo (where your kapitan inventory lives)

kapitan-base-compile.sh

cd $(git rev-parse --show-toplevel)
kapitan compile --fetch --t $ARGOCD_APP_NAME

kapitan-release.sh

find ./compiled/$ARGOCD_APP_NAME -type f -name '*.yml' -exec printf "\n\n---\n\n" \; -exec cat {} \; | tee /tmp/all.yaml

4. Create an application in ArgoCD :

--repo https://github.com/acme/demo.git \
--path . \
--dest-server https://mycluster.azmk8s.io:443 \
--dest-namespace euw-dev-cd

The target name in your kapitan inventory should match the application name parameter in step 3

During the refresh step of ArgoCD the kapitan plugin (first) compile the target and then join all the relevant .yml files from the compiled folder to one big yaml file that is outputted to stdout for ArgoCD to consume.

when your kapitan produces .yaml files instead of .yml, update the kapitan-release.sh file accordingly

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app.kubernetes.io/component: repo-server
app.kubernetes.io/name: argocd-repo-server
app.kubernetes.io/part-of: argocd
name: argocd-repo-server
namespace: argocd
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app.kubernetes.io/name: argocd-repo-server
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app.kubernetes.io/name: argocd-repo-server
spec:
automountServiceAccountToken: false
containers:
- command:
- uid_entrypoint.sh
- argocd-repo-server
- --redis
- argocd-redis:6379
image: argoproj/argocd:v1.2.3
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
initialDelaySeconds: 5
periodSeconds: 10
successThreshold: 1
tcpSocket:
port: 8081
timeoutSeconds: 1
name: argocd-repo-server
ports:
- containerPort: 8081
protocol: TCP
- containerPort: 8084
protocol: TCP
readinessProbe:
failureThreshold: 3
initialDelaySeconds: 5
periodSeconds: 10
successThreshold: 1
tcpSocket:
port: 8081
timeoutSeconds: 1
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /app/config/ssh
name: ssh-known-hosts
- mountPath: /app/config/tls
name: tls-certs
- mountPath: /usr/local/bin/kapitan
name: custom-tools
subPath: kapitan
dnsPolicy: ClusterFirst
initContainers:
- args:
- wget -q https://github.com/deepmind/kapitan/releases/download/v0.24.0/kapitan-linux-amd64 && mv
kapitan-linux-amd64 /custom-tools/kapitan && chmod +x /custom-tools/kapitan
command:
- sh
- -c
image: alpine:3.8
imagePullPolicy: IfNotPresent
name: download-tools
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /custom-tools
name: custom-tools
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- configMap:
defaultMode: 420
name: argocd-ssh-known-hosts-cm
name: ssh-known-hosts
- configMap:
defaultMode: 420
name: argocd-tls-certs-cm
name: tls-certs
- emptyDir: {}
name: custom-tools
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment