/oc-templates2helm

Primary LanguageGroovyMIT LicenseMIT

Generate Helm Charts from OpenShift Templates

OpenShift Deployment Templates (OC Templates) are one way to create a Deployment blueprint for all Kubernetes (k8s) objects of your application. The OC Templates can use free variables which are replaced during deployment, e.g., based on Environment settings. Native k8s does not have such a mechanism, you only can send the object definitions (YAML or JSON) directly to the API-Server. There are several solutions to provide a Templating engine for k8s as well. Helm charts seem to becoming a de-facto standard for k8s in that area. Helm is sometimes attributed as the package manager for k8s (similar to Debian packages or RPM in the Linux world), or the Homebrew for k8s.

If you plan to migrate from OC Templates to Helm (for OC or generic Kubernetes), this tool might be a starting point for you. It tries to automate much of the conversion work and can generate a first version of your Helm chart from a given OC Template.

Note
You will still have to perform some manual steps to create a valid Helm chart!

Prerequisites

The software is written as a Groovy Script. You need to have a Groovy interpreter (groovy binary) in your execution ${PATH} and access to the Internet to make it fetch further libraries (via Groovy Grapes).

Checkout Grape proxy settings if you have Internet access via a Proxy (e.g., set JAVA_OPTS="-Dhttps.proxyHost=localhost -Dhttps.proxyPort=3128" for a local CNTLM proxy).

Usage

Just call the script with the OpenShift Template file, e.g., deployment-myservice.yaml:

octmpl2helm.groovy deployment-myservices.yaml
Caution
It will create a local directory generated-charts/ and may override existing files in this sub folder without any warning!

Limitations

The script currently only creates one chart template for each kind of OC template object it finds. Template variables are replaced by a corresponding Helm value. In particular, the script performs almost no checks if the target kind in OC or k8s is valid, with the following exceptions

  • DeploymentConfigDeployment

Issues

If you run into any problems or will provide any improvments or fixes,

License

link:LICENSE.txt[role=include]