Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using YTT in Argocd as Sidecar #924

Closed
mdavid01 opened this issue Aug 7, 2024 · 1 comment
Closed

Using YTT in Argocd as Sidecar #924

mdavid01 opened this issue Aug 7, 2024 · 1 comment
Labels
carvel triage This issue has not yet been triaged for relevance

Comments

@mdavid01
Copy link

mdavid01 commented Aug 7, 2024

Hi team: Is there a YTT-specific example for configuring YTT using the sidecar method in Argocd? (other than the example shown in Argocd https://argo-cd.readthedocs.io/en/stable/operator-manual/config-management-plugins/)

Does anyone have an example of sidecar working with YTT plugins? Getting errors on both plugins. Configmaps install correctly.
Error Messages:

  1. error="Manifest generation error (cached): plugin sidecar failed. Couldn't find cmp-server plugin supporting repository .gitops/feature-templates"
  2. error="Manifest generation error (cached): plugin sidecar failed. Couldn't find cmp-server plugin supporting repository .apps/harbor"

Example of error #1:

From Application generated from Git as viewed in Argocd

project: harbor-features
source:
  repoURL: 'https://..../deployment.git'
  path: gitops/feature-templates
  targetRevision: harbor-md
  plugin:
    env:
      - name: BRANCH_NAME
        value: harbor-md
      - name: YTT_VALUES
        value: >
          #@data/values
          ---
          targetNamespace: "harbor-md"
          environment: internal
          defaultDomain: redacted
          externalURL:
          "redacted"
          istioGateway: istio-gateway
          docsUrl: ""
          targetRevision: "harbor-xxx"
          imageStorageType: filesystem
          aquaUrl: redacted
          s3:
            region: us-east-1
            bucket: redacted
            regionendpoint: https://s3.us-east-1.amazonaws.com
          database:
            type: internal
            host: redacted
          redis:
            installSentinel: "no"
            type: internal
            endpoint: sentinel-harbor-xxx-redis:26379
            masterset: mymaster
destination:
  server: 'https://kubernetes.default.svc'
  namespace: argocd
syncPolicy:
  automated: {}
  syncOptions:
    - CreateNamespace=true

======================================
Plugin ConfigMap generated from Git as viewed in Argocd

apiVersion: v1
data:
  plugin.yaml: |
    apiVersion: argoproj.io/v1alpha1
    kind: ConfigManagementPlugin
    metadata:
      name: harbor-applicationset
    spec:
      kustomize.buildOptions: --enable-helm
      init:
          command: ["/bin/sh", "-c"]
          args: ["helm dependency build || true"]
      generate:
        command: ["/bin/bash", "/swf/harborset-applicationset.sh"]
      discover:
        fileName: "gitops/feature-templates/auto-deploy.yaml"
kind: ConfigMap
metadata:
  labels:
    app.kubernetes.io/name: harbor-applicationset
    app.kubernetes.io/part-of: argocd
    argocd.argoproj.io/instance: argocd-customizations
  name: harbor-applicationset
  namespace: argocd

======================================
Repo-Server (Sidecar) generated from Git as viewed in Argocd
this includes several other plugins with similar command, mounts, and volume construct

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    argocd.argoproj.io/instance: argocd-customizations
  name: argocd-argo-cd-repo-server
  namespace: argocd
spec:
  replicas: 5
  revisionHistoryLimit: 5
  selector:
    matchLabels:
      app.kubernetes.io/instance: argocd-argo-cd
      app.kubernetes.io/name: argocd-repo-server
  template:
    metadata:
      labels:
        app.kubernetes.io/instance: argocd-argo-cd
        app.kubernetes.io/name: argocd-repo-server
    spec:
      automountServiceAccountToken: true
      containers:
        - command:
            - /var/run/argocd/argocd-cmp-server
          image: busybox
          name: harbor-applicationset-plugin
          securityContext:
            runAsNonRoot: true
            runAsUser: 999
          volumeMounts:
            - mountPath: /var/run/argocd
              name: var-files
            - mountPath: /home/argocd/cmp-server/plugins
              name: plugins
            - mountPath: /home/argocd/cmp-server/config/plugin.yaml
              name: harbor-applicationset
              subPath: plugin.yaml
            - mountPath: /tmp
              name: harbor-applicationsetp-tmp
            - mountPath: /swf/harborset-applicationset.sh
              name: argocd-swf
              subPath: harborset-applicationset.sh
......
Volumes:
      volumes:
        - configMap:
            name: helm-kustomize
          name: helm-kustomize
        - configMap:
            name: helmchart-kustomize
          name: helmchart-kustomize
        - configMap:
            name: helm-ytt
          name: helm-ytt
        - configMap:
            name: helmchart-ytt
          name: helmchart-ytt
        - configMap:
            name: ytt
          name: ytt
        - configMap:
            name: harbor-applicationset
          name: harbor-applicationset
        - configMap:
            name: output-environmentvariables
          name: output-environmentvariables

======================================
harbor-applicationset.sh configmap

apiVersion: v1
data:
  harborset-applicationset.sh: >
    [ -d $ARGOCD_ENV_BRANCH_NAME ] && SUBPATH="--data-values-file
    $ARGOCD_ENV_BRANCH_NAME/data.yml" || unset SUBPATH

    echo "$ARGOCD_ENV_YTT_VALUES" > x-ytt-values.yml

    MYCMD="cat x-ytt-values.yml | ytt --ignore-unknown-comments -f - $SUBPATH -f
    00-helm-values.yml"

    eval $MYCMD > 01-helm-values.txt

    MYCMD="cat x-ytt-values.yml | ytt --ignore-unknown-comments -f - $SUBPATH -f
    01-helm-values.txt -f 01-app.yml"

    eval $MYCMD
kind: ConfigMap
metadata:
  labels:
    argocd.argoproj.io/instance: argocd-customizations
  name: argocd-swf
  namespace: argocd

Maybe YTT sidecar is not available yet?

@mdavid01 mdavid01 added the carvel triage This issue has not yet been triaged for relevance label Aug 7, 2024
@carvel-bot carvel-bot added this to Carvel Aug 7, 2024
@prembhaskal
Copy link
Member

ytt sidecar is not readily available but you can make one quite easily by creating a docker image wrapping around ytt binary and using that as a container.

@mdavid01 mdavid01 closed this as completed Aug 7, 2024
@github-project-automation github-project-automation bot moved this to Closed in Carvel Aug 7, 2024
@github-actions github-actions bot removed the carvel triage This issue has not yet been triaged for relevance label Aug 7, 2024
@mdavid01 mdavid01 reopened this Aug 7, 2024
@github-project-automation github-project-automation bot moved this from Closed to In Progress in Carvel Aug 7, 2024
@github-actions github-actions bot added the carvel triage This issue has not yet been triaged for relevance label Aug 7, 2024
@mdavid01 mdavid01 closed this as completed Aug 8, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Closed in Carvel Aug 8, 2024
@github-actions github-actions bot added carvel triage This issue has not yet been triaged for relevance and removed carvel triage This issue has not yet been triaged for relevance labels Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
carvel triage This issue has not yet been triaged for relevance
Projects
Archived in project
Development

No branches or pull requests

2 participants