Preparing your application
KuberLogic provides a simple way to deploy your application as SaaS by supporting docker-compose.yml
structure.
KuberLogic only supports a single application type configured via docker-compose.yml. Any change to this file will be propagated to all KuberLogic managed applications.
You will be asked to enter path to the docker-compose.yml during the installation process, otherwise KuberLogic will be provisioned with demo application.
Limitations
There are few limitations about supported docker-compose.yml:
Only one service can have its ports published
Will work:
version: "3"
services:
- name: my-service
image: my-image
command:
- "./run.sh"
- name: my-service-2
image: my-image
ports:
- "8080:8080"
command:
- "./run.sh"
Will not work:
version: "3"
services:
- name: my-service
image: my-image
ports:
- "8080:8080"
command:
- "./run.sh"
- name: my-service-2
image: my-image
ports:
- "8080:8080"
command:
- "./run.sh"
Only a single port can be published.
Will work:
version: "3"
services:
- name: my-service
image: my-image
command:
- "./run.sh"
- name: my-service-2
image: my-image
ports:
- "8080:8080"
command:
- "./run.sh"
Will not work:
version: "3"
services:
- name: my-service
image: my-image
command:
- "./run.sh"
- name: my-service-2
image: my-image
ports:
- "8080:8080"
- "8081:8081"
command:
- "./run.sh"
Local volume mounts are not supported
Will work:
version: "3"
volumes:
data:
services:
- name: my-service
image: my-image
command:
- "./run.sh"
volumes:
- data:/data
Will not work:
version: "3"
services:
- name: my-service
image: my-image
command:
- "./run.sh"
volumes:
- ./data:/data
Templating docker-compose.yml
KuberLogic also supports templating certain service fields in docker-compose.yml
by using Go templates.
Fields that can be templated are:
image
command
environment
variables' valuesx-kuberlogic-file-configs
extensionx-kuberlogic-secrets
extension
Service parameters that can be accessed in the template are:
Name
: The name of the serviceNamespace
: The namespace of the serviceHost
: The host of the serviceReplicas
: The number of replicas of the serviceVolumeSize
: The size of the volume of the serviceVersion
: The version of the serviceTLSEnabled
: Whether the service is TLS enabledParameters
: The advanced parameters of the service
There are also a few functions that can be used for environment variables:
Endpoint
: Returns the endpoint of the serviceBase64
: Encodes string using Base64 algorithmGenerateKey <len: int,optional>
: Generate a random key of the specified lengthGenerateRSAKey <bits: int,optional>
: Generate a random RSA key of the specified lengthSecret <name: string>
: Retrieves a secret from an application secret storage.
Generate...
functions will generate different values each time the template is rendered. This will result in constant service restarts.
You should use x-kuberlogic-secrets
configuration parameter to have a consistent value. See this page for more information.
Examples
Specify the image version
Provisioned services will use version
as the image tag or "latest" if not specified.
version: "3"
services:
- name: my-service
image: my-image:{{ default .Version "latest" }}
command:
- "./run.sh"
ports:
- "8080:8080"
Configure service URL parameter
version: "3"
services:
- name: my-service
image: my-image
command:
- "./run.sh"
ports:
- "8080:8080"
environment:
- BASE_URL={{ Endpoint "localhost.com" }}
Generate a random key and save it to the persistent secret
version: "3"
services:
- name: my-service
image: my-image
command:
- "./run.sh"
ports:
- "8080:8080"
environment:
- SECRET_KEY={{ GenerateKey 30 | PersistentSecret }}
Generate a random RSA key, encode it with Base64, persist in secret and share it between different services
RSA key will be generated and saved in a persistent secret under the "PRIVATE_RSA_KEY" key.
version: "3"
services:
- name: my-service
image: my-image
command:
- "./run.sh"
ports:
- "8080:8080"
environment:
- SECRET_KEY={{ GenerateRSAKey 2048 | Base64 | PersistentSecret "PRIVATE_RSA_KEY" }}
- name: my-service-2
image: my-image
command:
- "./run.sh"
ports:
- "8080:8080"
environment:
- SECRET_KEY={{ GenerateRSAKey 2048 | Base64 | PersistentSecret "PRIVATE_RSA_KEY" }}