Using the CLI Tool (camctl)
camctl is a command line interface for Managed services. It provides a subset of the functions found in the Managed services web interface.
Before you Begin
Install the CLI tool (camctl). For more information, see Installing the CLI tool.
About the task
This topic explains how to use the camctl commands to use the Managed services functions. In this release, managing cloud connections and templates is supported. Non-versioned services are also supported, however the server must be put into COMPATIBILITY_MODE by having a server administrator run the following command.
kubectl set env deployment/cam-service-composer-api COMPATIBILITY_MODE=true -n management-infrastructure-management
Use the --help option to get a list of supported camctl commands.
- Logging in to a server
- Creating a new cloud connection
- Import a template
- Deploy a template
- Managing an instance
Logging in to a server
Before using camctl the login session should be refreshed.
Usage: camctl login [OPTIONS]
> camctl login --auth_only --username USERNAME --authenticator PASSWORD
Authentication successfully set.
Creating a cloud connection
To create a new cloud connection:
- You can specify cloud specific options at the end of the command using the connection option key name followed by the value.
- To determine the cloud specific options use the command:
>camctl connections cloud connection-options PROVIDER_NAME
Usage: camctl connections providers list [OPTIONS]
> camctl connections providers list --names
Name ... IBM ...
Usage: camctl connections providers list [OPTIONS]
> camctl connections cloud connection-options IBM
Name | Type | Required | Description ibmcloud_api_key | password | True | The API key for IBM Cloud iaas_classic_username | string | True | IBM Cloud Classic Infrastructure User Name iaas_classic_api_key | password | True | The API key for IBM Cloud Classic Infrastructure
- For simple cloud connections where only passwords, strings and integers are required, this is a possible option.
- Any required options that are missing from the command line are prompted for values.
- For cloud connections that have a file upload option, like Google Cloud, enter the path to the file and the contents of the file is included.
- For more complex cloud connections use the fetch command to generate the necessary file and then create using the --input_file option.
Import a template
camctl supports importing templates from all the standard sources Bitbucket, GitHub, GitLab, a remote zip archive hosted on a website, or a local template file. Each source has its own options. Use the --help option to find the appropriate options of each source.
Usage: camctl template import [OPTIONS] COMMAND [ARGS]...
> camctl template import github URL --dir RELATIVE_DIR --token TOKEN
Getting info for namespace default and all globally accessible Template successfully imported as local_sleep_stress with id 5dee68c0aed18d001de5ce70
Deploy a template
To deploy a template the following information must be obtained:
- Template ID
- Template options
- An ID for the cloud connection to deploy on
- The Terraform template version to use
To find the template id, use the list command.
Usage: camctl template list [OPTIONS]
> camctl template list --template_name stress
Getting info for namespace default and all globally accessible Templates located in namespace: default Id | Namespace | Provider | Name 5dee68c0aed18d001de5ce70 | default | Other | local_sleep_stress
To find the variables for the template use the template_variables command. For templates with a lot of options it might be easier to save the options to a local file using the --output option.
Usage: camctl template template_variables [OPTIONS] TEMPLATE_ID
> camctl template template_variables 5dee68c0aed18d001de5ce70
4900 MainThread INFO Refreshing local_sleep_stress with no status. (Manifest.refresh.88)) name | type | required | immutable | immutable_after_create | default | validation sleeptime | string| True | False | False | 3 |
If there is only one cloud connection in the target namespace, no cloud connection is required. To find the cloud connection id, use the connections clouds list command. It is recommended that you filter on the provider name for the template.
A template can be deployed now with the help of all this acquired information. The last piece of information is a unique name given to a deployed instance.
To add the parameters, there are three options.
- Usage: camctl template deploy [OPTIONS] TEMPLATE_ID INSTANCE_NAME
The first is to add the variable at the end of the command with its value.
> camctl template deploy --terraform_version 0.11.11 5dee68c0aed18d001de5ce70 jm_example_1 sleeptime 3
The second option is to enter the parameters interactively.
> camctl template deploy 5dee68c0aed18d001de5ce70 jm_example_2
Getting info for namespace default and all globally accessible 4123 MainThread INFO Refreshing local_sleep_stress with no status. (Manifest.refresh.88)) > Enter the value for sleeptime variable : > Enter the Terraform version to use for deploy. (0.11.11, 0.12.13): 0.11.11 22674 MainThread INFO Refreshing jm_example_2 with status of in_progress. (CamWorkerStack.refresh.86)) ... 5dee818baed18d001de5ce72
The third option is to use the template_variables command to create a file. Update each variable with the desired value and then use the --input option to load that file.
For all three methods the output remains the same and it displays the following information:
- The status of the deployment
- The log file
- The id for the instance
Managing an instance
Use the instance id to run instance commands. For a list of commands related to instance, use camctl template instance --help
To see information about the instance use the info command.
Usage: camctl template instance [OPTIONS] INSTANCE_ID info [OPTIONS]
> camctl template instance 5dee818baed18d001de5ce72 info
To delete an instance the resources must first be destroyed and then the delete command can be run.
Usage: camctl template instance [OPTIONS] INSTANCE_ID destroy [OPTIONS]
> camctl template instance 5dee818baed18d001de5ce72 destroy
Destroy was successful.
Usage: camctl template instance [OPTIONS] INSTANCE_ID delete [OPTIONS]
> camctl template instance 5dee818baed18d001de5ce72 delete
4508 MainThread INFO Refreshing jm_example_2 with status of success. (CamWorkerStack.refresh.86)) Stack jm_example_2 successfully removed.