Uploaded image for project: 'OpenShift GitOps'
  1. OpenShift GitOps
  2. GITOPS-2340

Use server-side apply to perform a patch operation

    • 5
    • False
    • None
    • False
    • Hide
      With this update, Argo CD supports Server-Side Apply.

      This will allow users to solve some of the major challenges with client side operation that relies on the annotation kubectl.kubernetes.io/last-applied-configuration to store previous resource state.
       - Manage large resources which are too big to fit in the 262144 bytes allowed annotation size.
       - Patch an existing resource that is not managed or deployed by Argo CD.

      Note: This feature can be configured at both Application level and individual resource level.
      Show
      With this update, Argo CD supports Server-Side Apply. This will allow users to solve some of the major challenges with client side operation that relies on the annotation kubectl.kubernetes.io/last-applied-configuration to store previous resource state.  - Manage large resources which are too big to fit in the 262144 bytes allowed annotation size.  - Patch an existing resource that is not managed or deployed by Argo CD. Note: This feature can be configured at both Application level and individual resource level.
    • GITOPS Sprint 225

      Why 

      Based on the spike that we have done to investigate patching resource support. We believe that Server Side Apply can be leveraged to fulfill the requirement. SSA support in Argo CD has been added to v2.5. We should take the v2.5 pre-release (or build from master branch) and do a POC to confirm that SSA can indeed to used for provide the support that we are looking for.

      Here are some basic steps to do the POC.

      1. Enable server-side apply in Argo CD instance
      2. Have an existing resource created, not managed by Argo CD
      3. Have a patch in git that modifies the resource
      4. Argo CD should apply the patch using server-side apply.
      5. The field manager should be updated.

      In the end, we can write a blog to let customers and solution architects know about how to address patching exiting resources with SSA.

      Acceptance Criteria

      • Perform the POC
      • Confirm the founding in Cabal. 
      • Optionally, publish a blog

       

            [GITOPS-2340] Use server-side apply to perform a patch operation

            Abhishek Veeramalla added a comment - Blog: https://abhishekveeramalla-av.medium.com/kubernetes-server-side-apply-with-argo-cd-aa0d2de58849

            I take back the comment - `Argo CD ServerSideApply` cannot apply a patch to an existing resource.

            It is possible by turning off the schema validation which is already supported by Argo CD.
            I have provided the required updates and steps to verify the feature here.
            https://github.com/argoproj/argo-cd/issues/2437#issuecomment-1264964312

            Abhishek Veeramalla added a comment - I take back the comment - `Argo CD ServerSideApply` cannot apply a patch to an existing resource. It is possible by turning off the schema validation which is already supported by Argo CD. I have provided the required updates and steps to verify the feature here. https://github.com/argoproj/argo-cd/issues/2437#issuecomment-1264964312

            However, the server side apply feature works as expected for the below
            1. ServerSideApply does not use the kubectl annotation to track the resources, so this feature can be used to managed large CRDs or configmaps with Argo CD. Users can use this feature if they have issues managing large resources due to the annotation limit.
            2. Field Manager is updated.

            Abhishek Veeramalla added a comment - However, the server side apply feature works as expected for the below 1. ServerSideApply does not use the kubectl annotation to track the resources, so this feature can be used to managed large CRDs or configmaps with Argo CD. Users can use this feature if they have issues managing large resources due to the annotation limit. 2. Field Manager is updated.

            1. An existing resource not managed by Argo CD goes into Out-of-Sync state when I tried to manage it using Argo CD ServerSideApply.
            I created an Upstream issue for the same.
            https://github.com/argoproj/argo-cd/issues/10740

            2. Argo CD ServerSideApply cannot apply a patch resource and fails with the error `incomplete yaml definition`.
            Example Patch resource:
            ```yaml
            apiVersion: apps/v1
            kind: Deployment
            metadata:
              labels:
                app: nginx
              name: nginx
              namespace: default
            spec:
              replicas: 2
            ```

            Abhishek Veeramalla added a comment - 1. An existing resource not managed by Argo CD goes into Out-of-Sync state when I tried to manage it using Argo CD ServerSideApply. I created an Upstream issue for the same. https://github.com/argoproj/argo-cd/issues/10740 2. Argo CD ServerSideApply cannot apply a patch resource and fails with the error `incomplete yaml definition`. Example Patch resource: ```yaml apiVersion: apps/v1 kind: Deployment metadata:   labels:     app: nginx   name: nginx   namespace: default spec:   replicas: 2 ```

              aveerama@redhat.com Abhishek Veeramalla
              jpitman63 John Pitman
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: