Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

(kedge init): add flag --controller #353

Merged
merged 2 commits into from
Oct 26, 2017

Conversation

surajssd
Copy link
Member

If this flag is specified with value being OnFailure or Never,
a controller of type Job is created.

Fixes #325

Copy link
Member

@kadel kadel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is creating a job, then maybe a better name for the flag would be --job what do you think?

@kadel
Copy link
Member

kadel commented Oct 13, 2017

It would be better if the name would be in the first place in generated Kedge output.

the output is correct, but looks a bit weird in this order

containers:
- image: image
controller: Job
name: name
restartPolicy: Never

@kadel
Copy link
Member

kadel commented Oct 13, 2017

The thing is that output of kedge init should be human consumable. The expectation is that users will edit and add stuff to it so it should be well formatted.

@surajssd
Copy link
Member Author

@kadel

If this is creating a job, then maybe a better name for the flag would be --job what do you think?

--job would be too specific of a flag. Later I envision of add flag called --controller, which basically changes the controller of the init file. Using which folks can generate DeploymentConfig or whatever controller support Kedge will have.


The thing is that output of kedge init should be human consumable. The expectation is that users will edit and add stuff to it so it should be well formatted.

Yeah true that, the golang template was being hard to maintain and add more things to it.

@kadel
Copy link
Member

kadel commented Oct 13, 2017

--job would be too specific of a flag. Later I envision of add flag called --controller, which basically changes the controller of the init file. Using which folks can generate DeploymentConfig or whatever controller support Kedge will have.

Then --restart OnFailure shouldn't create Job. Instead, regular DeploymentConfig should be used.

--controller job when implemented will create Job and set restartPolicy=OnFailure

@kadel
Copy link
Member

kadel commented Oct 13, 2017

Yeah true that, the golang template was being hard to maintain and add more things to it.

But output from this PR is complicating life for Kedge users, as generated kedge.yaml is going to be confusing to edit. Especially when we add more to it.

Templating might be better here, even if it is pain to maintain.

@surajssd
Copy link
Member Author

Then --restart OnFailure shouldn't create Job. Instead, regular DeploymentConfig should be used.

Deployment and DeploymentConfig should have restartPolicy as Always they can't have anything else!

@surajssd
Copy link
Member Author

@kadel how can I generate output of the yaml marshaller that is consistent with the structs that are backing it, any pointers?

@kadel
Copy link
Member

kadel commented Oct 13, 2017

Deployment and DeploymentConfig should have restartPolicy as Always they can't have anything else!

Ah, you are right.

Than we dont need restart flag for deployment.

The best thing would be to have this only for Job controller.

I think that it is better to have option that explicitly says that Job will be creted, rather than deciding what will be created based on restart flag.

@kadel
Copy link
Member

kadel commented Oct 13, 2017

@kadel how can I generate output of the yaml marshaller that is consistent with the structs that are backing it, any pointers?

don't understand the question :-(

@surajssd surajssd changed the title (kedge init): add flag --restart (kedge init): add flag --controller Oct 13, 2017
@surajssd
Copy link
Member Author

@kadel yeah make sense what you said, so removing the flag --restart rather adding flag --controller.

@surajnarwade
Copy link
Collaborator

+1 for replacing template with structs

@surajnarwade
Copy link
Collaborator

surajnarwade commented Oct 16, 2017

works for me & LGTM

@kadel
Copy link
Member

kadel commented Oct 16, 2017

+1 for for --controller flag.
Is it possible to control an order of files in yaml file?

It would be great to at least have name as the first field.

right now it looks like this:

containers:
- image: foobar
controller: DeploymentConfig
name: foobar
services:
- portMappings:
  - 80
  - 88

this would be much better:

name: foobar
controller: DeploymentConfig
containers:
- image: foobar

services:
- portMappings:
  - 80
  - 88

Copy link
Member

@kadel kadel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please extend user guide and add more information about kedge init? Especially --controller flag

@surajssd
Copy link
Member Author

@kadel

Can you please extend user guide and add more information about kedge init? Especially --controller flag

done

@surajssd
Copy link
Member Author

@kadel

Is it possible to control an order of files in yaml file?

not sure how do I do that because right now I am marshalling all those structs into yaml, not sure how to make the yaml library "github.com/ghodss/yaml" respect the struct field ordering!

@kadel
Copy link
Member

kadel commented Oct 23, 2017

I'm not sure what to do with this :-(

It makes our code a bit better, but on the other side it worsens User Experience a bit :-(

@@ -101,10 +101,32 @@ kedge version

## `kedge init`

Initialize kedge file
### Basic getting started
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think "getting start" should suffice

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

kedge init --name web --image centos/httpd --ports 80
```

This will create a `kedge.yml` file for a long running application running inside
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need "long running" here?
How about, "file for an httpd web server with container image centos/httpd"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


### Create a different controller type

By default the controller type that is created is Kubernetes Deployments, which
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"is a Kubernetes Deployment" - also a link to Kubernetes Deployment docs would help

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

which is Kubernetes Job, you can do that using the flag `--controller`.

```bash
kedge init --name myjob --image jobimage --controller Job
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lowercase "J" in job?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both are valid

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

### Create a different file

```bash
kedge init --file myapp.yml --name web --image centos/httpd --ports 80
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ kedge init --file myapp.yml --name web --image centos/httpd --ports 80
Error: unknown flag: --file
Usage:
  kedge init [flags]

Flags:
  -c, --controller string   The type of controller this application is. Legal values [Deployment, Job, DeploymentConfig]. Default 'Deployment'.
  -i, --image string        The image for the container to run
  -n, --name string         The name of service
  -o, --out string          Output filename (default "kedge.yml")
  -p, --ports intSlice      The ports that this container exposes

Global Flags:
      --provider string   Specify a provider. Kubernetes or OpenShift. (default "kubernetes")
  -v, --verbose           verbose output

unknown flag: --file

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

You can choose what type of controller is created using flag
`--controller`. The values you can give it are [Deployment,
DeploymentConfig, Job].
@concaf
Copy link
Collaborator

concaf commented Oct 23, 2017

@kadel about the UX part, I think kedge init will be used for initial getting started experience, which means very small kedge files. It would not take a lot of effort by the end user to find the name field.
Personally, I can live with it.
But if you think that it's a problem then I understand that too.

@kadel kadel merged commit 5609de7 into kedgeproject:master Oct 26, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants