If you would like to try this feature you can either build Argo CD from master or use the below Docker Image(not recommended for production or per-production).
Enable Server-Side Apply and turn off Schema Validation(not required in the below example, but this is similar to kubectl apply — server-side — validate=false.
This is required when you try to update anything in .spec).
Argo CD Server-Side Apply
By default, ArgoCD executes kubectl apply operation to apply the configuration stored in Git. This is a client side operation that relies on kubectl.kubernetes.io/last-applied-configuration annotation to store the previous resource state.
- In some cases the resource is too big to fit in 262144 bytes allowed annotation size. In this case server-side apply can be used to avoid this issue as the annotation is not used in this case.
- Apart from this Server-Side Apply can also be used to patch an existing resource that is not managed or deployed by Argo CD.
If the ServerSideApply=true sync option is set the ArgoCD will use kubectl apply — server-side command to apply changes.
This can also be configured at individual resource level.
Let’s try Server-Side Apply with a basic configuration
We will label a simple nginx deployment that is already available on the cluster and not managed by Argo CD. Let’s start with creating the nginx deployment.
1. Create a nginx deployment.
kubectl create deployment nginx — image=nginx
2. Patch the object that only includes the fields and values for which the user has an opinion. We will patch the nginx deployment with label
— Place the below nginx deployment in a git repo.
3. Create an Argo CD Application that points to the git repo and path as shown below.
4. Finally you will see that the new label `foo:bar` is attached to the nginx deployment.