Add new kompose site (#1475)
Adds the new kompose site and moves it to the /docs folder so that it's compatible with old links as well as gh-pages
4
.gitignore
vendored
@ -10,8 +10,8 @@ bin
|
||||
changes.txt
|
||||
|
||||
# Ignore built site
|
||||
site/_site/
|
||||
site/.jekyll-cache/
|
||||
docs/_site/
|
||||
docs/.jekyll-cache/
|
||||
|
||||
#
|
||||
# GO SPECIFIC
|
||||
|
||||
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 326 KiB After Width: | Height: | Size: 326 KiB |
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 992 B After Width: | Height: | Size: 992 B |
|
Before Width: | Height: | Size: 992 B After Width: | Height: | Size: 992 B |
|
Before Width: | Height: | Size: 992 B After Width: | Height: | Size: 992 B |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 179 B |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 319 KiB After Width: | Height: | Size: 319 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
@ -1,90 +0,0 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: /architecture/
|
||||
title: Architecture
|
||||
redirect_from:
|
||||
- /docs/architecture.md/
|
||||
- /docs/architecture/
|
||||
---
|
||||
|
||||
# Architecture and Internal Design
|
||||
|
||||
* TOC
|
||||
{:toc}
|
||||
|
||||
`kompose` has 3 stages: Loader, Transformer and Outputter. Each Stage should have well defined interface so it is easy to write new Loader, Transformer or Outputters and plug it in. Currently only Loader and Transformer interfaces are defined.
|
||||
|
||||

|
||||
|
||||
## Loader
|
||||
|
||||
Loader reads input file (now `kompose` supports [Docker Compose](https://docs.docker.com/compose) v1, v2 and converts it to KomposeObject.
|
||||
|
||||
Loader is represented by a Loader interface:
|
||||
|
||||
```go
|
||||
type Loader interface {
|
||||
LoadFile(file string) kobject.KomposeObject
|
||||
}
|
||||
```
|
||||
|
||||
Every loader “implementation” should be placed into `kompose/pkg/loader` (like compose). More input formats will be supported in future. You can take a look for more details at:
|
||||
|
||||
* [kompose/pkg/loader](https://github.com/kubernetes/kompose/tree/master/pkg/loader)
|
||||
* [kompose/pkg/loader/compose](https://github.com/kubernetes/kompose/tree/master/pkg/loader/compose)
|
||||
|
||||
## KomposeObject
|
||||
|
||||
`KomposeObject` is Kompose internal representation of all containers loaded from input file. First version of `KomposeObject` looks like this (source: [kobject.go](https://github.com/kubernetes/kompose/blob/master/pkg/kobject/kobject.go)):
|
||||
|
||||
```go
|
||||
// KomposeObject holds the generic struct of Kompose transformation
|
||||
type KomposeObject struct {
|
||||
ServiceConfigs map[string]ServiceConfig
|
||||
}
|
||||
|
||||
// ServiceConfig holds the basic struct of a container
|
||||
type ServiceConfig struct {
|
||||
ContainerName string
|
||||
Image string
|
||||
Environment []EnvVar
|
||||
Port []Ports
|
||||
Command []string
|
||||
WorkingDir string
|
||||
Args []string
|
||||
Volumes []string
|
||||
Network []string
|
||||
Labels map[string]string
|
||||
Annotations map[string]string
|
||||
CPUSet string
|
||||
CPUShares int64
|
||||
CPUQuota int64
|
||||
CapAdd []string
|
||||
CapDrop []string
|
||||
Entrypoint []string
|
||||
Expose []string
|
||||
Privileged bool
|
||||
Restart string
|
||||
User string
|
||||
}
|
||||
```
|
||||
|
||||
## Transformer
|
||||
|
||||
Transformer takes KomposeObject and converts it to target/output format (at this moment, there are sets of kubernetes/openshift objects). Similar to `Loader`, Transformer is represented by a Transformer interface:
|
||||
|
||||
```go
|
||||
type Transformer interface {
|
||||
Transform(kobject.KomposeObject, kobject.ConvertOptions) []runtime.Object
|
||||
}
|
||||
```
|
||||
|
||||
If you wish to add more providers which contain different kind of objects, transformer would be the place to look into. At this moment Kompose supports Kubernetes (by default) and Openshift providers. More details at:
|
||||
|
||||
* [kompose/pkg/transformer](https://github.com/kubernetes/kompose/tree/master/pkg/transformer)
|
||||
* [kompose/pkg/transformer/kubernetes](https://github.com/kubernetes/kompose/tree/master/pkg/transformer/kubernetes)
|
||||
* [kompose/pkg/transformer/openshift](https://github.com/kubernetes/kompose/tree/master/pkg/transformer/openshift)
|
||||
|
||||
## Outputter
|
||||
|
||||
Outputter takes Transformer result and executes given action. For example action can be displaying result to stdout or directly deploying artifacts to Kubernetes/OpenShift.
|
||||
@ -1,128 +0,0 @@
|
||||
---
|
||||
layout: default
|
||||
title: Conversion
|
||||
permalink: /conversion/
|
||||
redirect_from:
|
||||
- /docs/conversion.md/
|
||||
- /docs/conversion/
|
||||
---
|
||||
|
||||
# Conversion Matrix
|
||||
|
||||
* TOC
|
||||
{:toc}
|
||||
|
||||
This document outlines all possible conversion details regarding `docker-compose.yaml` values to Kubernetes / OpenShift artifacts.
|
||||
|
||||
## Version Table
|
||||
|
||||
| Supported | Compose Version | Docker Engine Version |
|
||||
|------------|-----------------|-----------------------|
|
||||
| N | 3.8 | 19.03.0+ |
|
||||
| N | 3.7 | 18.06.0+ |
|
||||
| N | 3.6 | 18.02.0+ |
|
||||
| N | 3.5 | 17.12.0+ |
|
||||
| N | 3.4 | 17.09.0+ |
|
||||
| Y | 3.3 | 17.06.0+ |
|
||||
| Y | 3.2 | 17.04.0+ |
|
||||
| Y | 3.1 | 1.13.1+ |
|
||||
| Y | 3.0 | 1.13.0+ |
|
||||
| Y | 2.4 | 17.12.0+ |
|
||||
| Y | 2.3 | 17.06.0+ |
|
||||
| Y | 2.2 | 1.13.0+ |
|
||||
| Y | 2.1 | 1.12.0+ |
|
||||
| Y | 2.0 | 1.10.0+ |
|
||||
|
||||
**Note:** We don't support anything 3.4 and above at the moment. It is reccomended to specify `version: "3.3"` in your `docker-compose.yaml` and converting. We use a library called [libcompose](https://github.com/docker/libcompose) that supports up to version `3.3`. If you are interested in adding additional support, please open up a PR!
|
||||
|
||||
## Conversion Table
|
||||
|
||||
__Glossary:__
|
||||
|
||||
- __✓:__ Converts
|
||||
- __-:__ Not in this Docker Compose Version
|
||||
- __n:__ Not yet implemented
|
||||
- __x:__ Not applicable / no 1-1 conversion
|
||||
|
||||
| Keys | V1 | V2 | V3 | Kubernetes / OpenShift | Notes |
|
||||
|------------------------|----|----|----|----------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
|
||||
| build | ✓ | ✓ | ✓ | | Builds/Pushes to Docker repository. See [user guide on build and push image](https://kompose.io/user-guide/#build-and-push-image) |
|
||||
| build: context | ✓ | ✓ | ✓ | | |
|
||||
| build: dockerfile | ✓ | ✓ | ✓ | | |
|
||||
| build: args | n | n | n | | |
|
||||
| build: cache_from | - | - | n | | |
|
||||
| cap_add | ✓ | ✓ | ✓ | Container.SecurityContext.Capabilities.Add | |
|
||||
| cap_drop | ✓ | ✓ | ✓ | Container.SecurityContext.Capabilities.Drop | |
|
||||
| command | ✓ | ✓ | ✓ | Container.Args | |
|
||||
| configs | n | n | ✓ | | |
|
||||
| configs: short-syntax | n | n | ✓ | | Only create configMap |
|
||||
| configs: long-syntax | n | n | ✓ | | If target path is /, ignore this and only create configMap |
|
||||
| cgroup_parent | x | x | x | | Not supported within Kubernetes. See issue https://github.com/kubernetes/kubernetes/issues/11986 |
|
||||
| container_name | ✓ | ✓ | ✓ | Metadata.Name + Deployment.Spec.Containers.Name | |
|
||||
| credential_spec | x | x | x | | Only applicable to Windows containers |
|
||||
| deploy | - | - | ✓ | | |
|
||||
| deploy: mode | - | - | ✓ | | |
|
||||
| deploy: replicas | - | - | ✓ | Deployment.Spec.Replicas / DeploymentConfig.Spec.Replicas | |
|
||||
| deploy: placement | - | - | ✓ | Affinity | |
|
||||
| deploy: update_config | - | - | ✓ | Workload.Spec.Strategy | Deployment / DeploymentConfig |
|
||||
| deploy: resources | - | - | ✓ | Containers.Resources.Limits.Memory / Containers.Resources.Limits.CPU | Support for memory as well as cpu |
|
||||
| deploy: restart_policy | - | - | ✓ | Pod generation | This generated a Pod, see the [user guide on restart](http://kompose.io/user-guide/#restart) |
|
||||
| deploy: labels | - | - | ✓ | Workload.Metadata.Labels | Only applied to workload resource |
|
||||
| devices | x | x | x | | Not supported within Kubernetes, See issue https://github.com/kubernetes/kubernetes/issues/5607 |
|
||||
| depends_on | x | x | x | | |
|
||||
| dns | x | x | x | | Not used within Kubernetes. Kubernetes uses a managed DNS server |
|
||||
| dns_search | x | x | x | | See `dns` key |
|
||||
| domainname | ✓ | ✓ | ✓ | SubDomain | |
|
||||
| tmpfs | ✓ | ✓ | ✓ | Containers.Volumes.EmptyDir | Creates emptyDirvolume with medium set to Memory & mounts given directory inside container |
|
||||
| entrypoint | ✓ | ✓ | ✓ | Container.Command | |
|
||||
| env_file | n | n | ✓ | | |
|
||||
| environment | ✓ | ✓ | ✓ | Container.Env | |
|
||||
| expose | ✓ | ✓ | ✓ | Service.Spec.Ports | |
|
||||
| endpoint_mode | n | n | ✓ | | If endpoint_mode=vip, the created Service will be forced to set to NodePort type |
|
||||
| extends | ✓ | ✓ | ✓ | | Extends by utilizing the same image supplied |
|
||||
| external_links | x | x | x | | Kubernetes uses a flat-structure for all containers and thus external_links does not have a 1-1 conversion |
|
||||
| extra_hosts | n | n | n | | |
|
||||
| group_add | ✓ | ✓ | ✓ | | |
|
||||
| healthcheck | - | n | ✓ | | |
|
||||
| hostname | ✓ | ✓ | ✓ | HostName | |
|
||||
| image | ✓ | ✓ | ✓ | Deployment.Spec.Containers.Image | |
|
||||
| isolation | x | x | x | | Not applicable as this applies to Windows with HyperV support |
|
||||
| labels | ✓ | ✓ | ✓ | Metadata.Annotations | |
|
||||
| links | x | x | x | | All containers in the same pod are accessible in Kubernetes |
|
||||
| logging | x | x | x | | Kubernetes has built-in logging support at the node-level |
|
||||
| network_mode | x | x | x | | Kubernetes uses its own cluster networking |
|
||||
| networks | ✓ | ✓ | ✓ | | See `networks` key |
|
||||
| networks: aliases | x | x | x | | See `networks` key |
|
||||
| networks: addresses | x | x | x | | See `networks` key |
|
||||
| pid | ✓ | ✓ | ✓ | HostPID | |
|
||||
| ports | ✓ | ✓ | ✓ | Service.Spec.Ports | |
|
||||
| ports: short-syntax | ✓ | ✓ | ✓ | Service.Spec.Ports | |
|
||||
| ports: long-syntax | - | - | ✓ | Service.Spec.Ports | |
|
||||
| secrets | - | - | ✓ | Secret | External Secret is not Supported |
|
||||
| secrets: short-syntax | - | - | ✓ | Secret | External Secret is not Supported |
|
||||
| secrets: long-syntax | - | - | ✓ | Secret | External Secret is not Supported |
|
||||
| security_opt | x | x | x | | Kubernetes uses its own container naming scheme |
|
||||
| stop_grace_period | ✓ | ✓ | ✓ | TerminationGracePeriodSeconds | |
|
||||
| stop_signal | x | x | x | | Not supported within Kubernetes. See issue https://github.com/kubernetes/kubernetes/issues/30051 |
|
||||
| sysctls | n | n | n | | |
|
||||
| ulimits | x | x | x | | Not supported within Kubernetes. See issue https://github.com/kubernetes/kubernetes/issues/3595 |
|
||||
| userns_mode | x | x | x | | Not supported within Kubernetes and ignored in Docker Compose Version 3 |
|
||||
| volumes | ✓ | ✓ | ✓ | PersistentVolumeClaim | Creates a PersistentVolumeClaim. Can only be created if there is already a PersistentVolume within the cluster |
|
||||
| volumes: short-syntax | ✓ | ✓ | ✓ | PersistentVolumeClaim | Creates a PersistentVolumeClaim. Can only be created if there is already a PersistentVolume within the cluster |
|
||||
| volumes: long-syntax | - | - | ✓ | PersistentVolumeClaim | Creates a PersistentVolumeClaim. Can only be created if there is already a PersistentVolume within the cluster |
|
||||
| restart | ✓ | ✓ | ✓ | | |
|
||||
| | | | | | |
|
||||
| __Volume__ | x | x | x | | |
|
||||
| driver | x | x | x | | |
|
||||
| driver_opts | x | x | x | | |
|
||||
| external | x | x | x | | |
|
||||
| labels | x | x | x | | |
|
||||
| | | | | | |
|
||||
| __Network__ | x | x | x | | |
|
||||
| driver | x | x | x | | |
|
||||
| driver_opts | x | x | x | | |
|
||||
| enable_ipv6 | x | x | x | | |
|
||||
| ipam | x | x | x | | |
|
||||
| internal | x | x | x | | |
|
||||
| labels | x | x | x | | |
|
||||
| external | x | x | x | | |
|
||||
@ -1,88 +0,0 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: /development/
|
||||
title: Development
|
||||
redirect_from:
|
||||
- /docs/development.md/
|
||||
- /docs/development/
|
||||
---
|
||||
|
||||
# Development Guide
|
||||
|
||||
## Building Kompose
|
||||
|
||||
Read about building kompose [here](https://github.com/kubernetes/kompose#building).
|
||||
|
||||
## Workflow
|
||||
### Fork the main repository
|
||||
|
||||
1. Go to https://github.com/kubernetes/kompose
|
||||
2. Click the "Fork" button (at the top right)
|
||||
|
||||
### Clone your fork
|
||||
|
||||
The commands below require that you have $GOPATH. We highly recommended you put Kompose' code into your $GOPATH.
|
||||
|
||||
```console
|
||||
git clone https://github.com/$YOUR_GITHUB_USERNAME/kompose.git $GOPATH/src/github.com/kubernetes/kompose
|
||||
cd $GOPATH/src/github.com/kubernetes/kompose
|
||||
git remote add upstream 'https://github.com/kubernetes/kompose'
|
||||
```
|
||||
|
||||
### Create a branch and make changes
|
||||
|
||||
```console
|
||||
git checkout -b myfeature
|
||||
# Make your code changes
|
||||
```
|
||||
|
||||
### Keeping your development fork in sync
|
||||
|
||||
```console
|
||||
git fetch upstream
|
||||
git rebase upstream/master
|
||||
```
|
||||
|
||||
Note: If you have write access to the main repository at github.com/kubernetes/kompose, you should modify your git configuration so that you can't accidentally push to upstream:
|
||||
|
||||
```console
|
||||
git remote set-url --push upstream no_push
|
||||
```
|
||||
|
||||
### Committing changes to your fork
|
||||
|
||||
```console
|
||||
git commit
|
||||
git push -f origin myfeature
|
||||
```
|
||||
|
||||
### Creating a pull request
|
||||
|
||||
1. Visit https://github.com/$YOUR_GITHUB_USERNAME/kompose.git
|
||||
2. Click the "Compare and pull request" button next to your "myfeature" branch.
|
||||
3. Check out the pull request process for more details
|
||||
|
||||
## Go Modules and dependency management
|
||||
|
||||
Kompose uses [Go Modules](https://github.com/golang/go/wiki/Modules) to manage dependencies.
|
||||
If you want to make changes to dependencies please make sure that `go.mod` and `go.sum` are updated properly.
|
||||
|
||||
##### Updating Kubernetes and OpenShift
|
||||
Kubernetes version depends on what version is OpenShift using.
|
||||
OpenShift is using forked Kubernetes to carry some patches.
|
||||
Currently it is not possible to use different Kubernetes version from version that OpenShift uses.
|
||||
(for more see comments in `go.mod`)
|
||||
|
||||
### Adding CLI tests
|
||||
|
||||
[Kompose CLI tests](https://github.com/kubernetes/kompose/tree/master/script/test/cmd) run `kompose convert` with docker-compose files, and cross-check the k8s and OpenShift artifacts generated with the template files.
|
||||
|
||||
To generate CLI tests, please run `make gen-cmd`.
|
||||
|
||||
### CI
|
||||
|
||||
For Kompose, we use numerous CI's:
|
||||
|
||||
- [TravisCI](https://travis-ci.org/kubernetes/kompose): Unit and CLI tests
|
||||
- [SemaphoreCI](https://semaphoreci.com/cdrage/kompose-2): Integration / cluster tests
|
||||
- [Fabric8CI](http://jenkins.cd.k8s.fabric8.io/): Secondary integration tests / future cluster tests
|
||||
@ -1,306 +0,0 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: /getting-started/
|
||||
title: Getting Started
|
||||
redirect_from:
|
||||
- /docs/getting-started.md/
|
||||
- /docs/getting-started/
|
||||
---
|
||||
|
||||
# Getting Started
|
||||
|
||||
* TOC
|
||||
{:toc}
|
||||
|
||||
This is how you'll get started with Kompose!
|
||||
|
||||
There are three different guides depending on your container orchestrator as well as operating system.
|
||||
|
||||
For beginners and the most compatibility, follow the _Minikube and Kompose_ guide.
|
||||
|
||||
## Minikube and Kompose
|
||||
|
||||
In this guide, we'll deploy a sample `docker-compose.yaml` file to a Kubernetes cluster.
|
||||
|
||||
Requirements:
|
||||
- [minikube](https://github.com/kubernetes/minikube)
|
||||
- [kompose](https://github.com/kubernetes/kompose)
|
||||
|
||||
__Start `minikube`:__
|
||||
|
||||
If you don't already have a Kubernetes cluster running, [minikube](https://github.com/kubernetes/minikube) is the best way to get started.
|
||||
|
||||
```sh
|
||||
$ minikube start
|
||||
Starting local Kubernetes v1.7.5 cluster...
|
||||
Starting VM...
|
||||
Getting VM IP address...
|
||||
Moving files into cluster...
|
||||
Setting up certs...
|
||||
Connecting to cluster...
|
||||
Setting up kubeconfig...
|
||||
Starting cluster components...
|
||||
Kubectl is now configured to use the cluster
|
||||
```
|
||||
|
||||
__Download an [example Docker Compose file](https://raw.githubusercontent.com/kubernetes/kompose/master/examples/docker-compose.yaml), or use your own:__
|
||||
|
||||
```sh
|
||||
wget https://raw.githubusercontent.com/kubernetes/kompose/master/examples/docker-compose.yaml
|
||||
```
|
||||
|
||||
__Convert your Docker Compose file to Kubernetes:__
|
||||
|
||||
Run `kompose convert` in the same directory as your `docker-compose.yaml` file.
|
||||
|
||||
```sh
|
||||
$ kompose convert
|
||||
INFO Kubernetes file "frontend-service.yaml" created
|
||||
INFO Kubernetes file "redis-master-service.yaml" created
|
||||
INFO Kubernetes file "redis-slave-service.yaml" created
|
||||
INFO Kubernetes file "frontend-deployment.yaml" created
|
||||
INFO Kubernetes file "redis-master-deployment.yaml" created
|
||||
INFO Kubernetes file "redis-slave-deployment.yaml" created
|
||||
```
|
||||
|
||||
Then you can use `kubectl apply` to create these resources in kubernetes.
|
||||
|
||||
|
||||
__Access the newly deployed service:__
|
||||
|
||||
Now that your service has been deployed, let's access it.
|
||||
|
||||
If you're using `minikube` you may access it via the `minikube service` command.
|
||||
|
||||
```sh
|
||||
$ minikube service frontend
|
||||
```
|
||||
|
||||
Otherwise, use `kubectl` to see what IP the service is using:
|
||||
|
||||
```sh
|
||||
$ kubectl describe svc frontend
|
||||
Name: frontend
|
||||
Namespace: default
|
||||
Labels: service=frontend
|
||||
Selector: service=frontend
|
||||
Type: LoadBalancer
|
||||
IP: 10.0.0.183
|
||||
LoadBalancer Ingress: 123.45.67.89
|
||||
Port: 80 80/TCP
|
||||
NodePort: 80 31144/TCP
|
||||
Endpoints: 172.17.0.4:80
|
||||
Session Affinity: None
|
||||
No events.
|
||||
|
||||
```
|
||||
|
||||
Note: If you're using a cloud provider, your IP will be listed next to `LoadBalancer Ingress`.
|
||||
|
||||
If you have yet to expose your service (for example, within GCE), use the command:
|
||||
|
||||
```sh
|
||||
kubectl expose deployment frontend --type="LoadBalancer"
|
||||
```
|
||||
|
||||
To check functionality, you may also `curl` the URL.
|
||||
|
||||
```sh
|
||||
$ curl http://123.45.67.89
|
||||
```
|
||||
|
||||
## Minishift and Kompose
|
||||
|
||||
In this guide, we'll deploy a sample `docker-compose.yaml` file to an OpenShift cluster.
|
||||
|
||||
Requirements:
|
||||
- [minishift](https://github.com/minishift/minishift)
|
||||
- [kompose](https://github.com/kubernetes/kompose)
|
||||
- An OpenShift route created
|
||||
|
||||
__Note:__ The service will NOT be accessible until you create an OpenShift route with `oc expose`. You must also have a virtualization environment setup. By default, `minishift` uses KVM.
|
||||
|
||||
__Start `minishift`:__
|
||||
|
||||
[Minishift](https://github.com/minishift/minishift) is a tool that helps run OpenShift locally using a single-node cluster inside of a VM. Similar to [minikube](https://github.com/kubernetes/minikube).
|
||||
|
||||
```sh
|
||||
$ minishift start
|
||||
Starting local OpenShift cluster using 'kvm' hypervisor...
|
||||
-- Checking OpenShift client ... OK
|
||||
-- Checking Docker client ... OK
|
||||
-- Checking Docker version ... OK
|
||||
-- Checking for existing OpenShift container ... OK
|
||||
...
|
||||
```
|
||||
|
||||
__Download an [example Docker Compose file](https://raw.githubusercontent.com/kubernetes/kompose/master/examples/docker-compose.yaml), or use your own:__
|
||||
|
||||
```sh
|
||||
wget https://raw.githubusercontent.com/kubernetes/kompose/master/examples/docker-compose.yaml
|
||||
```
|
||||
|
||||
__Convert your Docker Compose file to OpenShift:__
|
||||
|
||||
Run `kompose convert --provider=openshift` in the same directory as your `docker-compose.yaml` file.
|
||||
|
||||
```sh
|
||||
$ kompose convert --provider=openshift
|
||||
INFO OpenShift file "frontend-service.yaml" created
|
||||
INFO OpenShift file "redis-master-service.yaml" created
|
||||
INFO OpenShift file "redis-slave-service.yaml" created
|
||||
INFO OpenShift file "frontend-deploymentconfig.yaml" created
|
||||
INFO OpenShift file "frontend-imagestream.yaml" created
|
||||
INFO OpenShift file "redis-master-deploymentconfig.yaml" created
|
||||
INFO OpenShift file "redis-master-imagestream.yaml" created
|
||||
INFO OpenShift file "redis-slave-deploymentconfig.yaml" created
|
||||
INFO OpenShift file "redis-slave-imagestream.yaml" created
|
||||
```
|
||||
|
||||
Then you can use `kubectl apply` to create these resources in OpenShift cluster.
|
||||
|
||||
__Access the newly deployed service:__
|
||||
|
||||
After deployment, you must create an OpenShift route in order to access the service.
|
||||
|
||||
If you're using `minishift`, you'll use a combination of `oc` and `minishift` commands to access the service.
|
||||
|
||||
Create a route for the `frontend` service using `oc`:
|
||||
|
||||
```sh
|
||||
$ oc expose service/frontend
|
||||
route "frontend" exposed
|
||||
```
|
||||
|
||||
Access the `frontend` service with `minishift`:
|
||||
|
||||
```sh
|
||||
$ minishift openshift service frontend --namespace=myproject
|
||||
Opening the service myproject/frontend in the default browser...
|
||||
```
|
||||
|
||||
You can also access the GUI interface of OpenShift for an overview of the deployed containers:
|
||||
|
||||
```sh
|
||||
$ minishift console
|
||||
Opening the OpenShift Web console in the default browser...
|
||||
```
|
||||
|
||||
## RHEL and Kompose
|
||||
|
||||
In this guide, we'll deploy a sample `docker-compose.yaml` file using both RHEL (Red Hat Enterprise Linux) and OpenShift.
|
||||
|
||||
Requirements:
|
||||
- Red Hat Enterprise Linux 7.4
|
||||
- [Red Hat Development Suite](https://developers.redhat.com/products/devsuite/overview/)
|
||||
- Which includes:
|
||||
- [minishift](https://github.com/minishift/minishift)
|
||||
- [kompose](https://github.com/kubernetes/kompose)
|
||||
|
||||
__Note:__ A KVM hypervisor must be setup in order to correctly use `minishift` on RHEL. You can set it up via the [CDK Documentation](https://access.redhat.com/documentation/en-us/red_hat_container_development_kit/3.1/html-single/getting_started_guide/index#setup-virtualization) under "Set up your virtualization environment".
|
||||
|
||||
__Install Red Hat Development Suite:__
|
||||
|
||||
Before we are able to use both `minishift` and `kompose`, DevSuite must be installed. A more concise [installation document is available](https://developers.redhat.com/products/cdk/hello-world#fndtn-rhel).
|
||||
|
||||
Change to root.
|
||||
|
||||
```sh
|
||||
$ su -
|
||||
```
|
||||
|
||||
Enable the Red Hat Developer Tools software repository.
|
||||
|
||||
```sh
|
||||
$ subscription-manager repos --enable rhel-7-server-devtools-rpms
|
||||
$ subscription-manager repos --enable rhel-server-rhscl-7-rpms
|
||||
```
|
||||
|
||||
Add the Red Hat Developer Tools key to your system.
|
||||
|
||||
```sh
|
||||
$ cd /etc/pki/rpm-gpg
|
||||
$ wget -O RPM-GPG-KEY-redhat-devel https://www.redhat.com/security/data/a5787476.txt
|
||||
$ rpm --import RPM-GPG-KEY-redhat-devel
|
||||
```
|
||||
|
||||
Install Red Hat Development Suite and Kompose.
|
||||
|
||||
```sh
|
||||
$ yum install rh-devsuite kompose -y
|
||||
```
|
||||
|
||||
__Start `minishift`:__
|
||||
|
||||
Before we begin, we must do a few preliminary steps setting up `minishift`.
|
||||
|
||||
```sh
|
||||
$ su -
|
||||
$ ln -s /var/lib/cdk-minishift-3.0.0/minishift /usr/bin/minishift
|
||||
$ minishift setup-cdk --force --default-vm-driver="kvm"
|
||||
$ ln -s /home/$(whoami)/.minishift/cache/oc/v3.5.5.8/oc /usr/bin/oc
|
||||
```
|
||||
|
||||
Now we may start `minishift`.
|
||||
|
||||
```sh
|
||||
$ minishift start
|
||||
Starting local OpenShift cluster using 'kvm' hypervisor...
|
||||
-- Checking OpenShift client ... OK
|
||||
-- Checking Docker client ... OK
|
||||
-- Checking Docker version ... OK
|
||||
-- Checking for existing OpenShift container ... OK
|
||||
...
|
||||
```
|
||||
|
||||
__Download an [example Docker Compose file](https://raw.githubusercontent.com/kubernetes/kompose/master/examples/docker-compose.yaml), or use your own:__
|
||||
|
||||
```sh
|
||||
wget https://raw.githubusercontent.com/kubernetes/kompose/master/examples/docker-compose.yaml
|
||||
```
|
||||
|
||||
__Convert your Docker Compose file to OpenShift:__
|
||||
|
||||
Run `kompose convert --provider=openshift` in the same directory as your `docker-compose.yaml` file.
|
||||
|
||||
```sh
|
||||
$ kompose convert --provider=openshift
|
||||
INFO OpenShift file "frontend-service.yaml" created
|
||||
INFO OpenShift file "redis-master-service.yaml" created
|
||||
INFO OpenShift file "redis-slave-service.yaml" created
|
||||
INFO OpenShift file "frontend-deploymentconfig.yaml" created
|
||||
INFO OpenShift file "frontend-imagestream.yaml" created
|
||||
INFO OpenShift file "redis-master-deploymentconfig.yaml" created
|
||||
INFO OpenShift file "redis-master-imagestream.yaml" created
|
||||
INFO OpenShift file "redis-slave-deploymentconfig.yaml" created
|
||||
INFO OpenShift file "redis-slave-imagestream.yaml" created
|
||||
```
|
||||
|
||||
Then you can use `kubectl apply` to create these resources in OpenShift.
|
||||
|
||||
__Access the newly deployed service:__
|
||||
|
||||
After deployment, you must create an OpenShift route in order to access the service.
|
||||
|
||||
If you're using `minishift`, you'll use a combination of `oc` and `minishift` commands to access the service.
|
||||
|
||||
Create a route for the `frontend` service using `oc`:
|
||||
|
||||
```sh
|
||||
$ oc expose service/frontend
|
||||
route "frontend" exposed
|
||||
```
|
||||
|
||||
Access the `frontend` service with `minishift`:
|
||||
|
||||
```sh
|
||||
$ minishift openshift service frontend --namespace=myproject
|
||||
Opening the service myproject/frontend in the default browser...
|
||||
```
|
||||
|
||||
You can also access the GUI interface of OpenShift for an overview of the deployed containers:
|
||||
|
||||
```sh
|
||||
$ minishift console
|
||||
Opening the OpenShift Web console in the default browser...
|
||||
```
|
||||
|
Before Width: | Height: | Size: 122 KiB |
|
Before Width: | Height: | Size: 16 KiB |
@ -1,141 +0,0 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: /installation/
|
||||
title: Installation
|
||||
redirect_from:
|
||||
- /docs/installation.md/
|
||||
- /docs/installation/
|
||||
---
|
||||
|
||||
# Installation
|
||||
|
||||
* TOC
|
||||
{:toc}
|
||||
|
||||
We have multiple ways to install Kompose. Our preferred method is downloading the binary from the latest GitHub release.
|
||||
|
||||
## GitHub release
|
||||
|
||||
Kompose is released via GitHub on a three-week cycle, you can see all current releases on the [GitHub release page](https://github.com/kubernetes/kompose/releases).
|
||||
|
||||
__Linux and macOS:__
|
||||
|
||||
```sh
|
||||
# Linux
|
||||
curl -L https://github.com/kubernetes/kompose/releases/download/v1.26.1/kompose-linux-amd64 -o kompose
|
||||
|
||||
# macOS
|
||||
curl -L https://github.com/kubernetes/kompose/releases/download/v1.26.1/kompose-darwin-amd64 -o kompose
|
||||
|
||||
chmod +x kompose
|
||||
sudo mv ./kompose /usr/local/bin/kompose
|
||||
```
|
||||
|
||||
__Windows:__
|
||||
|
||||
Download from [GitHub](https://github.com/kubernetes/kompose/releases/download/v1.26.1/kompose-windows-amd64.exe) and add the binary to your PATH.
|
||||
|
||||
## Go
|
||||
|
||||
Installing using `go get` pulls from the master branch with the latest development changes.
|
||||
|
||||
```sh
|
||||
go get -u github.com/kubernetes/kompose
|
||||
```
|
||||
|
||||
## CentOS
|
||||
|
||||
Kompose is in [EPEL](https://fedoraproject.org/wiki/EPEL) CentOS repository.
|
||||
If you don't have [EPEL](https://fedoraproject.org/wiki/EPEL) repository already installed and enabled you can do it by running `sudo yum install epel-release`
|
||||
|
||||
If you have [EPEL](https://fedoraproject.org/wiki/EPEL) enabled in your system, you can install Kompose like any other package.
|
||||
|
||||
```bash
|
||||
sudo yum -y install kompose
|
||||
```
|
||||
|
||||
## Fedora
|
||||
Kompose is in Fedora 24, 25 and 26 repositories. You can install it just like any other package.
|
||||
|
||||
```bash
|
||||
sudo dnf -y install kompose
|
||||
```
|
||||
|
||||
## Ubuntu/Debian
|
||||
|
||||
A deb package is released for compose. Download latest package in the assets in [github releases](https://github.com/kubernetes/kompose/releases).
|
||||
|
||||
```bash
|
||||
wget https://github.com/kubernetes/kompose/releases/download/v1.26.1/kompose_1.26.1_amd64.deb # Replace 1.26.1 with latest tag
|
||||
sudo apt install ./kompose_1.26.1_amd64.deb
|
||||
```
|
||||
|
||||
## macOS
|
||||
On macOS you can install latest release via [Homebrew](https://brew.sh) or [MacPorts](https://www.macports.org/).
|
||||
|
||||
```bash
|
||||
# Homebrew
|
||||
brew install kompose
|
||||
|
||||
# MacPorts
|
||||
port install kompose
|
||||
```
|
||||
|
||||
## Windows
|
||||
Kompose can be installed via [Chocolatey](https://chocolatey.org/packages/kubernetes-kompose)
|
||||
|
||||
```console
|
||||
choco install kubernetes-kompose
|
||||
```
|
||||
|
||||
## openSUSE/SLE
|
||||
Kompose is available in the official Virtualization:containers repository for openSUSE Tumbleweed, Leap 15, Leap 42.3 and SUSE Linux Enterprise 15.
|
||||
|
||||
Head over to [software.opensuse.org for One-Click Installation](https://software.opensuse.org//download.html?project=Virtualization%3Acontainers&package=kompose) or add the repository manually:
|
||||
```bash
|
||||
#openSUSE Tumbleweed
|
||||
sudo zypper addrepo https://download.opensuse.org/repositories/Virtualization:containers/openSUSE_Tumbleweed/Virtualization:containers.repo
|
||||
|
||||
#openSUSE Leap 42.3
|
||||
sudo zypper addrepo https://download.opensuse.org/repositories/Virtualization:containers/openSUSE_Leap_42.3/Virtualization:containers.repo
|
||||
|
||||
#openSUSE Leap 15
|
||||
sudo zypper addrepo https://download.opensuse.org/repositories/Virtualization:/containers/openSUSE_Leap_15.2/Virtualization:containers.repo
|
||||
|
||||
#SUSE Linux Enterprise 15
|
||||
sudo zypper addrepo https://download.opensuse.org/repositories/Virtualization:/containers/SLE_15_SP1/Virtualization:containers.repo
|
||||
```
|
||||
and install the package:
|
||||
```bash
|
||||
sudo zypper refresh
|
||||
sudo zypper install kompose
|
||||
```
|
||||
|
||||
## NixOS
|
||||
|
||||
To install from [Nixpkgs](https://github.com/NixOS/nixpkgs), use [nix-env](https://nixos.org/manual/nix/stable/command-ref/nix-env.html).
|
||||
|
||||
```bash
|
||||
nix-env --install -A nixpkgs.kompose
|
||||
```
|
||||
|
||||
To run `kompose` without installing it, use [nix-shell](https://nixos.org/manual/nix/stable/command-ref/nix-shell.html).
|
||||
|
||||
```bash
|
||||
nix-shell -p kompose --run "kompose convert"
|
||||
```
|
||||
|
||||
|
||||
## Docker
|
||||
|
||||
You can build an image from the offical repo for [Docker](https://docs.docker.com/engine/reference/commandline/build/) or [Podman](https://docs.podman.io/en/latest/markdown/podman-build.1.html):
|
||||
|
||||
```bash
|
||||
docker build -t kompose https://github.com/kubernetes/kompose.git
|
||||
```
|
||||
|
||||
To run the built image against the current directory, run the following command:
|
||||
|
||||
```bash
|
||||
docker run --rm -it -v $PWD:/opt kompose sh -c "cd /opt && kompose convert"
|
||||
```
|
||||
@ -1,57 +0,0 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: /integrations/
|
||||
title: Integrations
|
||||
redirect_from:
|
||||
- /docs/integrations.md/
|
||||
- /docs/integrations/
|
||||
---
|
||||
|
||||
# Integrations
|
||||
|
||||
* TOC
|
||||
{:toc}
|
||||
|
||||
There are some projects out there known to use Kompose integrated in some form or another
|
||||
|
||||
### Kompose UI by Jad Chamoun (ICANN) and Joe Haddad (Anghami)
|
||||
|
||||
__Description:__ "A web interface to convert Docker Compose files to Kubernetes YAML"
|
||||
|
||||
__Link:__ [https://github.com/JadCham/komposeui](https://github.com/JadCham/komposeui)
|
||||
|
||||
### Kompose Docker Container by Cloudfind
|
||||
|
||||
__Description:__ "A Docker container for the Kompose translator for docker-compose"
|
||||
|
||||
__Link:__ [https://github.com/cloudfind/kompose-docker](https://github.com/cloudfind/kompose-docker)
|
||||
|
||||
### KPM by CoreOS
|
||||
|
||||
__Description:__ "KPM is a tool to deploy and manage application stacks on Kubernetes"
|
||||
|
||||
__Link:__ [https://github.com/coreos/kpm](https://github.com/coreos/kpm)
|
||||
|
||||
### Docker Image for Adobe Enterprise Manager by Adfinis SyGroup AG
|
||||
|
||||
__Description:__ "Docker Image for Adobe Enterprise Manager"
|
||||
|
||||
__Link:__ [https://github.com/adfinis-sygroup/aem-docker/tree/master](https://github.com/adfinis-sygroup/aem-docker/tree/master)
|
||||
|
||||
### Kompose Ansible Playbook by Chris Houseknecht (Red Hat)
|
||||
|
||||
__Description:__ "Download and unarchive the latest kompose release asset for your OS"
|
||||
|
||||
__Link:__ [https://github.com/chouseknecht/kompose-install-role](https://github.com/chouseknecht/kompose-install-role)
|
||||
|
||||
### Fabric8 Maven Plugin by Red Hat
|
||||
|
||||
__Description:__ "Maven is one of the widely used build tools for Java applications. The Fabric8 Maven Plugin is a maven extension that simplifies the deployment of Java applications to Kubernetes or OpenShift cluster.
|
||||
The main task of this plugin is to build Docker images, generate Kubernetes or OpenShift resource descriptors and run/deploy the application on Kubernetes or OpenShift cluster.
|
||||
Plugin has wide range of configuration options. Docker Compose is one of the option to bring up deployments on Kubernetes or OpenShift cluster.
|
||||
Technically, Fabric8 Maven Plugin processes the external docker-compose.yml file and generates Kubernetes or OpenShift resources via Kompose."
|
||||
|
||||
__Links:__
|
||||
|
||||
* [Quickstart](/docs/maven-example.md)
|
||||
* [Documentation](https://maven.fabric8.io/#docker-compose)
|
||||
@ -1,98 +0,0 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: /maven-example/
|
||||
title: Maven Example
|
||||
redirect_from:
|
||||
- /docs/maven-example.md/
|
||||
- /docs/maven-example/
|
||||
---
|
||||
|
||||
# Fabric8 Maven Plugin + Kompose:
|
||||
Let's deploy a Springboot Java application with Docker Compose file using Fabric8 Maven Plugin to Kubernetes or OpenShift.
|
||||
|
||||
##### Requirements
|
||||
* Linux or MacOS or Windows
|
||||
* JDK 1.7+ - [JDK Quick Installation Guide](http://openjdk.java.net/install/)
|
||||
* Maven 3.x+ - [Maven Installation Guide](http://www.baeldung.com/install-maven-on-windows-linux-mac)
|
||||
* Kompose - [Kompose Installation Guide](/docs/installation.md)
|
||||
|
||||
__1. Clone the example project from GitHub__
|
||||
```bash
|
||||
$ git clone https://github.com/piyush1594/kompose-maven-example.git
|
||||
```
|
||||
|
||||
Change current directory to `kompose-maven-example` directory.
|
||||
```bash
|
||||
$ cd kompose-maven-example
|
||||
```
|
||||
|
||||
__2. Add Fabric8 Maven Plugin to your project__
|
||||
```bash
|
||||
$ mvn io.fabric8:fabric8-maven-plugin:3.5.28:setup
|
||||
```
|
||||
|
||||
Add the Fabric8 Maven Plugin configuration to `pom.xml` of project. `pom.xml` is manifest or deployment descriptor file of a maven project.
|
||||
|
||||
__3. Install Kompose through Maven__
|
||||
```bash
|
||||
$ mvn fabric8:install
|
||||
```
|
||||
|
||||
This command installs the `kompose` on the host.
|
||||
|
||||
__4. Configure Fabric8 Maven Plugin to use a Docker Compose file__
|
||||
```bash
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>fabric8-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<composeFile>path for docker compose file</composeFile>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>resource</goal>
|
||||
<goal>build</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
```
|
||||
|
||||
Add the `<configuration>` and `<executions>` sections to `pom.xml` as shown in above `pom.xml` snippet. Update the `<composeFile>` to provide the relative path of Docker Compose file from `pom.xml`
|
||||
|
||||
__5. Deploy application on Kubernetes or OpenShift__
|
||||
|
||||
Make sure that Kubernetes/OpenShift cluster or Minikube/minishift is running. In case, if anything of this is not running, you can run minishift to test this application by using following command.
|
||||
```bash
|
||||
$ minishift start
|
||||
```
|
||||
|
||||
Below command deploys this application on Kubernetes or OpenShift.
|
||||
```bash
|
||||
$ mvn fabric8:deploy
|
||||
```
|
||||
|
||||
Now that your service has been deployed, let's access it by querying `pod`, `service` from Kubernetes or OpenShift.
|
||||
```bash
|
||||
$ oc get pods
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
springboot-docker-compose-1-xl0vb 1/1 Running 0 5m
|
||||
springboot-docker-compose-s2i-1-build 0/1 Completed 0 7m
|
||||
```
|
||||
|
||||
```bash
|
||||
$ oc get svc
|
||||
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
||||
springboot-docker-compose 172.30.205.137 <none> 8080/TCP 6m
|
||||
```
|
||||
|
||||
Let's access the Springboot service.
|
||||
```bash
|
||||
$ minishift openshift service --in-browser springboot-docker-compose
|
||||
Created the new window in existing browser session.
|
||||
```
|
||||
|
||||
It will open your application endpoint in default browser.
|
||||
|
||||

|
||||
@ -1,474 +0,0 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: /user-guide/
|
||||
title: User Guide
|
||||
redirect_from:
|
||||
- /docs/user-guide.md/
|
||||
- /docs/user-guide/
|
||||
---
|
||||
|
||||
# User Guide
|
||||
|
||||
* TOC
|
||||
{:toc}
|
||||
|
||||
Kompose has support for two providers: OpenShift and Kubernetes.
|
||||
You can choose a targeted provider using global option `--provider`. If no provider is specified, Kubernetes is set by default.
|
||||
|
||||
|
||||
## Kompose Convert
|
||||
|
||||
Kompose supports conversion of V1, V2, and V3 Docker Compose files into Kubernetes and OpenShift objects.
|
||||
|
||||
### Kubernetes
|
||||
|
||||
```sh
|
||||
$ kompose --file docker-voting.yml convert
|
||||
WARN Unsupported key networks - ignoring
|
||||
WARN Unsupported key build - ignoring
|
||||
INFO Kubernetes file "worker-svc.yaml" created
|
||||
INFO Kubernetes file "db-svc.yaml" created
|
||||
INFO Kubernetes file "redis-svc.yaml" created
|
||||
INFO Kubernetes file "result-svc.yaml" created
|
||||
INFO Kubernetes file "vote-svc.yaml" created
|
||||
INFO Kubernetes file "redis-deployment.yaml" created
|
||||
INFO Kubernetes file "result-deployment.yaml" created
|
||||
INFO Kubernetes file "vote-deployment.yaml" created
|
||||
INFO Kubernetes file "worker-deployment.yaml" created
|
||||
INFO Kubernetes file "db-deployment.yaml" created
|
||||
|
||||
$ ls
|
||||
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-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:
|
||||
|
||||
```sh
|
||||
$ kompose -f docker-compose.yml -f docker-guestbook.yml convert
|
||||
INFO Kubernetes file "frontend-service.yaml" created
|
||||
INFO Kubernetes file "mlbparks-service.yaml" created
|
||||
INFO Kubernetes file "mongodb-service.yaml" created
|
||||
INFO Kubernetes file "redis-master-service.yaml" created
|
||||
INFO Kubernetes file "redis-slave-service.yaml" created
|
||||
INFO Kubernetes file "frontend-deployment.yaml" created
|
||||
INFO Kubernetes file "mlbparks-deployment.yaml" created
|
||||
INFO Kubernetes file "mongodb-deployment.yaml" created
|
||||
INFO Kubernetes file "mongodb-claim0-persistentvolumeclaim.yaml" created
|
||||
INFO Kubernetes file "redis-master-deployment.yaml" created
|
||||
INFO Kubernetes file "redis-slave-deployment.yaml" created
|
||||
|
||||
$ ls
|
||||
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.
|
||||
|
||||
### OpenShift
|
||||
|
||||
```sh
|
||||
$ kompose --provider openshift --file docker-voting.yml convert
|
||||
WARN [worker] Service cannot be created because of missing port.
|
||||
INFO OpenShift file "vote-service.yaml" created
|
||||
INFO OpenShift file "db-service.yaml" created
|
||||
INFO OpenShift file "redis-service.yaml" created
|
||||
INFO OpenShift file "result-service.yaml" created
|
||||
INFO OpenShift file "vote-deploymentconfig.yaml" created
|
||||
INFO OpenShift file "vote-imagestream.yaml" created
|
||||
INFO OpenShift file "worker-deploymentconfig.yaml" created
|
||||
INFO OpenShift file "worker-imagestream.yaml" created
|
||||
INFO OpenShift file "db-deploymentconfig.yaml" created
|
||||
INFO OpenShift file "db-imagestream.yaml" created
|
||||
INFO OpenShift file "redis-deploymentconfig.yaml" created
|
||||
INFO OpenShift file "redis-imagestream.yaml" created
|
||||
INFO OpenShift file "result-deploymentconfig.yaml" created
|
||||
INFO OpenShift file "result-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.
|
||||
|
||||
```sh
|
||||
$ kompose --provider openshift --file buildconfig/docker-compose.yml convert
|
||||
WARN [foo] Service cannot be created because of missing port.
|
||||
INFO OpenShift Buildconfig using git@github.com:rtnpro/kompose.git::master as source.
|
||||
INFO OpenShift file "foo-deploymentconfig.yaml" created
|
||||
INFO OpenShift file "foo-imagestream.yaml" created
|
||||
INFO OpenShift 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 .
|
||||
|
||||
## Alternative Conversions
|
||||
|
||||
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, [Daemon Sets](http://kubernetes.io/docs/admin/daemons/), [Statefulset](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/) or [Helm](https://github.com/helm/helm) charts.
|
||||
|
||||
```sh
|
||||
$ kompose convert -j
|
||||
INFO Kubernetes file "redis-svc.json" created
|
||||
INFO Kubernetes file "web-svc.json" created
|
||||
INFO Kubernetes file "redis-deployment.json" created
|
||||
INFO Kubernetes file "web-deployment.json" created
|
||||
```
|
||||
The `*-deployment.json` files contain the Deployment objects.
|
||||
|
||||
```sh
|
||||
$ kompose convert --controller replicationController
|
||||
INFO Kubernetes file "redis-svc.yaml" created
|
||||
INFO Kubernetes file "web-svc.yaml" created
|
||||
INFO Kubernetes file "redis-replicationcontroller.yaml" created
|
||||
INFO Kubernetes file "web-replicationcontroller.yaml" created
|
||||
```
|
||||
|
||||
The `*-replicationcontroller.yaml` files contain the Replication Controller objects. If you want to specify replicas (default is 1), use `--replicas` flag: `$ kompose convert --controller replicationController --replicas 3`
|
||||
|
||||
```sh
|
||||
$ kompose convert --controller daemonSet
|
||||
INFO Kubernetes file "redis-svc.yaml" created
|
||||
INFO Kubernetes file "web-svc.yaml" created
|
||||
INFO Kubernetes file "redis-daemonset.yaml" created
|
||||
INFO Kubernetes file "web-daemonset.yaml" created
|
||||
```
|
||||
|
||||
The `*-daemonset.yaml` files contain the Daemon Set objects
|
||||
|
||||
```sh
|
||||
$ kompose convert --controller statefulset
|
||||
INFO Kubernetes file "db-service.yaml" created
|
||||
INFO Kubernetes file "wordpress-service.yaml" created
|
||||
INFO Kubernetes file "db-statefulset.yaml" created
|
||||
INFO Kubernetes file "wordpress-statefulset.yaml" created
|
||||
```
|
||||
|
||||
The `*statefulset-.yaml` files contain the Statefulset objects.
|
||||
|
||||
|
||||
If you want to generate a Chart to be used with [Helm](https://github.com/kubernetes/helm) simply do:
|
||||
|
||||
```sh
|
||||
$ kompose convert -c
|
||||
INFO Kubernetes file "web-svc.yaml" created
|
||||
INFO Kubernetes file "redis-svc.yaml" created
|
||||
INFO Kubernetes file "web-deployment.yaml" created
|
||||
INFO Kubernetes file "redis-deployment.yaml" created
|
||||
chart created in "./docker-compose/"
|
||||
|
||||
$ tree docker-compose/
|
||||
docker-compose
|
||||
├── Chart.yaml
|
||||
├── README.md
|
||||
└── templates
|
||||
├── redis-deployment.yaml
|
||||
├── redis-svc.yaml
|
||||
├── web-deployment.yaml
|
||||
└── web-svc.yaml
|
||||
```
|
||||
|
||||
The chart structure is aimed at providing a skeleton for building your Helm charts. It's compatible with both Helm V2 and Helm V3.
|
||||
|
||||
## Labels
|
||||
|
||||
`kompose` supports Kompose-specific labels within the `docker-compose.yml` file to
|
||||
explicitly define the generated resources' behavior upon conversion, like Service, PersistentVolumeClaim...
|
||||
|
||||
The currently supported options are:
|
||||
|
||||
| Key | Value |
|
||||
|----------------------|-------------------------------------|
|
||||
| kompose.service.type | nodeport / clusterip / loadbalancer / headless |
|
||||
| kompose.service.group | name to group the containers contained in a single pod |
|
||||
| kompose.service.expose | true / hostnames (separated by comma) |
|
||||
| kompose.service.nodeport.port | port value (string) |
|
||||
| kompose.service.expose.tls-secret | secret name |
|
||||
| kompose.volume.size | kubernetes supported volume size |
|
||||
| kompose.volume.storage-class-name | kubernetes supported volume storageClassName |
|
||||
| kompose.volume.type | use k8s volume type, eg "configMap", "persistentVolumeClaim", "emptyDir", "hostPath" |
|
||||
| kompose.controller.type | deployment / daemonset / replicationcontroller |
|
||||
| kompose.image-pull-policy | kubernetes pods imagePullPolicy |
|
||||
| kompose.image-pull-secret | kubernetes secret name for imagePullSecrets |
|
||||
| kompose.service.healthcheck.readiness.disable | kubernetes readiness disable |
|
||||
| kompose.service.healthcheck.readiness.test | kubernetes readiness exec command |
|
||||
| kompose.service.healthcheck.readiness.http_get_path | kubernetes readiness httpGet path |
|
||||
| kompose.service.healthcheck.readiness.http_get_port | kubernetes readiness httpGet port |
|
||||
| kompose.service.healthcheck.readiness.tcp_port | kubernetes readiness tcpSocket port |
|
||||
| kompose.service.healthcheck.readiness.interval | kubernetes readiness interval value |
|
||||
| kompose.service.healthcheck.readiness.timeout | kubernetes readiness timeout value |
|
||||
| kompose.service.healthcheck.readiness.retries | kubernetes readiness retries value |
|
||||
| kompose.service.healthcheck.readiness.start_period | kubernetes readiness start_period |
|
||||
| kompose.service.healthcheck.liveness.http_get_path | kubernetes liveness httpGet path |
|
||||
| kompose.service.healthcheck.liveness.http_get_port | kubernetes liveness httpGet port |
|
||||
| kompose.service.healthcheck.liveness.tcp_port | kubernetes liveness tcpSocket port |
|
||||
|
||||
**Note**: `kompose.service.type` label should be defined with `ports` only (except for headless service), otherwise `kompose` will fail.
|
||||
|
||||
|
||||
|
||||
- `kompose.service.type` defines the type of service to be created.
|
||||
|
||||
For example:
|
||||
|
||||
```yaml
|
||||
version: "2"
|
||||
services:
|
||||
nginx:
|
||||
image: nginx
|
||||
dockerfile: foobar
|
||||
build: ./foobar
|
||||
cap_add:
|
||||
- ALL
|
||||
container_name: foobar
|
||||
labels:
|
||||
kompose.service.type: nodeport
|
||||
```
|
||||
|
||||
- `kompose.service.group` defines the group of containers included in a single pod.
|
||||
|
||||
For example:
|
||||
|
||||
```yaml
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
nginx:
|
||||
image: nginx
|
||||
depends_on:
|
||||
- logs
|
||||
labels:
|
||||
- kompose.service.group=sidecar
|
||||
|
||||
logs:
|
||||
image: busybox
|
||||
command: ["tail -f /var/log/nginx/access.log"]
|
||||
labels:
|
||||
- kompose.service.group=sidecar
|
||||
```
|
||||
|
||||
- `kompose.service.expose` defines if the service needs to be made accessible from outside the cluster or not. If the value is set to "true", the provider sets the endpoint automatically, and for any other value, the value is set as the hostname. If multiple ports are defined in a service, the first one is chosen to be the exposed.
|
||||
- For the Kubernetes provider, an ingress resource is created and it is assumed that an ingress controller has already been configured. If the value is set to a comma sepatated list, multiple hostnames are supported.Hostname with path is also supported.
|
||||
- For the OpenShift provider, a route is created.
|
||||
- `kompose.service.nodeport.port` defines the port value when service type is `nodeport`, this label should only be set when the service only contains 1 port. Usually kubernetes define a port range for node port values, kompose will not validate this.
|
||||
- `kompose.service.expose.tls-secret` provides the name of the TLS secret to use with the Kubernetes ingress controller. This requires kompose.service.expose to be set.
|
||||
|
||||
For example:
|
||||
|
||||
```yaml
|
||||
version: "2"
|
||||
services:
|
||||
web:
|
||||
image: tuna/docker-counter23
|
||||
ports:
|
||||
- "5000:5000"
|
||||
links:
|
||||
- redis
|
||||
labels:
|
||||
kompose.service.expose: "counter.example.com,foobar.example.com"
|
||||
kompose.service.expose.tls-secret: "example-secret"
|
||||
redis:
|
||||
image: redis:3.0
|
||||
ports:
|
||||
- "6379"
|
||||
```
|
||||
|
||||
- `kompose.serviceaccount-name` defines the service account name to provide the credential info of the pod.
|
||||
|
||||
For example:
|
||||
|
||||
```yaml
|
||||
version: '3.4'
|
||||
services:
|
||||
app:
|
||||
image: python
|
||||
labels:
|
||||
kompose.serviceaccount-name: "my-service"
|
||||
```
|
||||
|
||||
- `kompose.image-pull-secret` defines a kubernetes secret name for imagePullSecrets podspec field.
|
||||
This secret will be used for pulling private images.
|
||||
For example:
|
||||
|
||||
```yaml
|
||||
version: '2'
|
||||
services:
|
||||
tm-service:
|
||||
image: premium/private-image
|
||||
labels:
|
||||
kompose.image-pull-secret: "example-kubernetes-secret"
|
||||
```
|
||||
|
||||
- `kompose.volume.size` defines the requests storage's size in the PersistentVolumeClaim, or you can use command line parameter `--pvc-request-size`.
|
||||
The priority follow label (kompose.volume.size) > command parameter(--pvc-request-size) > defaultSize (100Mi)
|
||||
|
||||
For example:
|
||||
|
||||
```yaml
|
||||
version: '2'
|
||||
services:
|
||||
db:
|
||||
image: postgres:10.1
|
||||
labels:
|
||||
kompose.volume.size: 1Gi
|
||||
volumes:
|
||||
- db-data:/var/lib/postgresql/data
|
||||
```
|
||||
|
||||
- `kompose.volume.storage-class-name` defines the requests storage's class name in the PersistentVolumeClaim.
|
||||
|
||||
For example:
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
services:
|
||||
db:
|
||||
image: postgres:10.1
|
||||
labels:
|
||||
kompose.volume.storage-class-name: custom-storage-class-name
|
||||
volumes:
|
||||
- db-data:/var/lib/postgresql/data
|
||||
```
|
||||
|
||||
- `kompose.controller.type` defines which controller type should convert for this service
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
web:
|
||||
image: wordpress:4.5
|
||||
ports:
|
||||
- '80'
|
||||
environment:
|
||||
WORDPRESS_AUTH_KEY: changeme
|
||||
WORDPRESS_SECURE_AUTH_KEY: changeme
|
||||
WORDPRESS_LOGGED_IN_KEY: changeme
|
||||
WORDPRESS_NONCE_KEY: changeme
|
||||
WORDPRESS_AUTH_SALT: changeme
|
||||
WORDPRESS_SECURE_AUTH_SALT: changeme
|
||||
WORDPRESS_LOGGED_IN_SALT: changeme
|
||||
WORDPRESS_NONCE_SALT: changeme
|
||||
WORDPRESS_NONCE_AA: changeme
|
||||
restart: always
|
||||
links:
|
||||
- 'db:mysql'
|
||||
db:
|
||||
image: mysql:5.7
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: password
|
||||
restart: always
|
||||
labels:
|
||||
project.logs: /var/log/mysql
|
||||
kompose.controller.type: daemonset
|
||||
```
|
||||
|
||||
Service `web` will be converted to `Deployment` as default, service `db` will be converted to `DaemonSet` because of `kompose.controller.type` label.
|
||||
|
||||
- `kompose.image-pull-policy` defines Kubernetes PodSpec imagePullPolicy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is specified, or IfNotPresent otherwise.
|
||||
|
||||
For example:
|
||||
|
||||
```yaml
|
||||
version: '2'
|
||||
services:
|
||||
example-service:
|
||||
image: example-image
|
||||
labels:
|
||||
kompose.image-pull-policy: "Never"
|
||||
```
|
||||
|
||||
|
||||
For example:
|
||||
|
||||
```yaml
|
||||
version: '2'
|
||||
services:
|
||||
example-service:
|
||||
image: example-image
|
||||
labels:
|
||||
kompose.service.healthcheck.liveness.http_get_path: /health/ping
|
||||
kompose.service.healthcheck.liveness.http_get_port: 8080
|
||||
healthcheck:
|
||||
interval: 10s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 30s
|
||||
```
|
||||
|
||||
- `kompose.service.healthcheck.liveness` defines Kubernetes [liveness HttpRequest](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-a-liveness-http-request), If you use healthcheck without liveness labels, have to define `test` in healcheck it's work to Kubernetes [liveness command](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-readiness-probes)
|
||||
|
||||
For example:
|
||||
|
||||
```yaml
|
||||
version: '2'
|
||||
services:
|
||||
example-service:
|
||||
image: example-image
|
||||
labels:
|
||||
kompose.service.healthcheck.readiness.test: CMD curl -f "http://localhost:8080/health/ping"
|
||||
kompose.service.healthcheck.readiness.interval: 10s
|
||||
kompose.service.healthcheck.readiness.timeout: 10s
|
||||
kompose.service.healthcheck.readiness.retries: 3
|
||||
kompose.service.healthcheck.readiness.start_period: 30s
|
||||
```
|
||||
- `kompose.service.healthcheck.readiness` defines Kubernetes [readiness](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-readiness-probes)
|
||||
|
||||
## Restart
|
||||
|
||||
If you want to create normal pods without controller you can use `restart` construct of docker-compose to define that. Follow table below to see what happens on the `restart` value.
|
||||
|
||||
| `docker-compose` `restart` | object created | Pod `restartPolicy` |
|
||||
|----------------------------|-------------------|---------------------|
|
||||
| `""` | controller object | `Always` |
|
||||
| `always` | controller object | `Always` |
|
||||
| `unless-stopped` | controller object | `Always` |
|
||||
| `on-failure` | Pod | `OnFailure` |
|
||||
| `no` | Pod | `Never` |
|
||||
|
||||
**Note**: controller object could be `deployment` or `replicationcontroller`, etc.
|
||||
|
||||
For e.g. `pival` service will become pod down here. This container calculated value of `pi`.
|
||||
|
||||
```yaml
|
||||
version: '2'
|
||||
|
||||
services:
|
||||
pival:
|
||||
image: perl
|
||||
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
|
||||
restart: "on-failure"
|
||||
```
|
||||
|
||||
#### Warning about Deployment Config's
|
||||
|
||||
If the Docker Compose file has a volume specified for a service, the Deployment (Kubernetes) or DeploymentConfig (OpenShift) strategy is changed to "Recreate" instead of "RollingUpdate" (default). This is done to avoid multiple instances of a service from accessing a volume at the same time.
|
||||
|
||||
If the Docker Compose file has service name with `_` or `.` in it (eg.`web_service` or `web.service`), then it will be replaced by `-` and the service name will be renamed accordingly (eg.`web-service`). Kompose does this because "Kubernetes" doesn't allow `_` in object name.
|
||||
|
||||
Please note that changing service name might break some `docker-compose` files.
|
||||
|
||||
## Build and push image
|
||||
|
||||
If the Docker Compose file has `build` or `build:context, build:dockerfile` keys, build will run when `--build` specified.
|
||||
|
||||
And Image will push to *docker.io* (default) when `--push-image=true` specified.
|
||||
|
||||
It is possible to push to custom registry by specify `--push-image-registry`, which will override the registry from image name.
|
||||
|
||||
### Authentication on registry
|
||||
|
||||
Kompose uses the docker authentication from file `$DOCKER_CONFIG/config.json`, `$HOME/.docker/config.json`, and `$HOME/.dockercfg` after `docker login`.
|
||||
|
||||
**This only works fine on Linux but macOS would fail when using `"credsStore": "osxkeychain"`.**
|
||||
|
||||
However, there is an approach to push successfully on macOS, by not using `osxkeychain` for `credsStore`. To disable `osxkeychain`:
|
||||
* remove `credsStore` from `config.json` file, and `docker login` again.
|
||||
* for some docker desktop versions, there is a setting `Securely store Docker logins in macOS keychain`, which should be unchecked. Then restart docker desktop if needed, and `docker login` again.
|
||||
|
||||
Now `config.json` should contain base64 encoded passwords, then push image should succeed. Working, but not safe though! Use it at your risk.
|
||||
|
||||
For Windows, there is also `credsStore` which is `wincred`. Technically it will fail on authentication as macOS does, but you can try the approach above like macOS too.
|
||||
|
||||
## Docker Compose Versions
|
||||
|
||||
Kompose supports Docker Compose versions: 1, 2 and 3. We have limited support on versions 2.1 and 3.2 due to their experimental nature.
|
||||
|
||||
A full list on compatibility between all three versions is listed in our [conversion document](/docs/conversion.md) including a list of all incompatible Docker Compose keys.
|
||||