By default, Hybrid Container Cloud delivers a set of default Template
objects. You can also build your own templates
and use them for deployment.
At the moment all
Templates
should reside in thehmc-system
namespace. But they can be referenced byManagedClusters
from any namespace.
Here are the instructions on how to bring your own Template to HMC:
- Create a HelmRepository object containing the URL to the
external Helm repository. Label it with
hmc.mirantis.com/managed: "true"
. - Create a HelmChart object referencing the
HelmRepository
as asourceRef
, specifying the name and version of your Helm chart. Label it withhmc.mirantis.com/managed: "true"
. - Create a
Template
object inhmc-system
namespace referencing this helm chart inspec.helm.chartRef
.chartRef
is a field of the CrossNamespaceSourceReference kind.
Here is an example of a custom Template
with the HelmChart
reference:
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
name: custom-templates-repo
namespace: hmc-system
labels:
hmc.mirantis.com/managed: "true"
spec:
insecure: true
interval: 10m0s
provider: generic
type: oci
url: oci://ghcr.io/external-templates-repo/charts
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmChart
metadata:
name: custom-template-chart
namespace: hmc-system
labels:
hmc.mirantis.com/managed: "true"
spec:
interval: 5m0s
chart: custom-template-chart-name
reconcileStrategy: ChartVersion
sourceRef:
kind: HelmRepository
name: custom-templates-repo
version: 0.2.0
apiVersion: hmc.mirantis.com/v1alpha1
kind: Template
metadata:
name: os-k0smotron
namespace: hmc-system
spec:
type: deployment
providers:
infrastructure:
- openstack
bootstrap:
- k0s
controlPlane:
- k0smotron
helm:
chartRef:
kind: HelmChart
name: custom-template-chart
namespace: default
The Template
should follow the rules mentioned below:
spec.type
should bedeployment
(as an alternative, the referenced helm chart may contain thehmc.mirantis.com/type: deployment
annotation inChart.yaml
).spec.providers
should contain the list of required Cluster API providers:infrastructure
,bootstrap
andcontrolPlane
. As an alternative, the referenced helm chart may contain the specific annotations in theChart.yaml
(value is a list of providers divided by comma). These fields are only used for validation. For example:
Template
spec:
spec:
providers:
infrastructure:
- aws
bootstrap:
- k0s
controlPlane:
- k0smotron
Chart.yaml
:
annotations:
hmc.mirantis.com/infrastructure-providers: aws
hmc.mirantis.com/controlplane-providers: k0smotron
hmc.mirantis.com/bootstrap-providers: k0s
If you need to limit the cluster templates that exist in your HMC installation, follow the instructions below:
- Get the list of
deployment
Templates shipped with HMC:
kubectl get templates -n hmc-system -l helm.toolkit.fluxcd.io/name=hmc-templates | grep deployment
Example output:
aws-hosted-cp deployment true
aws-standalone-cp deployment true
- Remove the templates from the list:
kubectl delete template -n hmc-system <template-name>