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

Easy all-in-one launch command (was Run configuration generator) #1695

Closed
bgrant0607 opened this issue Oct 9, 2014 · 11 comments
Closed

Easy all-in-one launch command (was Run configuration generator) #1695

bgrant0607 opened this issue Oct 9, 2014 · 11 comments
Assignees
Labels
area/app-lifecycle area/example area/usability kind/design Categorizes issue or PR as related to design. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.

Comments

@bgrant0607
Copy link
Member

The run operation has not yet been implemented in the new kubectl command, for reasons discussed in #1325 and #2144. The high-level goal is to be able to make simple use cases simple and concise, while not creating a dead-end usage path that can't extend to more complex use cases or isn't composable with our other config/deployment/CLI tooling. For example, supporting or mimicking the (current) docker command line isn't a viable solution.

Requirements for a replacement:

  • It needs to be possible to access same generator functionality declaratively as is available imperatively using the CLI. A configuration generator will therefore be at the core of the approach. Configuration generation was first discussed in Proposal: Configuration #1007 and Example: configuration generation as build steps #1694, and some proof-of-concept generators were created by Config generator suite #1980 and podex: initial import #1537. The command-line arguments for the imperative command should be used to generate the config generator input schema, with as much of the intelligent defaulting inside the config generator (or even in the API e.g., container name should be optional in pod manifest #2643) as possible.
  • The config generator schema needs to be versioned. Otherwise, it will become unchangeable -- we've had this problem internally in spades. The default version can just be the latest one, but anyone who cares about reproducibility should be able to access any supported version of the generator via flag. That probably means the interpretation of the command-line flags needs to be versioned inside kubectl for this subcommand.
  • It needs to be straightforward to discover and manage (update, delete) the generated objects, using either the generator schema or the native objects.
  • It needs to be possible to just generate the primitive API objects without sending them to the apiserver, to facilitate a transition to declarative management.
  • The standard kubectl functionality for the primitive objects should be used to communicate with the API, not custom client calls.
  • There should be a path towards accessing a non-trivial amount of the power of the API, including multi-container pods and multiple replication controllers, though via somewhat opinionated idioms. I think we could combine podex, simplegen, and srvexpand, and add support for some additional deployment idioms (e.g., labels for env, app, tier/uservice, and track -- which could be inferred from image tags). We can use scoping rules and conflict inference to determine implicit nesting relationships. For example, 2 images in a row could go into the same pod, perhaps unless they exposed the same port(s). "replicas" or another attribute corresponding to a larger scope (multiple pods) would also indicate another pod / replication controller. If we want images to be the primary required input, they could be the sole unqualified arguments to the subcommand. An alternative approach would be to make scoping explicit and use a general-purpose way to specify object fields on the command line rather than from a config file.
  • Other planned config and deployment mechanisms should compose cleanly with it.
  • It should also eventually support non-RestartAlways containers, to the degree that Kubernetes supports them.

Not all of this needs to be supported out the gate, but whatever we build needs to be a compatible subset. For instance, we should decide whether command-line argument order should matter, how to specify schema fields on the command line, what flags we should use for a dry run (generation only), etc.

/cc @smarterclayton @ghodss @brendandburns @jlowdermilk @kmerker

@thockin
Copy link
Member

thockin commented Oct 10, 2014

I have not digested all your ideas today, but here's my one requirement: I
want a simple, small-N set of commands that can set up a replciation
controller, pods, and service. It needs to be dead simple for simple use
cases and for building tests around.

On Thu, Oct 9, 2014 at 2:40 PM, bgrant0607 notifications@github.com wrote:

The run operation is not being implemented in the new kubectl command, as
discussed in #1325
#1325. This is an
alternative approach.

Configuration generation was discussed in #1007
#1007. kubecfg
run could be replaced by this approach, plus perhaps helpers in kubectl
(e.g., something that converts arbitrary command-line args to flat json
fields).

Parameters to kubecfg's run operation could be expressed as JSON:

{
"simpleServiceName": "frontend",
"image": "brendanburns/php-redis",
"replicas": 3,
"ports": [{"containerPort": 80, "servicePort": 8000}]
}

