Run a deployment to Rancher 2 via generated deployment.yml
file. It
generates this file based on Go's Package text/template
and processed
with Gomplate.
To use this image create a Dockerfile
with the following content:
FROM avenga/rancher2-deployment
The template file deployment.tmpl.yml
is copied with an
ONBUILD
trigger. This file should reside in the same directory as the
Dockerfile
.
By default kubectl diff
is run and the output printed to STDOUT. Thus there is
always a diff available in the CI/CD system to see what was changed.
If a namespace doesn't exist it will be created.
An example configration can be found under examples/
.
With the following variables the behaviour can be changed.
RANCHER_PROJECT
: Sets the project name in Rancher2. If not set the value ofPROJECT
is used.PROJECT
: Sets the Rancher2 project name. Can be overriden byRANCHER_PROJECT
.ENVIRONMENT
: Defines the folder underenvironment/
which is used by Gomplate. Gomplate sources all files in that folder to configure any environment variables, which are then used to seed the template. Additionally it is used together withPROJECT
/RANCHER_PROJECT
to build the name of the K8s namespace. Namespace becomes PROJECT-ENVIRONMENT in lower case letters.RANCHER_SERVER_URL
: URL under which the Rancher2 server is found. Used byrancher login
.RANCHER_BEARER_TOKEN
: Token to access Rancher2 and the specific project. Used byrancher login
.RANCHER_CONTEXT
: Tellsrancher login
which cluster and which project should be accessed. Uses the IDs and not the names. E.g.c-p8799:p-mq89d
.
RANCHER2_DEPLOYMENT_TRACE
: Enables trace mode when set to any value. Seehelp set
in Bash. Default: offDRY_RUN
: Don't do anything except print the parsed k8s configuration to STDOUT. Activate by setting to any value. Default: offRANCHER_SAVE_OUTPUT_DIR
: Name of the directory (should be a host volume) to where a copy of the rendered K8s configuration is saved. Name of the file isdeployment.yml
.RANCHER_NO_DIFF
: Turn off thekubectl diff
command.