Getting started with the Code Engine CLI
You can use the IBM Cloud® Code Engine API to create and manage your Code Engine entities.
Setting up your CLI environment
To work with the CLI to create and manage Code Engine entities, set up your CLI environment. Make sure you have the latest version of the IBM Cloud CLI installed.
Before you begin
You must create an IBM Cloud account.
-
Download and install the IBM Cloud CLI.
-
Log in to the IBM Cloud CLI.
-
Log in to the IBM Cloud CLI.
ibmcloud login
-
If you have more than one account, you are prompted to select which account to use. Follow the prompts or use the
target
command to select your IBM Cloud account.ibmcloud target -c <account_id>
-
Specify a region. Use the
target
command to target or change regions.ibmcloud target -r <region>
-
Specify a resource group. To get a list of your resource groups, run the following command.
ibmcloud resource groups
Example output
Retrieving all resource groups under account <account_name> as email@ibm.com... OK Name ID Default Group State default a8a12accd63b437bbd6d58fb8b462ca7 true ACTIVE test a8a12abbbd63b437cca6d58fb8b462ca7 false ACTIVE
-
Target a resource group by running the following command.
ibmcloud target -g <resource_group>
Example output
Targeted resource group default
-
-
Install the Code Engine CLI plug-in.
ibmcloud plugin install code-engine
-
Verify that the Code Engine CLI plug-in is installed. You can use the
ibmcloud plugin show code-engine
command or theibmcloud plugin list
command to confirm that the plug-in is installed.ibmcloud plugin show code-engine
Example output
Plugin Name code-engine[ce] Plugin Version 1.31.0 Plugin SDK Version 0.9.0 Minimal IBM Cloud CLI version required 1.0.0 Private endpoints supported true Commands: code-engine,ce Manage Code Engine components. [...]
-
Run the
ibmcloud ce help
command to view the commands for the Code Engine CLI. For example,ibmcloud ce help
Working with the Code Engine CLI
Now that your Code Engine CLI environment is set up, you are ready to work with Code Engine resources, such as applications, functions, or jobs with the CLI.
Before you can work with Code Engine resources, you must work within the context of a project.
A project is a grouping of Code Engine entities such as applications, jobs, and builds. A project is based on a Kubernetes namespace. The name of your project must be unique within your IBM Cloud® resource group, user account, and region. Projects are used to manage resources and provide access to its entities.
A project provides the following items.
- Provides a unique namespace for entity names.
- Manages access to project resources (inbound access).
- Manages access to backing services, registries, and repositories (outbound access).
- Has an automatically generated certificate for Transport Layer Service (TLS).
For more information about Code Engine projects, see Managing projects.
-
Create a project with the
project create
command. Use a project name that is unique to your region.ibmcloud ce project create --name PROJECT_NAME
Example output
Creating project 'myproject'... OK
-
View details about the project with the
project get
command.ibmcloud ce project get --name PROJECT_NAME
Example output
Getting project 'myproject'... OK Name: myproject ID: 01234567-abcd-abcd-abcd-abcdabcd1111 Status: active Selected: true Region: us-south Resource Group: default Service Binding Service ID: ServiceId-1234abcd-abcd-abcd-1111-1a2b3c4d5e6f Age: 52d Created: Fri, 15 Jan 2021 13:32:30 -0500 Updated: Fri, 15 Jan 2021 13:32:45 -0500 Quotas: Category Used Limit App revisions 1 100 Apps 1 100 Build runs 0 100 Builds 0 100 Configmaps 2 100 CPU 1.025 64 Ephemeral storage 902625Ki 256G Instances (active) 1 250 Instances (total) 2 2500 Job runs 1 100 Jobs 1 100 Memory 4400M 256G Secrets 5 100 Subscriptions (cron) 0 100 Subscriptions (IBM Cloud Object Storage) 0 100
Alternatively, you can use the project list
command to display a list of your created projects.
To work with a project with the CLI, the project must be selected as the current context. A project is automatically selected as the current context when it is created, unless you specify the --no-select
option. To select a project
that is not currently targeted, use the project select
command.
For more information about working with projects, see Managing projects.
Next steps
Now that you have setup your CLI environment, and have taken the first steps to ensure that you are working within the context of a Code Engine project, you can use the Code Engine CLI to work with apps, functions, and jobs.
To start working with Code Engine components with the CLI, see the following topics.
For more information about the Code Engine CLI, see the Setting up the CLI environment.
For more information about working in the Code Engine CLI environment, see Code Engine CLI Command Reference documentation.
For a summary of changes for each version of the CLI, see CLI version history. Be sure to keep your CLI up-to-date so that you can use all the available commands and their options.