AIOps

 View Only

Deploying Virtual Machine using Hybrid Application Model from CP4MCM Service Library

By DIVYA KAMATH posted Wed November 18, 2020 06:26 AM

  

Assumptions

The context of this article assumes that IBM CP4MCM 2.0 is installed with Infrastructure Management module.

Introduction:

Hybrid applications provide a way to group individual Kubernetes components, such as Services, Deployments, StatefulSets, Ingresses, CRDs, and manage them as a group. With the introduction of the hybrid application model, one can now create hybrid applications that include, deploy, and monitor resources that span containers, virtual machines, and cloud services. The support for these components within an application gives the ability to connect applications to infrastructure for managing.

This article explains how to deploy a Virtual Machine(VM) using Hybrid Application Model from the Service Library in IBM Cloud Pak for Multicloud Management v2.0. This release onwards it is possible to save application yaml files - just like terraform templates and services in the Service Library. In the application yaml there exists a variable viz. ${prefix} in metadata.name of each resource type which gets deployed as Application resource. While creating Application instances, ${prefix} variable is substituted with value provided by the user.

While deploying the application yaml provided as part of this article, it creates following resources in the selected namespace.
1. Application - An Application resource.
2. Hybrid Deployable - A hybrid deployable resource which includes a hybrid template to deploy VM in ibminfra. 
3. Connection - A Connection custom resource that contains the Infrastructure management endpoint and credentials.
4. VirtualMachine -  A VirtualMachine custom resource which deploys a VM in the Infrastructure Management(IM).

Pre-requisite: The pre-requisite to deploy a VM in IM from Service Library is to have a service in IM catalog, which provisions a virtual machine in any environment like AWS, Azure or VMware which is managed in IM. The steps for creating a service in IM to provision virtual machine can be found here. Once the pre-requisite is in place, these steps can be followed to create and deploy hybrid application that provisions VM from Service Library.


Steps
:

1. Request an authentication token for invoking the Infrastructure Management (CloudForms) REST API, by running following command:

curl -k -u <username>:<password> -X GET "Accept: application/json" https://<IM_URL>/api/auth

where <IM_URL> is the Infrastructure Management URL, <username> and <password> are credentials for logging in to IM.


2. Invoke the Infrastructure Management REST API which retrieves the details of service template used to provision the VM. Provide access token obtained in the previous step in the header of the REST API request with key X-AUTH-TOKEN.

GET https://<IM_URL>/api/service_templates/<id>

where <IM_URL> is the Infrastructure Management URL and <id> is the ID of the desired service template which provisions the VM.

3. Prepare the application yaml as per the attached sample. vm-deploy-application.yaml
The 
spec.options values of the VirtualMachine resource needs to be filled in using the config_info key values in the output of Infrastructure Management API invoked in the step 2.

4. Now that the application yaml is ready, it needs to be saved in Applications section of Service Library. On CP4MCM console, navigate to Automate Infrastructure -> Manage Services ->  Applications [tab] and click on Add Application. Provide a name, category, description and copy-paste the content of application yaml. Assign access can be either done while creating the application or later. Once the access is assigned to one or more namespaces, click on the overflow menu and select Publish to publish the application in Service Library. 

5. On CP4MCM console, navigate to Automate Infrastructure -> Service Library, click on the application tile which is created for deploying VM. Select a namespace and provide value for ${prefix} variable. Click on Deploy.

One can go to Deployed Instances to check the details of Application instance that is deployed or go to Manage Applications -> Hybrid Applications on CP4MCM console and view the deployed application topology. To check the status of the VM deployment, one can do oc login through CLI, check the status of VirtualMachine CR in the namespace where it is deployed. When the VM deployment is completed, oc get virtualmachine <name_of_virtualmachine_cr> would display "STATUS" as "finished". It also provides VMID, VMNAME and PROVIDER values of the deployed VM. This can be verified by logging into IM and viewing the deployed VM instance.

Note
1. If using non-default Connection CR, it should co-exist in the same namespace as that of VirtualMachine CR.
2. If no namespace is mentioned in the metadata of VirtualMachine CR, it would create the VirtualMachine CR in management-infrastructure-management namespace where Infrastructure Management modules are installed.
3. If the cfConnection parameter is not specified in the VirtualMachine CR, the default Connection CR, imconnection is used.




References
>  Infrastructure Management Operator - https://www.ibm.com/support/knowledgecenter/en/SSFC4F_2.0.0/mcm/infrastructure/infra_mgmt_operator.htmlhttps://www.ibm.com/support/knowledgecenter/en/SSFC4F_2.0.0/mcm/infrastructure/infra_mgmt_operator.html
>  Application Management - https://www.ibm.com/support/knowledgecenter/en/SSFC4F_2.0.0/mcm/applications/overview.html
>  Creating and Managing Applications - https://www.ibm.com/support/knowledgecenter/en/SSFC4F_2.0.0/cam/cam_managing_applications.html



0 comments
33 views

Permalink