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

Defining applications in a single file #17

Closed
concaf opened this issue Jun 14, 2017 · 15 comments
Closed

Defining applications in a single file #17

concaf opened this issue Jun 14, 2017 · 15 comments
Assignees

Comments

@concaf
Copy link
Collaborator

concaf commented Jun 14, 2017

Looking at the examples, the only way I can see for defining multiple microservices, is by putting them in different files.

e.g. - https://github.com/surajssd/opencomposition/tree/master/examples/allnomagic here, db.yaml and web.yaml have to be separate files.

This is fine and good practice under certain scenarios, but I also want to be able to define this in a single file.

@pradeepto
Copy link
Member

Any particular reason why you would want to define the whole thing in a single file? Advantages? Would this not lead to "more than "one true way" to do things scenario"?

@kadel
Copy link
Member

kadel commented Jun 14, 2017

I think its OK to force one file / one app way.

@concaf
Copy link
Collaborator Author

concaf commented Jun 14, 2017

Having multiple files for different microservices makes no sense for smaller applications, that will just increase the user time.
We should be giving the user the choice to do whichever way they want, not what we think is correct for them.
I strongly disagree in enforcing one way for the user to structure their application, we should not be doing that, it should be left up to them. The tooling should be able to take in multiple files at the same time and do the conversion/deployment.

@kadel
Copy link
Member

kadel commented Jun 14, 2017

We can always add support for multiple apps in one file later.
Let's try to go with the one file one app for now.
If it's proven cumbersome we can always add support for it later.

@pradeepto
Copy link
Member

But the whole point of James S was that we should write define one application/service per file. If we do it otherwise or keep that as a second priority, I am not sure how this serves the purpose.

@pradeepto
Copy link
Member

Having multiple files for different microservices makes no sense for smaller applications, that will just increase the user time.

I can perhaps agree with that but ...

We should be giving the user the choice to do whichever way they want, not what we think is correct for them.

Being opinionated is very important.

I strongly disagree in enforcing one way for the user to structure their application, we should not be doing that, it should be left up to them.

We are enforcing other things, I am sure. So why not this bit?

@concaf
Copy link
Collaborator Author

concaf commented Jun 14, 2017

@pradeepto -

But the whole point of James S was that we should write define one application/service per file. If we do it otherwise or keep that as a second priority, I am not sure how this serves the purpose.

Yes, he did, and I respectfully disagree.

We are enforcing other things, I am sure. So why not this bit?

We should not be enforcing everything.

IMHO, this is a huge step backward in terms of UX, we should let the users decide how they want to structure their application, and what fits best for their scenario, if they want to keep everything in the same file or they want put it in different version control. This increases my developer time by a lot if I have 2 small microservices, and I have to juggle between files.

Every spec that I know of provides a way to define multiple objects in one file, OpenShift templates, Docker Compose, OpenCompose.

@pradeepto
Copy link
Member

OK. But doing multiple apps in multiple files shouldn't be a secondary requirement.

@concaf
Copy link
Collaborator Author

concaf commented Jun 14, 2017

@pradeepto what does secondary requirement mean here?

@surajssd surajssd changed the title Defining applications is a single file Defining applications in a single file Jun 14, 2017
@concaf
Copy link
Collaborator Author

concaf commented Jun 14, 2017

let's decrease the priority and reconsider this later

@concaf
Copy link
Collaborator Author

concaf commented Jun 21, 2017

or let's not! :)

One way can be that we support defining multiple services by separating with a ---, so a small file will look like -

name: web
containers:
- image: quay.io/tomkral/nonroot-nginx
services:
- ports:
  - port: 8080
---
name: db
containers:
- image: mongo
services:
- ports:
  - port: 3306

Thoughts on this? @pradeepto @kadel @surajssd

@kadel
Copy link
Member

kadel commented Jun 22, 2017

I still don't think that we have a good reason to do that.

But if we are doing it than what @containscafeine is suggesting is a good way to do it.

@surajssd
Copy link
Member

One way can be that we support defining multiple services by separating with a ---, so a small file will look like -

@containscafeine 👍

@surajssd
Copy link
Member

But having everything in one file is a bad idea, because:

  • programmers are more comfortable with multiple files as opposed to single file having everything

  • also it brings separation of concerns since each team will be working on their own micro-service which is part of whole application

  • this brings in complications of how do we do conversion, should we convert everything each time or do we allow user a mechanism to say only convert this particular one app from list of apps

  • since we don't need to create configs of database everytime but only of the app user is working on

  • so with current approach we can do:

    • day0:
$ kapp convert -f db.yaml -f web.yaml | oc create -f -
- day1: when the app has changed
$ kapp convert -f web.yaml | oc apply -f -
  • With new approach I don't know how this will happen maybe we will have to add flags that says only convert this particular app using some extra flag or something like that, not sure how this is improving UX in anyway.

@concaf concaf self-assigned this Jun 27, 2017
@concaf
Copy link
Collaborator Author

concaf commented Jun 27, 2017

@surajssd -

this brings in complications of how do we do conversion, should we convert everything each time or do we allow user a mechanism to say only convert this particular one app from list of apps

I think for this issue we should generate everything, and then specifying one particular app for generation should be covered separately, but I agree, it should be.

Also, I agree that this is not going to improve UX a lot, but this could be a use case, so let's go ahead and this. This will not be the preferred way of doing it, but one of the ways!

TODO:

  • Open an issue to track specifying the app to generate k8s artifacts for, once this issue is implemented

concaf added a commit to concaf/kedge that referenced this issue Jun 28, 2017
Before this commit, every application had to be defined in a
separate file, and while deploying, had to be passed to the CLI
like `kapp covert -f app1.yml -f app2.yml`.

In this commit, support for defining multiple applications in one
file separated by triple dashes has been added, which means that
Kubernetes artifacts for all the applications defined in a given
file will be generated.

A sample application defined like this will look like -

name: database
containers:
- image: mariadb:10
services:
- ports:
  - port: 3306
---
name: wordpress
containers:
- image: wordpress:4
services:
- ports:
  - port: 8080
    targetPort: 80

This commit also adds an example for this behavior.

Fix kedgeproject#17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants