kubernetes / kubernetes

Production-Grade Container Scheduling and Management
https://kubernetes.io
Apache License 2.0
109.72k stars 39.29k forks source link

Add default config file lookup pattern #3268

Closed jasonkuhrt closed 4 years ago

jasonkuhrt commented 9 years ago

When kubectl is given a CRUD command for a resource (pod, replicationController, service), if it is not explicitly given a path to a config file, it should try a systematic file system lookup pattern for a config file for that resource.

Presumably these CRUD commands are being issued for a project and therefore I think the lookup pattern would not go beyond the cwd. However... it would be interesting if the command could be issues within any directory inside a project. git for instance gets away with this because it assumes the project root has a .git folder.

Some sketchy ideas:

  1. per-resource config files like .kubernetes-pod.yaml, .kubernetes-replicationController.yaml, etc.
  2. single config file like .kubernetes.yaml
  3. directory like .kubernetes with per-resource config files therein like pod.yaml, replicationController.yaml, etc.
  4. directory like .kubernetes with single config file like config.yaml

A .kubernetes folder seems somewhat interesting:

Do not necessarily take this idea too literally, its just a sketch for a general feature-characteristic. Lots of ways this could be skinned/go. The goal is ultimately:

  1. A way to streamline defaults (e.g. auto-discovered config files)
  2. A standard way for extensions to plant themselves
thockin commented 9 years ago

I don't understand. How is a default pod specification useful more than once, after which time the name is "in use"?

Can you explain more what utility you are trying to add or what problem you want to solve?

jasonkuhrt commented 9 years ago

Can you explain more what utility you are trying to add

Projects will have pod or replicationController config file(s) and also maybe service config file(s). kubectl should be able to find these without the user having to be explicit all the time.

jasonkuhrt commented 9 years ago

If users are creating various config file names in varying project folder locations, and if among the different approaches there are emerging cow paths, then Kubernetes core may want to pave them with smart defaults that streamline kubectl interactions.

thockin commented 9 years ago

I'm not sure this is a big enough win to warrant any code. It seems a bit surprising to me, but I could be convinced

On Wed, Jan 7, 2015 at 11:10 AM, Jason Kuhrt notifications@github.com wrote:

If the community is coming up with various config file names and locations that point to clear cow paths then Kubernetes core might as well automate what it can.

Reply to this email directly or view it on GitHub https://github.com/GoogleCloudPlatform/kubernetes/issues/3268#issuecomment-69073919 .

jasonkuhrt commented 9 years ago

@thockin When I created this issue I was in part punting the details to those with more experience, who could relate the idea to use-cases they'd had or seen. I'll need more time with kubernetes myself to flush out the use-cases I'm seeing across many projects. If after some time this issue is still an echo chamber then probably I've just been thinking about/using Kubernetes wrong.

thockin commented 9 years ago

Fair enough - no harm in seeking supporting evidence for an idea :)

On Wed, Jan 7, 2015 at 1:34 PM, Jason Kuhrt notifications@github.com wrote:

@thockin https://github.com/thockin When I created this issue I was in part punting the details to those with more experience, who could relate the idea to use-cases they'd had or seen. I'll need more time with kubernetes myself to flush out the use-cases I'm seeing across many projects. If after some time this issue is still an echo chamber then probably I've just been thinking about/using Kubernetes wrong.

Reply to this email directly or view it on GitHub https://github.com/GoogleCloudPlatform/kubernetes/issues/3268#issuecomment-69096078 .

bgrant0607 commented 9 years ago

Like Makefiles and Dockerfiles? Those at least process other files in the same directory. I'm not sure this makes sense for kubectl. kubectl does already have the ability to slurp in all the config files in a directory (kubectl create -f dir), so this would be like making cwd the default, which I don't particularly see as a desirable feature, as would be error prone.

jasonkuhrt commented 9 years ago

Like Makefiles and Dockerfiles? Those at least process other files in the same directory

