-
Notifications
You must be signed in to change notification settings - Fork 169
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
feat(process): Naive namespaces #312
Conversation
Now that lists are always unwrapped, we assume all other objects use `ObjectMeta`, so they do accept a namespace, regardless of whether they actually use it. This allows us to simplify our code, by always setting it. For yet unknown edge-cases, we allow using the `tanka.dev/namespaced` annotation to override this behaviour.
Not required anymore as namespaces are again supplied in YAML
Here's my concern about just adding namespaces to everything without exception: If I wanted to export into a file tree like The kubernetes API won't complain, but things will not necessarily go into the directories I'd want them to. Of course we could also work around this by having a set of overlays we put over the k8s jsonnet lib that add the annotation to those constructors as well. |
How would this affect an 'environment' with resources across namespaces? I would ideally like to have a setup like
Where the App environments are all under 1 namespace but the cluster baseline is spread across a few. |
@hamishforbes this should behave exactly as it did before, at least during apply. Tanka will only ever set the namespace defined in Only two differences will be there:
|
I'd rather see Tanka or Kubectl return an error (or at least a warning), expecting the developer/jsonnet to set the namespace instead, depending on Tanka to resolve the namespace promotes negligence imo. |
Verifies that metadata.annotations and metadata.labels are of correct type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM,
I do wish we could have a simple list of cluster-wide resources to skip namespacing on, but I can add that in a separate PR.
Would it be an option for this behaviour to be configurable? I think I would prefer to require namespace to be explicitly set and it would be easier to lint/validate in a CI pipeline if Tanka didn't automatically inject namespaces. |
@hamishforbes There is already discussion going about about this exact thing internally and I am happy to have this debate more broadly. Could you open a separate issue for this? Generally spoken, in an attempt to have as few knobs as possible, I am not a fan of configurable things. Instead, we should aim for a solution that works better for everybody. Also you could join our monthly community call (https://docs.google.com/document/d/1mEsc0GxlnwbWAXzbIP7tBb6T5WgAI66_0gIWJzqB93o) this evening and bring this up! |
The manifest.Manifest is a `map[string]interface{}`, which sticks to what `json.Unmarshal` returns, meaning it only includes concrete values, `[]interface{}` and `map[string]interface{}`. In a v0.10 change (https://github.com/grafana/tanka/blob/a6d5fde5aac69dc4d66bb57d5a501e52ba60fada/pkg/kubernetes/manifest/manifest.go#L248) I accidentally broke that, without realizing it. Up to #312, this didn't create any issues. Now however, because we called `Annotations` on all objects, types weren't like they should have been. This caused subsetdiff to miss annotations, not computing the subset on them at all. Fixes #318
The manifest.Manifest is a `map[string]interface{}`, which sticks to what `json.Unmarshal` returns, meaning it only includes concrete values, `[]interface{}` and `map[string]interface{}`. In a v0.10 change (https://github.com/grafana/tanka/blob/a6d5fde5aac69dc4d66bb57d5a501e52ba60fada/pkg/kubernetes/manifest/manifest.go#L248) I accidentally broke that, without realizing it. Up to #312, this didn't create any issues. Now however, because we called `Annotations` on all objects, types weren't like they should have been. This caused subsetdiff to miss annotations, not computing the subset on them at all. Fixes #318
Now that lists are always unwrapped, we assume all other objects use
ObjectMeta
, so they do accept a namespace, regardless of whether they actually use it.This allows us to simplify our code, by always setting it. For yet unknown edge-cases, we allow using the
tanka.dev/namespaced
annotation to override this behaviour.Removed the nsPatch injection method, as it is not needed anymore. Show and Apply will behave exactly the same now.
I decided against implementing a default list for cluster-wide resources, because this seems to make things only marginally more correct in theory, but has no effect on the outcome, but comes at the cost of maintaining yet another static list in our code. Quick analysis suggested there is no official type that won't use ObjectMeta, which makes me pretty confident here.
Fixes #269
Fixes #308