-
Notifications
You must be signed in to change notification settings - Fork 770
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
make YAML the default kompose conversion #339
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,12 +26,12 @@ import ( | |
) | ||
|
||
var ( | ||
ConvertSource, ConvertOut, ConvertBuildRepo, ConvertBuildBranch string | ||
ConvertChart, ConvertDeployment, ConvertDaemonSet bool | ||
ConvertReplicationController, ConvertYaml, ConvertStdout bool | ||
ConvertEmptyVols, ConvertDeploymentConfig, ConvertBuildConfig bool | ||
ConvertReplicas int | ||
ConvertOpt kobject.ConvertOptions | ||
ConvertSource, ConvertOut, ConvertBuildRepo, ConvertBuildBranch string | ||
ConvertChart, ConvertDeployment, ConvertDaemonSet bool | ||
ConvertReplicationController, ConvertYaml, ConvertStdout, ConvertJson bool | ||
ConvertEmptyVols, ConvertDeploymentConfig, ConvertBuildConfig bool | ||
ConvertReplicas int | ||
ConvertOpt kobject.ConvertOptions | ||
) | ||
|
||
var ConvertProvider string = GlobalProvider | ||
|
@@ -46,6 +46,7 @@ var convertCmd = &cobra.Command{ | |
ToStdout: ConvertStdout, | ||
CreateChart: ConvertChart, | ||
GenerateYaml: ConvertYaml, | ||
GenerateJson: ConvertJson, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can get rid of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After doing some iterations on trying to get rid of ConvertYaml it feels like it's only making code more convoluted in terms of making checks and validation, I think we can get rid of ConvertYaml once we decide we wanna get rid of the flag. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @surajssd feels cleaner to have both, right? json + yaml generation (by default, you can set the value of GenerateYaml to |
||
Replicas: ConvertReplicas, | ||
InputFiles: GlobalFiles, | ||
OutFile: ConvertOut, | ||
|
@@ -92,7 +93,10 @@ func init() { | |
convertCmd.Flags().MarkHidden("build-branch") | ||
|
||
// Standard between the two | ||
convertCmd.Flags().BoolVarP(&ConvertYaml, "yaml", "y", false, "Generate resource files into yaml format") | ||
convertCmd.Flags().BoolVarP(&ConvertYaml, "yaml", "y", false, "Generate resource files into YAML format") | ||
convertCmd.Flags().MarkDeprecated("yaml", "YAML is the default format now.") | ||
convertCmd.Flags().MarkShorthandDeprecated("y", "YAML is the default format now.") | ||
convertCmd.Flags().BoolVarP(&ConvertJson, "json", "j", false, "Generate resource files into JSON format") | ||
convertCmd.Flags().BoolVar(&ConvertStdout, "stdout", false, "Print converted objects to stdout") | ||
convertCmd.Flags().BoolVar(&ConvertEmptyVols, "emptyvols", false, "Use Empty Volumes. Do not generate PVCs") | ||
convertCmd.Flags().StringVarP(&ConvertOut, "out", "o", "", "Specify a file name to save objects to") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ $ cd examples/ | |
$ ls | ||
docker-compose.yml docker-compose-bundle.dab docker-gitlab.yml docker-voting.yml | ||
|
||
$ kompose -f docker-gitlab.yml convert -y | ||
$ kompose -f docker-gitlab.yml convert | ||
file "redisio-svc.yaml" created | ||
file "gitlab-svc.yaml" created | ||
file "postgresql-svc.yaml" created | ||
|
@@ -46,43 +46,43 @@ You can try with a Docker Compose version 2 like this: | |
$ kompose --file docker-voting.yml convert | ||
WARN[0000]: Unsupported key networks - ignoring | ||
WARN[0000]: Unsupported key build - ignoring | ||
file "worker-svc.json" created | ||
file "db-svc.json" created | ||
file "redis-svc.json" created | ||
file "result-svc.json" created | ||
file "vote-svc.json" created | ||
file "redis-deployment.json" created | ||
file "result-deployment.json" created | ||
file "vote-deployment.json" created | ||
file "worker-deployment.json" created | ||
file "db-deployment.json" created | ||
file "worker-svc.yaml" created | ||
file "db-svc.yaml" created | ||
file "redis-svc.yaml" created | ||
file "result-svc.yaml" created | ||
file "vote-svc.yaml" created | ||
file "redis-deployment.yaml" created | ||
file "result-deployment.yaml" created | ||
file "vote-deployment.yaml" created | ||
file "worker-deployment.yaml" created | ||
file "db-deployment.yaml" created | ||
|
||
$ ls | ||
db-deployment.json docker-compose.yml docker-gitlab.yml redis-deployment.json result-deployment.json vote-deployment.json worker-deployment.json | ||
db-svc.json docker-compose-bundle.dab docker-voting.yml redis-svc.json result-svc.json vote-svc.json worker-svc.json | ||
db-deployment.yaml docker-compose.yml docker-gitlab.yml redis-deployment.yaml result-deployment.yaml vote-deployment.yaml worker-deployment.yaml | ||
db-svc.yaml docker-compose-bundle.dab docker-voting.yml redis-svc.yaml result-svc.yaml vote-svc.yaml worker-svc.yaml | ||
``` | ||
|
||
You can also provide multiple docker-compose files at the same time: | ||
|
||
```console | ||
$ kompose -f docker-compose.yml -f docker-guestbook.yml convert | ||
file "frontend-service.json" created | ||
file "mlbparks-service.json" created | ||
file "mongodb-service.json" created | ||
file "redis-master-service.json" created | ||
file "redis-slave-service.json" created | ||
file "frontend-deployment.json" created | ||
file "mlbparks-deployment.json" created | ||
file "mongodb-deployment.json" created | ||
file "mongodb-claim0-persistentvolumeclaim.json" created | ||
file "redis-master-deployment.json" created | ||
file "redis-slave-deployment.json" created | ||
file "frontend-service.yaml" created | ||
file "mlbparks-service.yaml" created | ||
file "mongodb-service.yaml" created | ||
file "redis-master-service.yaml" created | ||
file "redis-slave-service.yaml" created | ||
file "frontend-deployment.yaml" created | ||
file "mlbparks-deployment.yaml" created | ||
file "mongodb-deployment.yaml" created | ||
file "mongodb-claim0-persistentvolumeclaim.yaml" created | ||
file "redis-master-deployment.yaml" created | ||
file "redis-slave-deployment.yaml" created | ||
|
||
$ ls | ||
mlbparks-deployment.json mongodb-service.json redis-slave-service.jsonmlbparks-service.json | ||
frontend-deployment.json mongodb-claim0-persistentvolumeclaim.json redis-master-service.json | ||
frontend-service.json mongodb-deployment.json redis-slave-deployment.json | ||
redis-master-deployment.json | ||
mlbparks-deployment.yaml mongodb-service.yaml redis-slave-service.jsonmlbparks-service.yaml | ||
frontend-deployment.yaml mongodb-claim0-persistentvolumeclaim.yaml redis-master-service.yaml | ||
frontend-service.yaml mongodb-deployment.yaml redis-slave-deployment.yaml | ||
redis-master-deployment.yaml | ||
``` | ||
|
||
When multiple docker-compose files are provided the configuration is merged. Any configuration that is common will be over ridden by subsequent file. | ||
|
@@ -92,43 +92,43 @@ Using `--bundle, --dab` to specify a DAB file as below: | |
```console | ||
$ kompose --bundle docker-compose-bundle.dab convert | ||
WARN[0000]: Unsupported key networks - ignoring | ||
file "redis-svc.json" created | ||
file "web-svc.json" created | ||
file "web-deployment.json" created | ||
file "redis-deployment.json" created | ||
file "redis-svc.yaml" created | ||
file "web-svc.yaml" created | ||
file "web-deployment.yaml" created | ||
file "redis-deployment.yaml" created | ||
``` | ||
|
||
### OpenShift | ||
|
||
```console | ||
$ kompose --provider openshift --file docker-voting.yml convert | ||
WARN[0000] [worker] Service cannot be created because of missing port. | ||
INFO[0000] file "vote-service.json" created | ||
INFO[0000] file "db-service.json" created | ||
INFO[0000] file "redis-service.json" created | ||
INFO[0000] file "result-service.json" created | ||
INFO[0000] file "vote-deploymentconfig.json" created | ||
INFO[0000] file "vote-imagestream.json" created | ||
INFO[0000] file "worker-deploymentconfig.json" created | ||
INFO[0000] file "worker-imagestream.json" created | ||
INFO[0000] file "db-deploymentconfig.json" created | ||
INFO[0000] file "db-imagestream.json" created | ||
INFO[0000] file "redis-deploymentconfig.json" created | ||
INFO[0000] file "redis-imagestream.json" created | ||
INFO[0000] file "result-deploymentconfig.json" created | ||
INFO[0000] file "result-imagestream.json" created | ||
INFO[0000] file "vote-service.yaml" created | ||
INFO[0000] file "db-service.yaml" created | ||
INFO[0000] file "redis-service.yaml" created | ||
INFO[0000] file "result-service.yaml" created | ||
INFO[0000] file "vote-deploymentconfig.yaml" created | ||
INFO[0000] file "vote-imagestream.yaml" created | ||
INFO[0000] file "worker-deploymentconfig.yaml" created | ||
INFO[0000] file "worker-imagestream.yaml" created | ||
INFO[0000] file "db-deploymentconfig.yaml" created | ||
INFO[0000] file "db-imagestream.yaml" created | ||
INFO[0000] file "redis-deploymentconfig.yaml" created | ||
INFO[0000] file "redis-imagestream.yaml" created | ||
INFO[0000] file "result-deploymentconfig.yaml" created | ||
INFO[0000] file "result-imagestream.yaml" created | ||
``` | ||
|
||
In similar way you can convert DAB files to OpenShift. | ||
```console | ||
$ kompose --bundle docker-compose-bundle.dab --provider openshift convert | ||
WARN[0000]: Unsupported key networks - ignoring | ||
INFO[0000] file "redis-svc.json" created | ||
INFO[0000] file "web-svc.json" created | ||
INFO[0000] file "web-deploymentconfig.json" created | ||
INFO[0000] file "web-imagestream.json" created | ||
INFO[0000] file "redis-deploymentconfig.json" created | ||
INFO[0000] file "redis-imagestream.json" created | ||
INFO[0000] file "redis-svc.yaml" created | ||
INFO[0000] file "web-svc.yaml" created | ||
INFO[0000] file "web-deploymentconfig.yaml" created | ||
INFO[0000] file "web-imagestream.yaml" created | ||
INFO[0000] file "redis-deploymentconfig.yaml" created | ||
INFO[0000] file "redis-imagestream.yaml" created | ||
``` | ||
|
||
It also supports creating buildconfig for build directive in a service. By default, it uses the remote repo for the current git branch as the source repo, and the current branch as the source branch for the build. You can specify a different source repo and branch using ``--build-repo`` and ``--build-branch`` options respectively. | ||
|
@@ -137,9 +137,9 @@ It also supports creating buildconfig for build directive in a service. By defau | |
kompose --provider openshift --file buildconfig/docker-compose.yml convert | ||
WARN[0000] [foo] Service cannot be created because of missing port. | ||
INFO[0000] Buildconfig using [email protected]:rtnpro/kompose.git::master as source. | ||
INFO[0000] file "foo-deploymentconfig.json" created | ||
INFO[0000] file "foo-imagestream.json" created | ||
INFO[0000] file "foo-buildconfig.json" created | ||
INFO[0000] file "foo-deploymentconfig.yaml" created | ||
INFO[0000] file "foo-imagestream.yaml" created | ||
INFO[0000] file "foo-buildconfig.yaml" created | ||
``` | ||
|
||
**Note**: If you are manually pushing the Openshift artifacts using ``oc create -f``, you need to ensure that you push the imagestream artifact before the buildconfig artifact, to workaround this Openshift issue: https://github.com/openshift/origin/issues/4518 . | ||
|
@@ -237,10 +237,10 @@ Note: | |
|
||
## Alternate formats | ||
|
||
The default `kompose` transformation will generate Kubernetes [Deployments](http://kubernetes.io/docs/user-guide/deployments/) and [Services](http://kubernetes.io/docs/user-guide/services/), in json format. You have alternative option to generate yaml with `-y`. Also, you can alternatively generate [Replication Controllers](http://kubernetes.io/docs/user-guide/replication-controller/) objects, [Deamon Sets](http://kubernetes.io/docs/admin/daemons/), or [Helm](https://github.com/helm/helm) charts. | ||
The default `kompose` transformation will generate Kubernetes [Deployments](http://kubernetes.io/docs/user-guide/deployments/) and [Services](http://kubernetes.io/docs/user-guide/services/), in yaml format. You have alternative option to generate json with `-j`. Also, you can alternatively generate [Replication Controllers](http://kubernetes.io/docs/user-guide/replication-controller/) objects, [Deamon Sets](http://kubernetes.io/docs/admin/daemons/), or [Helm](https://github.com/helm/helm) charts. | ||
|
||
```console | ||
$ kompose convert | ||
$ kompose convert -j | ||
file "redis-svc.json" created | ||
file "web-svc.json" created | ||
file "redis-deployment.json" created | ||
|
@@ -249,17 +249,17 @@ file "web-deployment.json" created | |
The `*-deployment.json` files contain the Deployment objects. | ||
|
||
```console | ||
$ kompose convert --rc -y | ||
$ kompose convert --rc | ||
file "redis-svc.yaml" created | ||
file "web-svc.yaml" created | ||
file "redis-rc.yaml" created | ||
file "web-rc.yaml" created | ||
``` | ||
|
||
The `*-rc.yaml` files contain the Replication Controller objects. If you want to specify replicas (default is 1), use `--replicas` flag: `$ kompose convert --rc --replicas 3 -y` | ||
The `*-rc.yaml` files contain the Replication Controller objects. If you want to specify replicas (default is 1), use `--replicas` flag: `$ kompose convert --rc --replicas 3` | ||
|
||
```console | ||
$ kompose convert --ds -y | ||
$ kompose convert --ds | ||
file "redis-svc.yaml" created | ||
file "web-svc.yaml" created | ||
file "redis-daemonset.yaml" created | ||
|
@@ -271,7 +271,7 @@ The `*-daemonset.yaml` files contain the Daemon Set objects | |
If you want to generate a Chart to be used with [Helm](https://github.com/kubernetes/helm) simply do: | ||
|
||
```console | ||
$ kompose convert -c -y | ||
$ kompose convert -c | ||
file "web-svc.yaml" created | ||
file "redis-svc.yaml" created | ||
file "web-deployment.yaml" created | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ type ConvertOptions struct { | |
BuildBranch string | ||
CreateChart bool | ||
GenerateYaml bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
GenerateJson bool | ||
EmptyVols bool | ||
Replicas int | ||
InputFiles []string | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as https://github.com/kubernetes-incubator/kompose/pull/339/files#r94295029