Cloud Automation Manager Kubernetes resource controller for Cloud Automation Manager services
The Cloud Automation Manager Kubernetes custom resource definition and controller provides you with the ability to deploy and delete Cloud Automation Manager service instances using Kubernetes yaml resource files. With this capability, a single Kubernetes yaml can be created to deploy a composite application that consists of both Kubernetes deployable resources and traditional infrastructure resources, which are deployed with Terraform in Cloud Automation Manager A typical containerized application is an example of a kubernetes deployable resource. Examples of traditional infrastructure resources are Virtual machines, storage, and so on.
About the task
The Cloud Automation Manager Kubernetes resource controller deploys the Cloud Automation Manager service and waits for Active status. If the deployment FAILS, then the controller continues to issue Resume requests until the service becomes Active.
Before you begin
A role binding must be defined for a user or group to have the authority to deploy a service in Cloud Automation Manager.
The following is an example for the icp:camgroup:operator user group:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: icp:camgroup:operator:service
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cam-controller-manager-role
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: Group
name: icp:camgroup:operator
Procedure
- Deploying a Cloud Automation Manager service
- Displaying the status of a Cloud Automation Manager service
- Deleting a deployed Cloud Automation Manager service
Deploying a Cloud Automation Manager service
- Go to your Kubernetes environment that is same as Cloud Automation Manager.
-
Create your YAML file. The file allows the definition of the service deployment to be placed under the source control that allows changes to be tracked. An example Cloud Automation Manager Kubernetes service resource controller yaml file:
apiVersion: cloudautomationmgr.ibm.com/v1alpha1 kind: Service metadata: name: service-test-vsphere-1 namespace: "default" spec: connection: "camDc2Rtp" service: name: "LrhNodeOnSingleVM-vsphere" //Instance that you are going to deploy instance_plan: "host-164" action: "Provision" //The action is provision. parameters: templateParameters: [] specifications: parameters: //The parameters that are passed with the instance vSphereConfig: vSphere-CAMDC2 vm_ipv4_address: "9.9.9.9" vm_name: "camc-vis232c-vm-164" vm_dns_servers: - "9.9.9.9" vm_dns_suffixes: ["rtp.raleigh.ibm.com"]-
parameters - It is a collection of name/value pairs that map to the Cloud Automation Manager Service Input Parameter Key and Value. For example:
parameters: vSphereConfig: vSphere-CAMDC2 vm_ipv4_address: "9.9.9.9" vm_dns_suffixes: ["rtp.raleigh.ibm.com"] -
secretParameters- (Optional) List of Cloud Automation Manager secret parameter data objects to use with the deployed service. For example:secretParameters: name: vm_password_lrh secretKeyRef: name: vm-password-lrh-secret key: passwordwhere
name: name of service parameter
secretKeyRef:
name: Name of the kubernetes secret
key: key is the name of the secret data defined in the secret
-
-
Run the following kubectl command to deploy a Cloud Automation Manager service:
kubectl apply -f <yaml file name>
Displaying the status of a Cloud Automation Manager service
-
Verfiy the status of a deployed Cloud Automation Manager service by using either of the following commands:
kubectl describe -f <yaml file name>or
kubectl describe services.cloudautomationmgr.ibm.com service-test-vsphere-1 -n defaultExample:
Name: service-test-vsphere-1 Namespace: default Labels: <none> Annotations: kubectl.kubernetes.io/last-applied-configuration: {"apiVersion":"cloudautomationmgr.ibm.com/v1alpha1","kind":"Service","metadata":{"annotations":{},"name":"service-test-vsphere-1","namespa... API Version: cloudautomationmgr.ibm.com/v1alpha1 Kind: Service Metadata: Creation Timestamp: 2019-08-09T19:50:52Z Finalizers: Service.cloudautomationmgr.ibm.com Generation: 2 Resource Version: 6549804 Self Link: /apis/cloudautomationmgr.ibm.com/v1alpha1/namespaces/default/services/service-test-vsphere-1 UID: feadd3c9-bade-11e9-a019-00163e01cbab Spec: Secrets: Env: Service: Action: Provision instance_plan: Standard Name: LrhNodeOnSingleVM-vsphere Parameters: Specifications: Parameters: V Sphere Config: vSphere-CAMDC2 vm_datacenter: CAMDC2 vm_dns_servers: 9.42.106.3 vm_dns_suffixes: rtp.raleigh.ibm.com vm_ipv4_address: 9.46.126.166 vm_name: camc-vis232c-vm-166 Status: Action: provision Conditions: Last Transition Time: 2019-08-09T19:53:43Z Reason: Active Status: True Type: provision Message: Service ID: 5d4dce9d5b972d001dc804d8 Status: Active Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal provision:Submitted 2m51s cam-controller-service provision status changed for default/service-test-vsphere-1 Normal provision:In Progress 2m32s cam-controller-service provision status changed for default/service-test-vsphere-1 Normal provision:Active 1s cam-controller-service provision status changed for default/service-test-vsphere-1-
The Status fields returned from the
kubectl describecommand:- Action - Last action performed, that is provision, resume, delete
- Message - Last error message, blank if no error message.
- Service ID - Cloud Automation Manager service ID of the deployment.
- Status - Status of the last action performed.
- Conditions
- Last Transition Time - Last update time of the condition.
- Reason - The status of the Cloud Automation Manager action.
- Status - It is 'True' when the condition is valid.
- Type - The type of the condition - the Cloud Automation Manager action (For example, provision, resume, delete).
- Outputs
- Name - Name of the output parameter.
- Type - The type of the parameter, that is, string, list, map.
- Value - The value of the output parameter in json format.
-
The Event fields returned from the
kubectl describecommand are Type, Reason, Age, and From. Example:Type Reason Age From Message ---- ------ ---- ---- ------- Normal provision:Submitted 6m53s cam-controller-service provision status changed for default/service-test-vsphere-1 Normal provision:In Progress 6m34s cam-controller-service provision status changed for default/service-test-vsphere-1 Normal provision:Active 4m3s cam-controller-service provision status changed for default/service-test-vsphere-1
-
-
Optionally, you can also use Cloud Automation Manager Kubernetes controller startup parameters - controller parameter. They are defined in
cam-controller-statefulset.yamlfile. The args parameter are specified in the pod definition.The
-syncPeriodis a controller parameter for the time duration between resource status checks. Value units are 's', 'm', 'h'." (Default is 2m).For example:
- -syncPeriod=2h30m
- -syncPeriod=300s
- -syncPeriod=30m
Deleting a deployed Cloud Automation Manager service
If you no longer require the deployed instance of a service instance, run either of the following commands to delete it:
kubectl delete -f <yaml file name>
or
kubectl delete services.cloudautomationmgr.ibm.com service-test-vsphere-1 -n default
Note: The command deletes the Cloud Automation Manager instance. After the Cloud Automation Manager instance is successfully deleted, the kubernetes resource that represents the Cloud Automation Manager instance is also deleted.