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

Diffing with slash in field name #2795

Closed
mg03 opened this issue Dec 2, 2019 · 5 comments · Fixed by #15144
Closed

Diffing with slash in field name #2795

mg03 opened this issue Dec 2, 2019 · 5 comments · Fixed by #15144
Labels
component:core Syncing, diffing, cluster state cache

Comments

@mg03
Copy link

mg03 commented Dec 2, 2019

Hi

I want to use ignoreDifferences for a annotation field in all services.
In order to set it up as a system level configuration, I am modifying the argo-cm configmap.

Qs 1) What would be the resource name that I need to use for services?

Qs 2) In the ignoreDifferences section, can I provide a fieldname with a slash in it? suppose field name is "string1/string2"

data:
resource.customizations: |
<what is this for services????>:
ignoreDifferences: |
jsonPointers:
- /metadata/annotations/string1/string2

@alexec
Copy link
Contributor

alexec commented Dec 3, 2019

These are JSON pointers. I believe you can use tilde character.

https://tools.ietf.org/html/rfc6901

@mg03
Copy link
Author

mg03 commented Dec 4, 2019

ok thanx @alexec and the resource name under resource customizations does it follow a format. Is the format: APIGROUP/KIND?

@jannfis jannfis added component:core Syncing, diffing, cluster state cache type:docs labels May 14, 2020
@Lirt
Copy link

Lirt commented Apr 12, 2021

So for example if I want to reference annotation checksum/certs from yaml like this:

metadata:
  annotations:
    checksum/certs: "CHECKSUM"

RFC says that / is encoded as ~1, so appropriate json pointer is this /metadata/annotations/checksum~1certs?

@maximmold
Copy link

I'm having issues ignoring a label in a CRD. It appears that K8S is automatically removing it for some reason and I'd like to just ignore it if the label is there in source control, but not showing up in K8S.

The CRD looks like this

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  labels:
    app.kubernetes.io/name: velero

Here is my application spec...

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: velero
  namespace: argocd
spec:
  project: tools
  source:
    repoURL: 'https://github.com/../...'
    plugin:
      
  ignoreDifferences:
    - group: apiextensions.k8s.io/v1beta1
      kind: CustomResourceDefinition
      namespace: velero
      jsonPointers:
        - /metadata/labels/app.kubernetes.io~1name

Does this not work with the custom plugin?

@younsl
Copy link

younsl commented Aug 27, 2024

You can escape it by replacing the slash / with ~1 in the argocd application's jsonPointers.

Example of slash escaping an annotation named checksum/clusteragent_token:

# argocd application resource yaml
spec:
  ignoreDifferences:
    - kind: Secret
      name: datadog-cluster-agent
      jsonPointers:
        - /data/token
    - group: apps
      kind: Deployment
      name: datadog-cluster-agent
      jsonPointers:
        - /spec/template/metadata/annotations/checksum~1clusteragent_token
    - group: apps
      kind: Deployment
      name: datadog-clusterchecks
      jsonPointers:
        - /spec/template/metadata/annotations/checksum~1clusteragent_token

Other slash escape example in argocd docs:

If you have a slash / in your pointer path, you need to replace it with the ~1 character.
For example:

spec:
  ignoreDifferences:
  - kind: Node
    jsonPointers: /metadata/labels/node-role.kubernetes.io~1worker

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:core Syncing, diffing, cluster state cache
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants