MCM - Concepts
MCM Manages applications by defining them as custom resource definitions in Kubernetes. By defining these resources we can install, delete and update resources on the managed MCM clusters. When these MCM resources are created the changes are applied on the target MCM cluster via the MCM Klusterlet.
In the next sections we will explore the different resources MCM provides.
The channel resource defines the location of an resource to be deployed. These resources can be a Helm repository, Kubernetes namespace, Object store or Git repository.
The sample below describes a Channel the points to a HelmRepo.
kubectl create -f - <<EOFapiVersion: v1kind: Namespacemetadata:name: google-deployables---apiVersion: app.ibm.com/v1alpha1kind: Channelmetadata:
Once the channel definition above has been applied you can get your channel.
oc get channels -n google-deployablesNAME TYPE PATHNAME AGEgoogle-incubator-repo HelmRepo http://storage.googleapis.com/kubernetes-charts-incubator 3m41s
When the channel is created it will query the target HelmRepo and create MCM
deployables for each of the Helm charts in the repo.
oc get deployables -n google-deployablesNAME TEMPLATE-KIND TEMPLATE-APIVERSION AGE STATUSgoogle-incubator-repo-artifactory-5.2.1 HelmRelease app.ibm.com/v1alpha1 5m39sgoogle-incubator-repo-aws-alb-ingress-controller-0.1.12 HelmRelease app.ibm.com/v1alpha1 5m38sgoogle-incubator-repo-azuremonitor-containers-2.5.0 HelmRelease app.ibm.com/v1alpha1 5m43s.........app.ibm.com/v1alpha1 5m43s
You can see that all the Helm charts are now available as
deployables and are available to be deployed using MCM. In this section a HelmRepo has been used as an example of a Channel. You can find additional information on Channels here: https://www.ibm.com/support/knowledgecenter/en/SSFC4F_1.2.0/mcm/applications/managing_channels.html
PlacementRules are an MCM resource that define where resources should be deployed. PlacementRules by themeselves do not do anything, but can be included as a reference in other resource types or embedded in other MCM resource types.
Below is an example:
kubectl create -f - <<EOFapiVersion: v1kind: Namespacemetadata:name: etcd-project---apiVersion: app.ibm.com/v1alpha1kind: PlacementRulemetadata:
The example PlacementRule is defining a rule called
my-placementrule and will deploy only on clusters that match the label
myapp. This is a simple example, but PlacementRules can be used to determine number of replicas and more complex logic can be applied to control where MCM resources will be deployed.
More information on PlacementRules can be found here: https://www.ibm.com/support/knowledgecenter/en/SSFC4F_1.2.0/mcm/applications/managing_placement_rules.html
The Subscription resource is the resource that combines the
Channel and the
PlacementRule to determine which resources should be deployed and where they should be deployed. A subscription does this by referencing a specific Deployable resource defined by a Channel and will either embed a PlacementRule or reference an existing PlacementRule. The Subscription can also modify the defualt values that maybe defined in a Deployable by defining
kubectl create -f - <<EOFapiVersion: app.ibm.com/v1alpha1kind: Subscriptionmetadata:name: etcdnamespace: etcd-projectlabels:purpose: myappspec:
In the example above we are creating a namespace called
etc-subscription and we are creating a Subscription in that namespace called
etcd. The subscription references the etcd version 0.7.3 Helm chart in the google-incbuator Channel created earier and references the PlacementRule
my-placementrule. At the end of the subscription an override is defined to deploy the Helm chart in the namespace
myapp instead of the default namespace.
Note: The PlacementRule must be in the same namespace as the Subscription.
After this is Subsciption is applied we can view our Subscription.
oc get deployables.app.ibm.com -A | grep Subscription | grep etcdetcd-project etcd-deployable Subscription app.ibm.com/v1alpha1 3m59s Propagated
Notice that this shows that we created a Subscription and the status shows
Propagated. This shows us that we have successfully created the Subscription, but there are no clusters that meet the criteria as targets for our PlacementRule.
First let’s get our available clusters
oc get clusters -ANAMESPACE NAME MANAGED BY ENDPOINTS STATUS AGEctcp4ai ctcp4ai hub0 api.ctcp4ai.ocp.csplab.local:6443 Ready 15h
Next let’s add the
myapp label to the
oc label cluster ctcp4ai -n ctcp4ai cluster=myapp
Now let’s check our Subscription again
oc get deployables.app.ibm.com -A | grep Subscription | grep etcdctcp4ai etcd-deployable-fh798 Subscription app.ibm.com/v1alpha1 3m58s Deployedetcd-project etcd-deployable Subscription app.ibm.com/v1alpha1 3m59s Propagated
Now we see that there is an additional Subscription in the namespace of the target cluster that shows
Deployed. The HelmChart should now be deployed on the target cluster.
From the target system
Once the Subsciption shows
Deployed on the MCM Hub server you should be able to see the subscription on the target cluster:
oc get subscriptions.app.ibm.com --all-namespaces | grep etcdmyapp etcd Subscribed 11m
In addition since this is a Helm chart subscription you should see a
helmrelease object as well:
oc get helmreleases.app.ibm.com --all-namespaces | grep etcdmyapp etcd-etcd-myapp 14m
Finally we can see that the Helm chart was deployed to the
oc get po -n myappNAME READY STATUS RESTARTS AGEetcd-0 1/1 Running 0 8m17setcd-1 1/1 Running 0 7m59setcd-2 1/1 Running 0 7m42s
Additional documentation can be found to describe the Subscription resource here: https://www.ibm.com/support/knowledgecenter/en/SSFC4F_1.2.0/mcm/applications/managing_subscriptions.html
The Application resource is used to reference other MCM resources that we want to define as an Application. Since an Application may be composed of multiple MCM resources we can use selectors to combine the different components.
If you login to the MCM Console and Navigate to Manage Applications you will not see our etcd subscription. Even though we have already deployed the components we will not be able to manage them as a whole until we create an Application resource.
See the example below:
kubectl create -f - <<EOFapiVersion: app.k8s.io/v1beta1kind: Applicationmetadata:name: etcd-applicationnamespace: etcd-projectspec:selector:matchLabels:
MCM channel documentation