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

tk diff/prune not respecting spec.namespace ? #1129

Open
strowi opened this issue Aug 8, 2024 · 0 comments
Open

tk diff/prune not respecting spec.namespace ? #1129

strowi opened this issue Aug 8, 2024 · 0 comments

Comments

@strowi
Copy link
Contributor

strowi commented Aug 8, 2024

Hi,

i noticed this rather unexpected behaviour with tk diff (tk prune same issue):

  1. deploying a resource in one namespace (e.g. secret)
  2. copying this resource it to another namespace (in our case with kubernetes-replicator)
  3. running tk diff as below it
  4. shows removal of the resouce in the other namespace, not defined in spec.namespace
~> tk --version
2024/08/08 22:56:45 tk version 0.28.0

~> tk env add --inject-labels --diff-strategy native --context-name cluster --namespace testing environments/test
~> cat > environments/test/main.jsonnet << EOF
{
  apiVersion: 'v1',
  kind: 'Secret',
  type: 'Opaque',
  metadata: {
    name: 'test',
  },
  data: {
    foo: 'YmFyCg=='
  },
}
EOF

~> kubectl create namespace testing
~> tk apply environments/test
...

~> kubectl get -n testing secret test -o json \
  |jq 'del(.metadata.annotations, .metadata.creationTimestamp, .metadata.resourceVersion, .metadata.uid)' \
  | jq '.metadata.namespace = "default"' \
  | kubectl apply -f - 

# diff wants to remove the secret in namespace "default"
~> tk diff --diff-strategy validate --with-prune --exit-zero --log-level warn environments/test

diff -u -N /tmp/diff4225968230/LIVE-v1.Secret.default.test /tmp/diff4225968230/MERGED-v1.Secret.default.test
--- /tmp/diff4225968230/LIVE-v1.Secret.default.test     2024-08-08 22:55:01.530504804 +0200
+++ /tmp/diff4225968230/MERGED-v1.Secret.default.test   2024-08-08 22:55:01.530504804 +0200
@@ -1,34 +0,0 @@
...

Looks like it is not respecting the spec.namespace when the environment label on resources outside that namespace?

Is this intentional? If so i think its very un-obvious, altough this might be an edge-case (we're replicating some configs into review-app namespaces).

regards,
strowi

@strowi strowi changed the title tk diff not respecting spec.namespace ? tk diff/prune not respecting spec.namespace ? Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Triage
Development

No branches or pull requests

1 participant