|
| 1 | +--- |
| 2 | + |
| 3 | +copyright: |
| 4 | + years: 2020, 2021 |
| 5 | +lastupdated: "2021-07-20" |
| 6 | + |
| 7 | +keywords: applications in code engine, apps in code engine, http requests in code engine, deploy apps in code engine, app workloads in code engine, deploying workloads in code engine, application, app, memory, cpu, environment variables |
| 8 | + |
| 9 | +subcollection: codeengine |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +{:DomainName: data-hd-keyref="APPDomain"} |
| 14 | +{:DomainName: data-hd-keyref="DomainName"} |
| 15 | +{:android: data-hd-operatingsystem="android"} |
| 16 | +{:api: .ph data-hd-interface='api'} |
| 17 | +{:apikey: data-credential-placeholder='apikey'} |
| 18 | +{:app_key: data-hd-keyref="app_key"} |
| 19 | +{:app_name: data-hd-keyref="app_name"} |
| 20 | +{:app_secret: data-hd-keyref="app_secret"} |
| 21 | +{:app_url: data-hd-keyref="app_url"} |
| 22 | +{:authenticated-content: .authenticated-content} |
| 23 | +{:beta: .beta} |
| 24 | +{:c#: data-hd-programlang="c#"} |
| 25 | +{:cli: .ph data-hd-interface='cli'} |
| 26 | +{:codeblock: .codeblock} |
| 27 | +{:curl: .ph data-hd-programlang='curl'} |
| 28 | +{:deprecated: .deprecated} |
| 29 | +{:dotnet-standard: .ph data-hd-programlang='dotnet-standard'} |
| 30 | +{:download: .download} |
| 31 | +{:external: target="_blank" .external} |
| 32 | +{:faq: data-hd-content-type='faq'} |
| 33 | +{:fuzzybunny: .ph data-hd-programlang='fuzzybunny'} |
| 34 | +{:generic: data-hd-operatingsystem="generic"} |
| 35 | +{:generic: data-hd-programlang="generic"} |
| 36 | +{:gif: data-image-type='gif'} |
| 37 | +{:go: .ph data-hd-programlang='go'} |
| 38 | +{:help: data-hd-content-type='help'} |
| 39 | +{:hide-dashboard: .hide-dashboard} |
| 40 | +{:hide-in-docs: .hide-in-docs} |
| 41 | +{:important: .important} |
| 42 | +{:ios: data-hd-operatingsystem="ios"} |
| 43 | +{:java: .ph data-hd-programlang='java'} |
| 44 | +{:java: data-hd-programlang="java"} |
| 45 | +{:javascript: .ph data-hd-programlang='javascript'} |
| 46 | +{:javascript: data-hd-programlang="javascript"} |
| 47 | +{:new_window: target="_blank"} |
| 48 | +{:note .note} |
| 49 | +{:note: .note} |
| 50 | +{:objectc data-hd-programlang="objectc"} |
| 51 | +{:org_name: data-hd-keyref="org_name"} |
| 52 | +{:php: data-hd-programlang="php"} |
| 53 | +{:pre: .pre} |
| 54 | +{:preview: .preview} |
| 55 | +{:python: .ph data-hd-programlang='python'} |
| 56 | +{:python: data-hd-programlang="python"} |
| 57 | +{:route: data-hd-keyref="route"} |
| 58 | +{:row-headers: .row-headers} |
| 59 | +{:ruby: .ph data-hd-programlang='ruby'} |
| 60 | +{:ruby: data-hd-programlang="ruby"} |
| 61 | +{:runtime: architecture="runtime"} |
| 62 | +{:runtimeIcon: .runtimeIcon} |
| 63 | +{:runtimeIconList: .runtimeIconList} |
| 64 | +{:runtimeLink: .runtimeLink} |
| 65 | +{:runtimeTitle: .runtimeTitle} |
| 66 | +{:screen: .screen} |
| 67 | +{:script: data-hd-video='script'} |
| 68 | +{:service: architecture="service"} |
| 69 | +{:service_instance_name: data-hd-keyref="service_instance_name"} |
| 70 | +{:service_name: data-hd-keyref="service_name"} |
| 71 | +{:shortdesc: .shortdesc} |
| 72 | +{:space_name: data-hd-keyref="space_name"} |
| 73 | +{:step: data-tutorial-type='step'} |
| 74 | +{:subsection: outputclass="subsection"} |
| 75 | +{:support: data-reuse='support'} |
| 76 | +{:swift: .ph data-hd-programlang='swift'} |
| 77 | +{:swift: data-hd-programlang="swift"} |
| 78 | +{:table: .aria-labeledby="caption"} |
| 79 | +{:term: .term} |
| 80 | +{:terraform: .ph data-hd-interface='terraform'} |
| 81 | +{:tip: .tip} |
| 82 | +{:tooling-url: data-tooling-url-placeholder='tooling-url'} |
| 83 | +{:troubleshoot: data-hd-content-type='troubleshoot'} |
| 84 | +{:tsCauses: .tsCauses} |
| 85 | +{:tsResolve: .tsResolve} |
| 86 | +{:tsSymptoms: .tsSymptoms} |
| 87 | +{:tutorial: data-hd-content-type='tutorial'} |
| 88 | +{:ui: .ph data-hd-interface='ui'} |
| 89 | +{:unity: .ph data-hd-programlang='unity'} |
| 90 | +{:url: data-credential-placeholder='url'} |
| 91 | +{:user_ID: data-hd-keyref="user_ID"} |
| 92 | +{:vbnet: .ph data-hd-programlang='vb.net'} |
| 93 | +{:video: .video} |
| 94 | + |
| 95 | + |
| 96 | +# Deploy application workloads from images in {{site.data.keyword.registryshort}} |
| 97 | +{: #deploy-app-crimage} |
| 98 | + |
| 99 | +Deploy your app with {{site.data.keyword.codeengineshort}} that uses an image in {{site.data.keyword.registryshort}}. You can create an app from the console or with the CLI. |
| 100 | +{: shortdesc} |
| 101 | + |
| 102 | +**Before you begin** |
| 103 | + |
| 104 | +- You must have an image in {{site.data.keyword.registryshort}}. For more information, see [Getting started with {{site.data.keyword.registryshort}}](/docs/Registry?topic=Registry-getting-started#getting-started). Or, you can [build one from source](#deploy-app-source-code). |
| 105 | + |
| 106 | +## Deploying an app that references an image in {{site.data.keyword.registryshort}} with the console |
| 107 | +{: #deploy-app-crimage-console} |
| 108 | + |
| 109 | +Deploy an application that uses an image in a container registry by using the {{site.data.keyword.codeengineshort}} console. |
| 110 | +{: shortdesc} |
| 111 | + |
| 112 | +{{site.data.keyword.codeengineshort}} can automatically pull images from a {{site.data.keyword.registryshort}} namespace in your account. To pull images from a different {{site.data.keyword.registryshort}} account or from a private DockerHub account, see [Deploy application workloads from images in a private registry](#deploy-app-private-console). |
| 113 | + |
| 114 | +1. Open the [{{site.data.keyword.codeengineshort}}](https://cloud.ibm.com/codeengine/overview){: external} console. |
| 115 | +2. Select **Start creating** from **Run a container image**. |
| 116 | +3. Select **Application**. |
| 117 | +4. Enter a name for the application; for example, `helloapp`. Use a name for your application that is unique within the project. |
| 118 | +5. Select a project from the list of available projects. You can also [create a new one](/docs/codeengine?topic=codeengine-manage-project#create-a-project). You must have a selected project to deploy an app. |
| 119 | +6. Select **Container image** and click **Configure image**. |
| 120 | +7. Select a container registry location, such as `IBM Registry, Dallas`. |
| 121 | +8. Select `Automatic` for **Registry access**. |
| 122 | +9. Select the namespace and name of the image in the registry for the {{site.data.keyword.codeengineshort}} app to reference. For example, select `mynamespace` and select the image `hello_repo` in that namespace. |
| 123 | +10. Select a value for **Tag**; for example, `latest`. |
| 124 | +11. Click **Done**. |
| 125 | +12. Modify any runtime settings or environment variables for your app. For more information about these options, see [Options for deploying an app](#deploy-app-options). |
| 126 | +13. From the Create application page, click **Create**. |
| 127 | +14. After the application status changes to **Ready**, you can test the application by clicking **Send request**. To open the application in a web page, click **Open application URL**. |
| 128 | + |
| 129 | +If you want to add registry access to a {{site.data.keyword.registryshort}} instance that is not in your account, see [Adding access to a {{site.data.keyword.registryshort}}](/docs/codeengine?topic=codeengine-add-registry). |
| 130 | + |
| 131 | +Looking for more code examples? Check out the [Samples for {{site.data.keyword.codeenginefull_notm}} GitHub repo](https://github.com/IBM/CodeEngine){: external}. |
| 132 | +{: tip} |
| 133 | + |
| 134 | +## Deploying an app with an image in {{site.data.keyword.registryshort}} with the CLI |
| 135 | +{: #deploy-app-crimage-cli} |
| 136 | + |
| 137 | +Deploy an application that uses an image in a container registry with the CLI with the **`ibmcloud ce app create`** command. |
| 138 | +{: shortdesc} |
| 139 | + |
| 140 | +Before you can work with a {{site.data.keyword.codeengineshort}} application that references an image in {{site.data.keyword.registryshort}}, you must first add access to the registry, pull the image, and then deploy it. |
| 141 | + |
| 142 | +1. To add access to {{site.data.keyword.registryshort_notm}}, [create an IAM API key](/docs/codeengine?topic=codeengine-add-registry#images-your-account-api-key). To create an {{site.data.keyword.cloud_notm}} IAM API key with the CLI, run the [**`iam api-key-create`**](/docs/account?topic=cli-ibmcloud_commands_iam#ibmcloud_iam_api_key_create) command. For example, to create an API key called `cliapikey` with a description of "My CLI APIkey" and save it to a file called `key_file`, run the following command: |
| 143 | + |
| 144 | + ``` |
| 145 | + ibmcloud iam api-key-create cliapikey -d "My CLI APIkey" --file key_file |
| 146 | + ``` |
| 147 | + {: pre} |
| 148 | + |
| 149 | + If you choose to not save your key to a file, you must record the apikey that is displayed when you create it. You cannot retrieve it later. |
| 150 | + {: important} |
| 151 | + |
| 152 | +2. After you create your API key, add registry access to {{site.data.keyword.codeengineshort}}. To add access to {{site.data.keyword.registryshort}} with the CLI, use the [**`ibmcloud ce registry create`**](/docs/codeengine?topic=codeengine-cli#cli-registry-create) command to create an image registry access secret. For example, the following **`registry create`** command creates registry access to a {{site.data.keyword.registryshort}} instance called `myregistry`. Note, even though the `--server` and `--username` options are specified in the example command, the default value for the `--server` option is `us.icr.io` and the `--username` option defaults to `iamapikey` when the server is `us.icr.io`. |
| 153 | + |
| 154 | + ``` |
| 155 | + ibmcloud ce registry create --name myregistry --server us.icr.io --username iamapikey --password APIKEY |
| 156 | + ``` |
| 157 | + {: pre} |
| 158 | + |
| 159 | + **Example output** |
| 160 | + |
| 161 | + ``` |
| 162 | + Creating image registry access secret 'myregistry'... |
| 163 | + OK |
| 164 | + ``` |
| 165 | + {: screen} |
| 166 | + |
| 167 | +3. Create your app and reference the `hello_repo` image in {{site.data.keyword.registryshort}}. For example, use the [**`ibmcloud ce app create`**](/docs/codeengine?topic=codeengine-cli#cli-application-create) command to create the `myhelloapp` app to reference the `us.icr.io/mynamespace/hello_repo` by using the `myregistry` access information. |
| 168 | + |
| 169 | + ``` |
| 170 | + ibmcloud ce app create --name myhelloapp --image us.icr.io/mynamespace/hello_repo --registry-secret myregistry |
| 171 | + ``` |
| 172 | + {: pre} |
| 173 | + |
| 174 | + The format of the name of the image for this application is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and `TAG` are optional. If `REGISTRY` is not specified, the default is `docker.io`. If `TAG` is not specified, the default is `latest`. |
| 175 | + {: important} |
| 176 | + |
| 177 | +4. After your app deploys, you can access the app. To obtain the URL of your app, run `ibmcloud ce app get --name myhelloapp --output url`. When you curl the `myhelloapp` app, `Hello World` is returned. |
| 178 | + |
| 179 | + ``` |
| 180 | + curl https://myhelloapp.abcdabcdhye.us-south.codeengine.appdomain.cloud |
| 181 | + ``` |
| 182 | + {: pre} |
| 183 | + |
| 184 | +Looking for more code examples? Check out the [Samples for {{site.data.keyword.codeenginefull_notm}} GitHub repo](https://github.com/IBM/CodeEngine){: external}. |
| 185 | +{: tip} |
0 commit comments