Yes I think that's a decent starting point for this idea.

kubectl does already have the ability to slurp in all the config files in a directory (kubectl create -f dir)

I agree this alleviates the issue somewhat

so this would be like making cwd the default, which I don't particularly see as a desirable feature, as would be error prone.

Agreed cwd would not work. A folder might though, such as .kubernetes or .kube or no dot-prefix variants...

There's a good chance that this feature is invalid.

jasonkuhrt commented 9 years ago

@bgrant0607 Another use-case that I am envisioning is analogous to editor plugins. For instance there is a module called flycheck for emacs which is a emacs linting framework that allows additional modules to be written that lint for particular languages. Unfortunately, one awful default is that flycheck_* files are created all over the file system as files are opened/edited/closed.

The point here is that emacs or some emacs packaging tool never provided a reliable folder-space system which modules can use to provide sane defaults.

The reason this is analogous to Kubernetes is that I'm just wondering/imaging that plugins that extend kubectl may also have need to interact with the file system in some way. If this is likely then its certainly worth Kubernetes project investing a little into some filesystem defaults so that good defaults can be enjoyed by everyone.

jasonkuhrt commented 9 years ago

This last comment is somewhat out of scope of the issue title. I admit I'm somewhat making up the issue as I go here. It just began as a sense.

bgrant0607 commented 9 years ago

@jasonkuhrt If you haven't seen it, take a look at https://github.com/GoogleCloudPlatform/kubernetes/tree/master/pkg/kubectl/cmd/config

jasonkuhrt commented 9 years ago

@bgrant0607 Ah cool. Will take a closer look later but I guess a new command to work with settings painlessly?

bgrant0607 commented 9 years ago

Yes. See the section on "config" here: https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/kubectl.md

bgrant0607 commented 8 years ago

Tools from the community are doing this:

https://github.com/helm/helm https://github.com/kubernauts/kploy https://github.com/flexiant/kdeploy https://github.com/kubespray/kpm

bgrant0607 commented 8 years ago

cc @ethernetdan

dims commented 8 years ago

@bgrant0607 @thockin seems like we can close this issue?

bgrant0607 commented 8 years ago

@dims No, this is still a valid issue. Why do you think it should be closed?

dims commented 8 years ago

@bgrant0607 was wondering aloud since the last few comments were old.

bgrant0607 commented 8 years ago

@dims Nobody has had time to do it. I have listed it as something we want to do, here: https://github.com/kubernetes/community/wiki/Roadmap:-kubectl

bgrant0607 commented 8 years ago

See also https://github.com/kubernetes/kubernetes/issues/24649#issuecomment-213489912

dims commented 8 years ago

Thanks @bgrant0607 !

liggitt commented 6 years ago

magic implicit file input doesn't seem great... what was the reason for reopening this?

bgrant0607 commented 6 years ago

@liggitt Current default behavior is to look for files with .yaml, .yml, and .json suffixes in a directory. Keeping this open regarding providing a way to override that behavior with a file of a well known name.

bgrant0607 commented 6 years ago

/lifecycle frozen

brianpursley commented 4 years ago

Hi @bgrant0607. This issue has been open a long time, so I'm just checking to see if this issue is still valid or if it is taken care of by kubectl apply -k or helm, etc.

brianpursley commented 4 years ago

/kind feature

bgrant0607 commented 4 years ago

@brianpursley Yes, I think it's addressed by kustomize, or at least addressed as it's going to be. kubectl has a long-established, documented convention of specifying files and directories explicitly. /close

k8s-ci-robot commented 4 years ago

@bgrant0607: Closing this issue.

In response to [this](https://github.com/kubernetes/kubernetes/issues/3268#issuecomment-622263144): >@brianpursley Yes, I think it's addressed by kustomize, or at least addressed as it's going to be. kubectl has a long-established, documented convention of specifying files and directories explicitly. >/close Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.