Argo CD
In this guide, we'll learn how to deploy Okteto within an Argo CD Application manifest.
Source
Okteto is distributed as a Helm chart in the official Okteto chart repository:
helm repo add okteto https://charts.okteto.com
helm repo update
In the Argo CD manifest, add it as a Helm source:
source:
repoURL: 'https://charts.okteto.com'
chart: 'okteto'
targetRevision: '1.47.0'
helm:
releaseName: 'okteto'
Destination
The destination sets the cluster and the namespace where Okteto runs:
destination:
server: 'https://kubernetes.default.svc'
namespace: 'okteto'
Sync Policy
We recommend the following sync policy and syncOptions to install Okteto with Argo CD and keep it healthy:
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- 'RespectIgnoreDifferences=true'
- 'PruneLast=true'
- 'CreateNamespace=true'
- 'ApplyOutOfSyncOnly=true'
syncPolicy.automatedprune: The names of some objects that Okteto creates contain a hash of the configuration. When the configuration changes, Argo CD detects objects that no longer belong to the chart and should be pruned. This option prunes them automatically. Without it, check the "Prune" checkbox (or set the operation to "prune") when you sync manually.selfHeal: Keeps the manifests consistent with the desired state, and recreates the Okteto configuration if it's deleted or modified externally by accident.
syncPolicy.syncOptions'RespectIgnoreDifferences=true': Makes sync operations respect the differences listed in Ignore Differences.'PruneLast=true': Prunes after Okteto is synced to the desired state.'CreateNamespace=true': Lets Argo CD create the namespace set in the destination. Optional.'ApplyOutOfSyncOnly=true': The Okteto chart uses Helm templating to render some configuration dynamically, such as internal certificates and private keys. This option keeps them from being recreated unnecessarily.
Ignore Differences
Some Okteto resources are rendered with Helm templating functions that need access to the cluster's previous state. Argo CD doesn't give them that access, so you must configure the following ignoreDifferences:
ignoreDifferences:
# TLS secrets generated by Okteto
- kind: 'Secret'
jsonPointers:
- '/data/ca.crt'
- '/data/tls.crt'
- '/data/tls.key'
- '/stringData/ca.crt'
- '/stringData/tls.crt'
- '/stringData/tls.key'
# Mutation webhook cabundles patched by Okteto
- group: 'admissionregistration.k8s.io'
kind: 'MutatingWebhookConfiguration'
jqPathExpressions:
- '.webhooks[].clientConfig.caBundle'
# Validation webhook cabundles patched by Okteto
- group: 'admissionregistration.k8s.io'
kind: 'ValidatingWebhookConfiguration'
jqPathExpressions:
- '.webhooks[].clientConfig.caBundle'
# APIService caBundle managed/patched by Okteto
- group: 'apiregistration.k8s.io'
kind: 'APIService'
jsonPointers:
- '/spec/caBundle'
# Internal service account managed by Okteto
- kind: 'ServiceAccount'
name: 'okteto-bot'
jsonPointers:
- '/metadata/labels/app'
- '/metadata/labels/app.kubernetes.io~1instance'
- '/metadata/labels/chart'
- '/metadata/labels/heritage'
- '/metadata/labels/release'
# Internal service account managed by Okteto
- kind: 'ServiceAccount'
name: 'okteto-admin'
jsonPointers:
- '/metadata/labels/app'
- '/metadata/labels/app.kubernetes.io~1instance'
- '/metadata/labels/chart'
- '/metadata/labels/heritage'
- '/metadata/labels/release'
# Annotations for restarting internal components
- group: 'apps'
kind: 'DaemonSet'
jsonPointers:
- '/spec/template/metadata/annotations/checksum~1certs'
- group: 'apps'
kind: 'Deployment'
jsonPointers:
- '/spec/template/metadata/annotations/checksum~1secrets'
Caveats
- Any change to the configuration leaves orphan resources, which Argo CD can safely prune, automatically or manually. These resources are:
clustermetrics-<hash>jobmigration-<hash>job
- Changes to the following configuration paths may cause a short outage during the sync:
.Values.webhook.internalCertificate.annotations: the webhooks that Okteto registers recreate their certificates..Values.wildcardCertificate.annotations, when.Values.wildcardCertificate.create == true: the self-signed certificates used for external access are recreated.