$ oc create configmap --from-file=<templates-directory> smcp-templates -n openshift-operators
Templates allow a cluster administrator to create reusable configurations that users may extend with their own customizations. Templates may also inherit from other templates. As an example, if there are two teams with different control planes, say an accounting team and a website team, with a development and production configuration, then there could be a template called development and one called production and individual templates for the accounting and development teams that extend these two configurations with their own customizations. Individual control planes in the teams can customize these for the actual deployment.
Templates follow the same configuration as a ServiceMeshControlPlane
so if you get a ServiceMeshControlPlane
working, you can then
include it as a template. To add custom templates, create a ConfigMap
called smcp-templates
in the openshift-operators
project.
This ConfigMap
will contain a collection of templates to use. The ConfigMap
must then be mounted in the operator at
/usr/local/share/istio-operator/templates/
.
To create the ConfigMap
, execute the following as a cluster administrator, substituting <templates-directory> for a directory containing a
collection of ServiceMeshControlPlane
files to use as templates. The name of the template will match the name of the file. Templates will
inherit from other templates until a template is reached which has an empty template field. Using a template name of default
will override the
default template for all control planes when no template is specified in a control plane.
To create a template, save a ServiceMeshControlPlane
in a directory referred to as <templates-directory>
.
Follow the instructions below to create and configure a ConfigMap
containing this new
template. Additional templates can be added to the ConfigMap
as desired.
$ oc create configmap --from-file=<templates-directory> smcp-templates -n openshift-operators
Next, find the Maistra operator ClusterServiceVersion
name.
$ oc get clusterserviceversion -n openshift-operators | grep 'Service Mesh' maistra.v1.1.0 Red Hat OpenShift Service Mesh 1.1.0 Succeeded
Edit the ClusterServiceVersion
to instruct the operator to use the smcp-templates
ConfigMap
.
$ oc edit clusterserviceversion -n openshift-operators maistra.v1.1.0
In the editor, add a volume mount and volume to the deployments as shown below.
deployments:
- name: istio-operator
spec:
template:
spec:
containers:
volumeMounts:
- name: smcp-templates
mountPath: /usr/local/share/istio-operator/templates/
volumes:
- name: smcp-templates
configMap:
name: smcp-templates
...
You can now use templates in your ServiceMeshControlPlane
by adding a
template
parameter to the ServiceMeshControlPlane
. In the example below,
we are including the default
template, but you can use any template from the
smcp-templates
ConfigMap
as well.
apiVersion: maistra.io/v1
kind: ServiceMeshControlPlane
metadata:
name: minimal-install
spec:
template: default