GoogleCloudPlatform / metacontroller

Lightweight Kubernetes controllers as a service
https://metacontroller.app/
Apache License 2.0
792 stars 105 forks source link

Move namespace to own manifest #133

Closed mgoodness closed 5 years ago

mgoodness commented 5 years ago

Allows kubectl apply -f manifests/ to create all required resources, including a metacontroller Namespace.

However, kustomization.yaml does not include that manifest in its resources, which lets kustomize handle namespace creation.

Replaces my borked #129.

enisoc commented 5 years ago

To get kubectl apply -f manifests/ to work, I had to rename namespace.yaml to kubernetes-namespace.yaml so it comes before kubernetes.yaml in the sort order.

I also tried with the latest Skaffold 0.20.0, and I'm not seeing it create the namespace automatically with either skaffold run or skaffold run -n metacontroller. Is it a feature of kustomize that it creates the namespace for you implicitly? It seems uncommon for tools to do that.

mgoodness commented 5 years ago

To get kubectl apply -f manifests/ to work, I had to rename namespace.yaml to kubernetes-namespace.yaml so it comes before kubernetes.yaml in the sort order.

I can prefix the manifests so kubectl loads them in the correct order.

Is it a feature of kustomize that it creates the namespace for you implicitly?

No, kustomize doesn't create namespaces implicitly. My original comment was misworded.

That said, I think the common pattern so far is to not include a namespace manifest in the base layer. End users then have a couple of options in their overlays.

resources:

namespace: my-namespace



The former seems like a good fit for tools like skaffold, while the latter is what I'm trying to do. Should I create a second `kustomization.yaml` for skaffold?
enisoc commented 5 years ago

Thanks for clarifying. I added some commits after yours that should maintain the intent of your PR while keeping our Skaffold workflow unchanged. Please let me know if you find any problems.

mgoodness commented 5 years ago

Perfect. Thanks!