Installing Rancher Dashboard apps as code.
Rancher Version: 2.10
I've spent the downtime over Christmas automating my Rancher environment. So far i've been able to
- Terraform: Deploy node VM's on libvirt
- Ansible: Install Rancher 2.10 server on a cloud VPN with Letsencrypt
- Ansible: Install a control/etc node and 3 x worker nodes on the terraform-built VM's
(I'm not flexing here, i'm posting it to show I've done a lot of reading and research)
The last piece of the puzzle is the installation of Dashboard apps
I'd like to install as code
- rancher-monitoring
- rancher-longhorn
- rancher-istio
I tried this using the URI Ansible module and found a /k8s endpoint for the API with an install URL that looked positive. I wrote some Ansible that thinks it installs the above however it installs nothing.
https://github.com/rancher/rancher/issues/30130
- name: Install Longhorn
uri:
url: "https://{{ rancher.api_url }}/k8s/clusters/c-m-wf2rcz44/v1/catalog.cattle.io.clusterrepos/rancher-charts?action=install"
method: POST
headers:
Authorization: "Bearer {{ rancher.api_token }}"
Content-Type: "application/json"
body_format: json
body:
name: "longhorn"
namespace: "longhorn-system"
answers:
# Add any specific configuration options here if needed
persistence.storageClass: "longhorn" # Example option
catalogTemplate: "longhorn"
name: "longhorn"
namespace: "longhorn-system"
project: "default"
targetNamespace: "longhorn-system"
version: "{{ longhorn.version }}"
wait: true
status_code: 201
register: longhorn_install_result
- name: Debug Longhorn installation result
debug:
var: longhorn_install_result
- name: Install Cattle-Monitoring
uri:
url: "https://{{ rancher.api_url }}/k8s/clusters/c-m-wf2rcz44/v1/catalog.cattle.io.clusterrepos/rancher-charts?action=install"
method: POST
headers:
Authorization: "Bearer {{ rancher.api_token }}"
Content-Type: "application/json"
body_format: json
body:
name: "cattle-monitoring"
namespace: "cattle-monitoring-system"
answers:
# Add any specific configuration options here if needed
prometheus.persistentStorage.enabled: "{{ monitoring.persistent_storage.enabled }}"
prometheus.persistentStorage.size: "{{ monitoring.persistent_storage.size }}"
prometheus.persistentStorage.storageClass: "{{ monitoring.persistent_storage.storage_class }}"
catalogTemplate: "rancher-monitoring"
name: "rancher-monitoring"
namespace: "cattle-monitoring-system"
project: "system"
targetNamespace: "cattle-monitoring-system"
version: "{{ monitoring.version }}"
wait: true
status_code: 201
register: monitoring_install_result
- name: Debug Cattle-Monitoring installation result
debug:
var: monitoring_install_result
As I'm going to link this together using a github pipeline, I figured. cancher-cli got it setup and logged in, only to find it in the latest docs..
https://ranchermanager.docs.rancher.com/reference-guides/cli-with-rancher/rancher-cli
The Rancher CLI cannot be used to install dashboard apps or Rancher feature charts.
So my question is.. How can i install the three Dashboard apps above using code?
My assumption is there must be a helm chart I could use. However, I've no idea where to start.. If someone could give me some pointers or indeed an easier way of doing this it would be really appreciated..
As with everything I do, I'll blog the whole process/code for the community once I have it working..