This spec could be expanded by a program, which would generate the
corresponding pod template, replication controller, and service objects.
This translation would occur as part of a more general configuration
generation process (#1694
#1694).

/cc @ghodss https://github.com/ghodss

Reply to this email directly or view it on GitHub
#1695.

@bgrant0607
Copy link
Member Author

Well, even without run, 2 commands is sufficient. That could easily be scripted or wrapped with a library, if it's even worth it.

@thockin
Copy link
Member

thockin commented Oct 10, 2014

I am fine with 2 commands. what I don't want is

  • write a json file
  • run a command
  • write another file
  • run another command
  • write a third damned json file
  • run a command

On Thu, Oct 9, 2014 at 10:16 PM, bgrant0607 notifications@github.com
wrote:

Well, even without run, 2 commands is sufficient. That could easily be
scripted or wrapped with a library, if it's even worth it.

Reply to this email directly or view it on GitHub
#1695 (comment)
.

@bgrant0607
Copy link
Member Author

With the above proposal, a human would have to write at most 1 file, and not any file if we provided a way to generate the json. The number of commands required would depend on the amount of tooling/scripting we provided.

That said, a library of test utility/helper functions would be useful, and something like Run could go in such a library. It could also be implemented as a contrib script.

Run is not a primitive.

@thockin
Copy link
Member

thockin commented Oct 10, 2014

ACK that run is not a primitive, but we should make useful tools that cover
common use cases simply.

On Thu, Oct 9, 2014 at 11:14 PM, bgrant0607 notifications@github.com
wrote:

With the above proposal, a human would have to write at most 1 file, and
not any file if we provided a way to generate the json. The number of
commands required would depend on the amount of tooling/scripting we
provided.

That said, a library of test utility/helper functions would be useful, and
something like Run could go in such a library. It could also be implemented
as a contrib script.

Run is not a primitive.

Reply to this email directly or view it on GitHub
#1695 (comment)
.

@bgrant0607 bgrant0607 added this to the v1.0 milestone Oct 10, 2014
@bgrant0607 bgrant0607 self-assigned this Oct 21, 2014
@bgrant0607
Copy link
Member Author

For further inspiration, a comparison with Fig: https://gist.github.com/proppy/8e714bf41b6b0978ab0e#fig2kube

/cc @proppy @smarterclayton

I'm happy for kubectl to be able to invoke this directly (ideally as some kind of plugin, at least eventually), though it should also be possible to just dump the generated configs, as discussed in #1905.

@smarterclayton
Copy link
Contributor

I like the idea of pluggable transformation steps at some point - an example I was talking about today with someone was taking a pod generated by Podex and then transforming that into an openshift deployment config and image repository (find the docker repository the pod names, import it into openshift, then turn the pod template / replication controller into a deployment config and point to the image repository). Encouraging multiple step transformation / generation via plugins or other community ecosystem tools seems extremely positive, but it does potentially lead to more support issues.

@bgrant0607
Copy link
Member Author

@smarterclayton Let's discuss pluggability/composability in #1905.

@bgrant0607 bgrant0607 added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Dec 3, 2014
@bgrant0607 bgrant0607 changed the title Run configuration generator Easy all-in-one launch command (was Run configuration generator) Dec 11, 2014
@bgrant0607
Copy link
Member Author

Initial concrete proposal (feel free to bikeshed on the name, though I'm assuming we rename service to something more appropriate):

type UServiceSpec struct {
    ServiceSpec `json:",inline"`
    Count int `json:"count"`
    PodSpec `json:",inline"`
}

If/when we add additional fields to replicationController, as discussed in #3058, they should be bundled into a struct that can be inlined here (except selector, which would collide with the selector from ServiceSpec, though maybe the service reorg discussed in #2585 will also make that easy to avoid).

With aggressive defaulting, propagation of common metadata, and support for json on the command line as suggested in #3233, this could enable fairly simple configurations while including much of the power of the API in a maintainable way.

For example:

kubectl create uservice --app=guestbook count:3 containers:'[{image:brendanburns/redis-slave}]'

The command-line arguments could be mapped to the generator schema in a generic way.

Yes, the containers list is a little ugly, but having dealt with a system where I had to learn different syntaxes and schemas and default behaviors for multiple configuration DSLs and CLIs, as well as the API, I'd much prefer to just learn essentially one schema for object details.

We could also add an optional image field to the above to further simplify the trivial case of one container with no other parameters, while preserving the ability to use the full PodSpec if desired.

I could also imagine an all-in-one API synthetic "macro" control resource that would perform this expansion, rather than doing it on the client side, but we may not want to bite that off yet.

After deploying the microservice, if a user wanted to add another replicationController, such as for a canary, it should be straightforward, with the newly proposed kubectl commands, to add labels to the existing pods and replication controller, and then create the new one under the same service. They'd then use the label-selector-based multi-object kubectl commands to manage the whole constellation of objects.

@bgrant0607
Copy link
Member Author

With some reflection, I think the following could be made to work, without adding an image field:

kubectl create uservice --app=guestbook count:3 image:brendanburns/redis-slave

I'd be ok if the initial implementation weren't fully generic, but I don't want to start with CLI syntax that isn't extensible to the full realization.

@bgrant0607
Copy link
Member Author

Initial version of run-container is in. There are various improvements we could make (e.g., integrating podex, multi-container pods), but let's capture those in other issues and in cli-roadmap.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/app-lifecycle area/example area/usability kind/design Categorizes issue or PR as related to design. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Projects
None yet
Development

No branches or pull requests

3 participants