Rancher Integrator docs - development

Repository: https://github.com/baycarbone/charm-rancher-integrator
Bugs / Issues: https://github.com/baycarbone/charm-rancher-integrator/issues

Development Setup

To set up a local test environment with MicroK8s:

# Install MicroK8s
$ sudo snap install --classic microk8s

# Wait for MicroK8s to be ready
$ sudo microk8s status --wait-ready

# Enable features required by Juju controller & charm
$ sudo microk8s enable storage dns ingress rbac

# (Optional) Alias kubectl bundled with MicroK8s package
$ sudo snap alias microk8s.kubectl kubectl

# (Optional) Add current user to 'microk8s' group
# This avoid needing to use 'sudo' with the 'microk8s' command
$ sudo usermod -aG microk8s $(whoami)

# Activate the new group (in the current shell only)
# Log out and log back in to make the change system-wide
$ newgrp microk8s

# Install Charmcraft
$ sudo snap install charmcraft

# Install juju
$ sudo snap install --classic juju

# Bootstrap the Juju controller on MicroK8s
$ juju bootstrap microk8s micro

# Add a new model to Juju
$ juju add-model development

Build and Deploy Locally

# Clone the charm code
$ git clone https://github.com/baycarbone/charm-rancher-integrator && cd charm-rancher-integrator

# Build the charm package
$ charmcraft pack

# Deploy!
$ juju deploy ./rancher-integrator.charm --resource rancher-integrator-image=baycarbone/rancher-integrator:latest

# Set required config options
$ juju config rancher-integrator url=<rancher url>
$ juju config rancher-integrator bearer-token=<rancher api token>
$ juju config rancher-integrator cert-verify=<'True'|'False'>

# Elavate permisions in order for the charm to communicate with the Kubernetes API
$ juju trust rancher-integrator --scope=cluster

# Wait for the deployment to complete
$ watch -n1 --color juju status --color

# Execute actions using actions-v2 for a better UX e.g:
export JUJU_FEATURES=actions-v2
$ juju run rancher-integrator/0 register --format=yaml
$ juju run rancher-integrator/0 unregister --format=yaml
$ juju run rancher-integrator/0 register name=<name> --format=yaml

Config options

  • url: url of the existing Rancher platform against which registration will be performed.

  • bearer-token: bearer-token needed to access the Rancher api. For more information on retrieving such a token, please see rancher-api-keys.

  • (optional) cert-verify: toggles verification of the Rancher platform certificate. Setting this to ‘False’ is not recommended but can be useful for development purposes when using a self-signed certificate.


Request the rancher-integration application to register the Kubernetes cluster, then retrieve the import manifest and apply it on the Kubernetes cluster hosting the charm.

The register action takes an optional name parameter when a user defined cluster name within the Rancher platform is desired. If this parameter is not set, a randomly generated cluster name will be assigned and returned to the user.

Request the rancher-integration application to unregister the Kubernetes cluster, then delete the import manifest from the Kubernetes cluster hosting the charm.


# Clone the charm code
$ git clone https://github.com/baycarbone/charm-rancher-integrator && cd charm-rancher-integrator

# Create a virtual environemnt for the charm code
$ python3 -m venv venv

# Activate the venv
$ source ./venv/bin/activate

# Install dependencies
$ pip install -r requirements-dev.txt

# Run the tests
$ ./run_tests