copyright | lastupdated | keywords | subcollection | ||
---|---|---|---|---|---|
|
2024-03-22 |
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 |
codeengine |
{{site.data.keyword.attribute-definition-list}}
{: #update-app}
An application contains one or more revisions. A revision represents an immutable version of the configuration properties of the application. Each update of an application configuration property creates a new revision of the application. {: shortdesc}
When you modify an application and deploy the application with the changes, or redeploy the application without changes to its configuration settings, these actions deploy a new revision of the application. When you deploy (or redeploy) an application revision, {{site.data.keyword.codeengineshort}} uses any changed configuration settings, and gets any updated container image, secret, or configmap that is referenced by the application.
For more information about deploying applications, such as specifying valid vCPU and memory combinations, defining commands and arguments, environment variables, secrets, or configmaps, see Options for deploying an app.
{{site.data.keyword.codeengineshort}} has a quota for the number of apps and app revisions in a project. For more information about limits for projects, see Project quotas. {{site.data.keyword.codeengineshort}} retains only the latest inactive revision of your application in addition to your active app revision. Older revisions are deleted. {: important}
You can update your deployed app and its referenced code by using any of the following ways, independent of how you created or previously updated your app:
-
If you have a container image, per the Open Container Initiative (OCI) standard{: external}, then you need to provide only a reference to the image, which points to the location of your container registry when you deploy your app. You can deploy your app with an image in a public registry or private registry.
If you created your app by using the
app create
command and you specified the--build-source
option to build the container image from local or repository source, and you want to change your app to point to a different container image, you must first remove the association of the build from your app. For example, runibmcloud ce application update -n APP_NAME --build-clear
. After you remove the association of the build from your app, you can update the app to reference a different image. {: important} -
If you are starting with source code that resides in a Git repository, you can choose to let {{site.data.keyword.codeengineshort}} take care of building the image from your source and deploying the app with a single operation. In this scenario, {{site.data.keyword.codeengineshort}} uploads your image to {{site.data.keyword.registrylong}}. To learn more, see Deploying your app from repository source code. If you want more control over the build of your image, then you can choose to build the image with {{site.data.keyword.codeengineshort}} before you deploy your app.
-
If you are starting with source code that resides on a local workstation, you can choose to let {{site.data.keyword.codeengineshort}} take care of building the image from your source and deploying the app with a single CLI command. In this scenario, {{site.data.keyword.codeengineshort}} uploads your image to {{site.data.keyword.registrylong}}. To learn more, see Deploying your app from local source code with the CLI. If you want more control over the build of your image, then you can choose to build the image with {{site.data.keyword.codeengineshort}} before you deploy your app.
For example, you might choose to let {{site.data.keyword.codeengineshort}} handle the build of your local source while you evolve the development of your source for the app. Then, after the image is matured, you can update the deployed app to reference the specific image that you want. You can repeat this process as needed.
When you deploy your updated app, the latest version of your referenced container image is downloaded and deployed, unless a tag is specified for the image. If a tag is specified for the image, then the tagged image is used for the deployment.
{: #update-app-nochange}
You can always deploy your application with configuration changes by changing a configuration value and deploying the application.
However, you might want to redeploy an application revision without changing your application configuration settings. Perhaps your referenced container image is changed, and you want your application revision to use the updated container image. Or, perhaps you want your application to reference a secret or configmap, which contains updated content values.
For these scenarios, from the console, you can click Redeploy from the Configuration tab of your application page, without changing your app configuration. With the CLI, use the ibmcloud ce app update
command.
{: #update-app-console}
Update the application that you created in Deploying an application from a public registry from the console to add an environment variable.
- Navigate to your application page. One way to navigate to your application page is to
- Locate the {{site.data.keyword.codeengineshort}} Projects page{: external}.
- Click the name of your project to open the Overview page.
- Click Applications to open a list of your applications. Click the name of your application to open its application page.
- From the application page, you can view information about the running instances of your application and its revisions, configuration details, and endpoint settings of the app. Click the name of the application revision that you want to work with to open the configuration summary for that revision. Or, you can click the Configuration tab to open the configuration summary for the latest application revision.
- From the Configuration tab, click the Environment variables tab.
- Click Add environment variable. Define this environment variable as a literal value. Enter
TARGET
for name andStranger
for value. Click Add. - Click Deploy to save your change and deploy the application revision.
- After the application status changes to Ready, you can test the application revision. Click Test application and then click Send request in the Test application pane. To open the application in a web page, click Application URL. For this app,
Hello Stranger
is displayed.
In this example, you updated environment variables for an app. You can also update other configuration settings for your app, including referencing a different image or different image build from the Code tab. From the Resources & scaling tab, you can update memory and application scaling settings for your app. From the Environment variables tab, you can add or update environment variables for your app. From the Image start options tab, you can add or update command and arguments to override settings within your container image, or work with liveness and readiness probes.
{: #update-app-console-projendpt}
By default, when you deploy an app, the app deploys such that it can receive requests from the public internet, from a private network, or from components within the project. Let's change the visibility of this app such that it is accessed only by other {{site.data.keyword.codeengineshort}} resources that are running in the same {{site.data.keyword.codeengineshort}} environment. Use the Domain mappings tab to change the visibility of an app.
-
Navigate to your application page. One way to navigate to your application page is to
- Locate the {{site.data.keyword.codeengineshort}} Projects page{: external}.
- Click the name of your project to open the Overview page.
- Click Applications to open a list of your applications. Click the name of your application to open its application page.
-
From the application page, you can view information about the running instances of your application and its revisions, configuration details, and endpoint settings of the app. Click the Domain mappings tab to open the endpoint visibility settings for the application.
-
From the Domain mappings tab, notice the available URLs for your application. When
Public
is selected, you can view the public and the internal system domain mapping URL for the application. When No external system domain mapping is selected, this application is no longer accessible from the public internet and network access is only possible from components within this project.When you change the visibility of your app, the change is effective immediately. It is important to consider the impact of the change for your active users or integrations as well as any security implications. You can change the visibility setting as needed. {: important}
{: #update-app-console-privateendpt}
By default, when you deploy an app, the app deploys such that it can receive requests from the public internet, from a private network, or from components within the project. Let's change the visibility of this app such that it is accessed only by other {{site.data.keyword.codeengineshort}} resources that are running in the same project and from the private network by using Virtual Private Endpoints. Use the Domain mappings tab to change the visibility of an app.
-
Navigate to your application page. One way to navigate to your application page is to
- Locate the {{site.data.keyword.codeengineshort}} Projects page{: external}.
- Click the name of your project to open the Overview page.
- Click Applications to open a list of your applications. Click the name of your application to open its application page.
-
From the application page, you can view information about the running instances of your application and its revisions, configuration details, and endpoint settings of the app. Click the Domain mappings tab to open the endpoint visibility settings for the application.
-
From the Domain mappings tab, notice the available URLs for your application. When
Private
is selected, this application is no longer accessible from the public internet and network access is only possible from components within this project (cluster-local) and from the private network.Click Private to change the endpoint visibility of the app. The available URLs for your endpoint definition are displayed for the private and project-only URLs.
-
To access your app securely by using a Virtual Private Endpoint (VPE), follow the instructions for Using your VPE to access an app to set up the VPE to access your app.
If you set your application for visibility = private
, then you can only test your application through the virtual private endpoint from within your Virtual Private Cloud (VPC).
By changing the visibility of your app, the change is effective immediately. It is important to consider the impact of the change for your active users or integrations as well as any security implications. You can change the visibility setting as needed. {: important}
{: #update-app-cli}
To update your app with the CLI, use the app update
command. This command requires the name of the app that you want to update and also allows other optional arguments. For a complete listing of options, see the ibmcloud ce app update
command.
{: shortdesc}
Update the application that you created in Deploying an application with the CLI to add an environment variable.
The sample icr.io/codeengine/hello
image reads the environment variable TARGET
, and prints Hello ${TARGET}
. If this environment variable is empty, Hello World
is returned. The following example updates the app to modify the value of the TARGET
environment variable to Stranger
. For more information about the code that is used for this example, see hello
{: external}.
-
Run the
application update
command. For example,ibmcloud ce application update -n myapp --env TARGET=Stranger
{: pre}
Example output
Updating application 'myapp' to latest revision. [...] Run 'ibmcloud ce application get -n myapp' to check the application status. OK https://myapp.4svg40kna19.us-south.codeengine.appdomain.cloud
{: screen}
-
Run the
application get
command to display the status of your app, including the latest revision information.ibmcloud ce application get --name myapp
{: pre}
Example output
[...] Name: myapp [...] URL: https://myapp.4svg40kna19.us-south.codeengine.appdomain.cloud Cluster Local URL: http://myapp.4svg40kna19.svc.cluster.local Console URL: https://cloud.ibm.com/codeengine/project/us-south/01234567-abcd-abcd-abcd-abcdabcd1111/application/myapp/configuration Environment Variables: Type Name Value Literal TARGET Stranger Image: icr.io/codeengine/hello Resource Allocation: CPU: 1 Ephemeral Storage: 400M Memory: 4G Revisions: myapp-hc3u8-2: Age: 82s Traffic: 100% Image: icr.io/codeengine/hello (pinned to f0dc03) Running Instances: 1 Runtime: Concurrency: 100 Maximum Scale: 10 Minimum Scale: 0 Timeout: 300 Conditions: Type OK Age Reason ConfigurationsReady true 75s Ready true 62s RoutesReady true 62s Events: Type Reason Age Source Messages Normal Created 2m11s service-controller Created Configuration "myapp" Normal Created 2m11s service-controller Created Route "myapp" Instances: Name Revision Running Status Restarts Age myapp-hc3u8-1-deployment-65cf8cd4f5-jx8b8 myapp-hc3u8-1 1/2 Terminating 0 2m10s myapp-hc3u8-2-deployment-7f98b679d5-2hskr myapp-hc3u8-2 2/2 Terminating 0 85s
{: screen}
From the output in the Revisions section, you can see the latest application revision of the
myapp
service. Also, notice that 100% of the traffic to the application is running the latest revision of the app. -
Call the application.
curl https://myapp.4svg40kna19.us-south.codeengine.appdomain.cloud
{: pre}
Example output
Hello Stranger
{: screen}
From the output of this command, you can see the updated app now returns
Hello Stranger
. -
Use the
ibmcloud ce revision list
command to display all your app revisions. Use this information to help you manage your app revisions as {{site.data.keyword.codeengineshort}} has a quota for the number of app revisions in a project.In the following
revision list
output, notice that {{site.data.keyword.codeengineshort}} retains only the latest inactive revision of your application in addition to your active app revision. Older revisions are deleted.ibmcloud ce revision list
{: pre}
Example output
Listing all application revisions... OK Name Application Status URL Latest Tag Traffic Age Conditions Reason myapp-hc3u8-4 myapp Ready 2d15h 3 OK / 4 myapp-hc3u8-5 myapp Ready true 100% 2d8h 3 OK / 4 myapp2-vjfqt-1 myapp2 Ready true 100% 3d 3 OK / 4 myhelloapp-tv368-3 myhelloapp Ready 16d 3 OK / 4 myhelloapp-tv368-4 myhelloapp Ready true 100% 16d 3 OK / 4 newapp-mytest-00008 newapp-mytest Ready 4d17h 3 OK / 4 newapp-mytest-00009 newapp-mytest Ready true 100% 2d20h 3 OK / 4
{: screen}
You can manage your app revisions by using the ibmcloud ce revision get
command to display details of an app revision and the ibmcloud ce revision delete
command to remove revisions that you don't want to keep. You can also use the ibmcloud ce revision logs
command to view logs of application revision instances. Use the ibmcloud ce revision events
command to display system events of application revision instances.
{: #update-app-cli-projectonly}
By default, when you deploy an app, the app deploys such that it can receive requests from the public internet, from a private network, or from components within the project. To change the visibility of your app such that it is accessed only by other {{site.data.keyword.codeengineshort}} resources that are running in the same project, use the --visibility=project
option with the ibmcloud ce app update
or ibmcloud ce app create
command.{: shortdesc}
In this scenario, update the application that you created in Deploying an application with the CLI to change the visibility of the app to use a project endpoint.
-
Run the
application update
command. For example,ibmcloud ce application update -n myapp --visibility=project
{: pre}
Example output
Updating application 'myapp' to latest revision. [...] Run 'ibmcloud ce application get -n myapp' to check the application status. OK http://myapp.4svg40kna19.svc.cluster.local
{: screen}
-
Run the
application get
command to display the status of your app, including the latest revision information.ibmcloud ce application get --name myapp
{: pre}
Example output
[...] Name: myapp [...] URL: http://myapp.4svg40kna19.svc.cluster.local Cluster Local URL: http://myapp.4svg40kna19.svc.cluster.local Console URL: https://cloud.ibm.com/codeengine/project/us-south/01234567-abcd-abcd-abcd-abcdabcd1111/application/myapp/configuration Environment Variables: Type Name Value Literal TARGET Stranger Image: icr.io/codeengine/hello Resource Allocation: CPU: 1 Ephemeral Storage: 400M Memory: 4G Revisions: myapp-hc3u8-2: Age: 82s Traffic: 100% Image: icr.io/codeengine/hello (pinned to f0dc03) Running Instances: 1 Runtime: Concurrency: 100 Maximum Scale: 10 Minimum Scale: 0 Timeout: 300 Conditions: Type OK Age Reason ConfigurationsReady true 75s Ready true 62s RoutesReady true 62s Events: Type Reason Age Source Messages Normal Created 2m11s service-controller Created Configuration "myapp" Normal Created 2m11s service-controller Created Route "myapp" Instances: Name Revision Running Status Restarts Age myapp-hc3u8-1-deployment-65cf8cd4f5-jx8b8 myapp-hc3u8-1 1/2 Terminating 0 2m10s myapp-hc3u8-2-deployment-7f98b679d5-2hskr myapp-hc3u8-2 2/2 Terminating 0 85s
{: screen}
From the output in the Revisions section, you can see the latest application revision of the
myapp
service. Also, notice that 100% of the traffic to the application is running the latest revision of the app.
Now that you set --visibility=project
on your application, this application is no longer accessible from the public internet and network access is only possible from components within this project (cluster-local).
{: #update-app-cli-privateendpt}
By default, when you deploy an app, the app deploys such that it can receive requests from the public internet, from a private network, or from components within the project. You can set the endpoint visibility for your app such that it is deployed with a private endpoint. Setting a private endpoint means that your app is not accessible from the public internet and network access is only possible from other {{site.data.keyword.cloud_notm}} services from virtual private endpoints (VPC) or {{site.data.keyword.codeengineshort}} components that are running in the same project (cluster-local). {: shortdesc}
To change the visibility of your app such that it is accessed only with a private endpoint, use the --visibility=private
option with the ibmcloud ce app update
or ibmcloud ce app create
command.{: shortdesc}
You can only use your VPE to access your app with a private endpoint if your selected project supports application private visibility. To confirm if the project supports application private visibility, use the ibmcloud ce project get
command to verify the output for Application Private Visibility Supported
is set to true
.
{: important}
In this scenario, update the application that you created in Deploying an application with the CLI to change the visibility of the app to use a private endpoint.
-
Confirm that the existing project supports applications with private visibility. Use the
ibmcloud ce project get
command to verify the output forApplication Private Visibility Supported
is set totrue
. If the value isfalse
, contact IBM support to enable this capability within your existing project.ibmcloud ce project get -n myproject
{: pre}
Example output
Getting project 'myproject'... OK Name: myproject ID: abcdabcd-abcd-abcd-abcd-f1de4aab5d5d Status: active Enabled: true Application Private Visibility Supported: true Selected: true Region: us-south Resource Group: default Service Binding Service ID: ServiceId-1234abcd-abcd-abcd-1111-1a2b3c4d5e6f Age: 52d Created: Tue, 28 Sep 2021 05:12:16 -0500 Updated: Tue, 28 Sep 2021 05:12:19 -0500 Quotas: Category Used Limit App revisions 1 60 Apps 1 20 Build runs 1 100 Builds 2 100 Configmaps 2 100 CPU 0 64 Ephemeral storage 0 256G Instances (active) 0 250 Instances (total) 0 2500 Job runs 0 100 Jobs 0 100 Memory 0 256G Secrets 6 100 Subscriptions (cron) 0 100 Subscriptions (IBM Cloud Object Storage) 0 100 Subscriptions (Kafka) 0 100
{: screen}
-
If
Application Private Visibility Supported
istrue
, then you can update your app to use private endpoints. Run theapplication update
command. For example,ibmcloud ce application update -n myapp --visibility=private
{: pre}
Example output
Updating application 'myapp' to latest revision. [...] Run 'ibmcloud ce application get -n myapp' to check the application status. OK https://myapp.4svg40kna19.private.us-south.codeengine.appdomain.cloud
{: screen}
-
Run the
application get
command to display the status of your app, including the latest revision information.ibmcloud ce application get --name myapp
{: pre}
Example output
[...] Name: myapp [...] URL: https://myapp.4svg40kna19.private.us-south.codeengine.appdomain.cloud Cluster Local URL: http://myapp.4svg40kna19.svc.cluster.local Console URL: https://cloud.ibm.com/codeengine/project/us-south/01234567-abcd-abcd-abcd-abcdabcd1111/application/myapp/configuration Environment Variables: Type Name Value Literal TARGET Stranger Image: icr.io/codeengine/hello Resource Allocation: CPU: 1 Ephemeral Storage: 400M Memory: 4G Revisions: myapp-hc3u8-2: Age: 82s Traffic: 100% Image: icr.io/codeengine/hello (pinned to f0dc03) Running Instances: 1 Runtime: Concurrency: 100 Maximum Scale: 10 Minimum Scale: 0 Timeout: 300 Conditions: Type OK Age Reason ConfigurationsReady true 75s Ready true 62s RoutesReady true 62s Events: Type Reason Age Source Messages Normal Created 2m11s service-controller Created Configuration "myapp" Normal Created 2m11s service-controller Created Route "myapp" Instances: Name Revision Running Status Restarts Age myapp-hc3u8-1-deployment-65cf8cd4f5-jx8b8 myapp-hc3u8-1 1/2 Terminating 0 2m10s myapp-hc3u8-2-deployment-7f98b679d5-2hskr myapp-hc3u8-2 2/2 Terminating 0 85s
{: screen}
From the output in the Revisions section, you can see the latest application revision of the
myapp
service. Also, notice that 100% of the traffic to the application is running the latest revision of the app. -
Set up your VPE to access your app with a private endpoint.
{: #update-app-diff-image}
You can update your app to reference a different image.
The image that is associated with your specific application revision has a unique container registry digest, and {{site.data.keyword.codeengineshort}} uses this digest for the life of your application revision. If you create a newer version of an image with the same tag as the original image, the original image is overwritten in the container registry and becomes untagged. The newer image is tagged, and this newer image has a different digest. Your {{site.data.keyword.codeengineshort}} application does not use this newer image, because the newer image has a different digest than the image that is referenced by the application revision. {{site.data.keyword.codeengineshort}} can still create new instances of the application revision as long as the untagged image, which was referenced originally, still exists. For more information, see Why can't {{site.data.keyword.codeengineshort}} pull an image? {: important}
Updating an app to reference a different image in {{site.data.keyword.registryshort}} from the console
{: #update-app-crimage-console}
Update an application to reference a different image in a container registry by using the {{site.data.keyword.codeengineshort}} console. {: shortdesc}
For this example, let's update the helloapp
that you created in Deploying an application that references an image in a container registry from the console to reference a different image. The updated app references the helloworld_repo
image in the mynamespace2
namespace in {{site.data.keyword.registryshort_notm}}. The following steps describe adding access to a registry during the update of an app.
For more information about adding an image to {{site.data.keyword.registryshort_notm}}, see Getting started with {{site.data.keyword.registrylong_notm}}.
-
Navigate to your application page. One way to navigate to your application page is to
- Locate the {{site.data.keyword.codeengineshort}} Projects page{: external}.
- Click the name of your project to open the Overview page.
- Click Applications to open a list of your applications. Click the name of your application to open the application page.
-
Click the Configuration tab to open the configuration details for the latest application revision.
-
From the Configuration tab, click the Code tab.
-
For Image to run, click Configure image to open the configure image dialog. For this example, update the app to reference an existing
ibmcregistry
registry, select themynamespace2
namespace, select thehelloworld-repo
image, and select1
as the value fortag
. From the configure image page,- If the image you want to use resides in the same {{site.data.keyword.registryshort_notm}} account, select the access for the registry.
- If the image that you want to use resides in a different container registry account, you can select the registry access for this registry. If the registry access does not exist, you must first create your IAM API key and then Add registry access to {{site.data.keyword.codeengineshort}}.
If you want to update only the registry access to your image, you can make this change without clicking Configure image to open the configure image dialog and use the Registry access menu to select an existing registry access or create a registry access to {{site.data.keyword.codeengineshort}} for the image that is referenced by your application.
{: note} -
Click Done. You selected your image in the registry to reference from your app.
-
Click Deploy to save your change and deploy the app revision.
-
After the application status changes to Ready, you can test the app revision. Click Test application and then click Send request in the Test application pane. To open the application in a web page, click Application URL. For this app,
Hello World from {{site.data.keyword.codeengineshort}}
is displayed.
{: #update-app-crimage-cli}
Update an application to reference a different image in {{site.data.keyword.registryshort}} from the {{site.data.keyword.codeengineshort}} CLI. {: shortdesc}
For this example, update the myhelloapp
that you created in Deploying an application that references an image in a container registry with the CLI to reference a different image in a different namespace in the same account. Update the app to reference the helloworld_repo
image in the mynamespace2
namespace in {{site.data.keyword.registryshort_notm}}.
-
Add a different image to {{site.data.keyword.registryshort_notm}}. For this example, add the
helloworld_repo
image in themynamespace2
namespace in {{site.data.keyword.registryshort_notm}}. For more information about adding an image to {{site.data.keyword.registryshort_notm}}, see Getting started with {{site.data.keyword.registrylong_notm}}. -
Add registry access to {{site.data.keyword.codeengineshort}}. For this example, because the
helloworld_repo
image resides in the same account, use the previously definedmyregistry
registry access. -
Update your app and reference the image in {{site.data.keyword.registryshort}} by using the
myregistry
access. For example, update themyhelloapp
app to reference theus.icr.io/mynamespace2/helloworld_repo
by using themyregistry
access information.ibmcloud ce app update --name myhelloapp --image us.icr.io/mynamespace2/helloworld_repo:1 --registry-secret myregistry
{: pre}
The format of the name of the image for this application is
REGISTRY/NAMESPACE/REPOSITORY:TAG
whereREGISTRY
andTAG
are optional. IfREGISTRY
is not specified, the default isdocker.io
. IfTAG
is not specified, the default islatest
. {: important} -
After your app is updated, you can access the app. To obtain the URL of your app, run
ibmcloud ce app get --name myhelloapp --output url
. When you curl themyhelloapp
app, the app returnsHello World from {{site.data.keyword.codeengineshort}}
, which demonstrates the app is now using thehelloworld_repo
image.
{: #update-app-source-console}
Update an application to reference an image that is built from source code by using the {{site.data.keyword.codeengineshort}} console. {: shortdesc}
For this example, let's update the helloapp
that you created in Deploying an application that references an image in a container registry from the console to reference an image that is built from your source code.
For more information about creating a build configuration from the console, see create a build.
- Navigate to your application page. One way to navigate to your application page is to
- Locate the {{site.data.keyword.codeengineshort}} Projects page{: external}.
- Click the name of your project to open the Overview page.
- Click Applications to open a list of your applications. Click the name of your application to open the application page.
- Click the Configuration tab to open the configuration details for the latest application revision.
- From the Configuration tab, click the Code tab.
- From the Code tab, you can create an image build, or you can rerun an existing image build that is referenced by your application. To create an image build, click Create image from source to run an image build. The Specify build details page opens where you can enter the details of your build to deploy your app from source code. Click Done when build detail updates are specified.
- Click Deploy to save your changes, run the build, and deploy the app revision.
- After the application status changes to Ready, you can test the app revision. Click Test application and then click Send request in the Test application pane. To open the application in a web page, click Application URL.
- To update this application again to reference an updated build image, click Rerun build from the Code tab, and specify a unique image tag for the updated build image. If you want to make more changes to the build details, click Edit build details. The Specify build details page opens where you can enter the details of your build to deploy your app from source code. Click Done when build detail updates are specified.
- Click Deploy to save your changes, run the build with your changes, and deploy the app revision.
- After the application status changes to Ready, you can test the app revision. Click Test application and then click Send request in the Test application pane. To open the application in a web page, click Application URL.
{: #update-app-source-cli}
Update an application to reference an image that is built from source code by using the {{site.data.keyword.codeengineshort}} CLI. {: shortdesc}
For this example, let's change the myhelloapp
that you updated in Updating an app to reference a different image in Container Registry with the CLI to reference a different image that is built from your source code.
From the previous example, the myhelloapp
app references the us.icr.io/mynamespace2/helloworld_repo
by using the myregistry
access information. Let's create a build configuration, run the build, and update the myhelloapp
to reference the image that was built from source code.
-
Create the build configuration. For example, the following
build create
command creates a build configuration that is calledhelloworld-build
. This configuration builds from the public Git repohttps://github.com/IBM/CodeEngine
, uses thedockerfile
strategy andmedium
build size, and stores the image tous.icr.io/mynamespace/codeengine-helloworld
by using the image registry secret that is defined inmyregistry
.ibmcloud ce build create --name helloworld-build --image us.icr.io/mynamespace/codeengine-helloworld --registry-secret myregistry --source https://github.com/IBM/CodeEngine --commit main --context-dir /hello --strategy dockerfile --size medium
{: pre}
-
Run the build. This example runs a build that is called
helloworld-build-run
and uses thehelloworld-build
build configuration.ibmcloud ce buildrun submit --build helloworld-build --name helloworld-build-run
{: pre}
The following output displays the details of the build run by using the
ibmcloud ce buildrun get
command.Example output
Getting build run 'helloworld-build-run'... [...] OK Name: helloworld-build-run ID: abcdefgh-abcd-abcd-abcd-1a2b3c4d5e6f Project Name: myproject Project ID: 01234567-abcd-abcd-abcd-abcdabcd1111 Age: 21m Created: 2021-09-30T14:50:13-05:00 Summary: Succeeded Status: Succeeded Reason: All Steps have completed executing Image: us.icr.io/mynamespace/codeengine-helloworld
{: screen}
For more information about creating a build configuration with the CLI, see create a build.
-
Update the
myhelloapp
to reference the image that you built and uses themyregistry
registry secret.ibmcloud ce app update --name myhelloapp --image us.icr.io/mynamespace/codeengine-helloworld --registry-secret myregistry
{: pre}
-
Display information about the updated app to confirm the image that is referenced is the image that you built.
ibmcloud ce app get --name myhelloapp
{: pre}
Example output
[...] OK Name: myhelloapp ID: abcdefgh-abcd-abcd-abcd-1a2b3c4d5e6f Project Name: myproject Project ID: 01234567-abcd-abcd-abcd-abcdabcd1111 Age: 2m4s Created: 2021-09-09T14:01:02-04:00 URL: https://myhelloapp.abcdabcdabc.us-south.codeengine.appdomain.cloud Cluster Local URL: http://myhelloapp.abcdabcdabc.svc.cluster.local Console URL: https://cloud.ibm.com/codeengine/project/us-south/01234567-abcd-abcd-abcd-abcdabcd1111/application/myhelloapp/configuration Status Summary: Application deployed successfully Environment Variables: Type Name Value Literal CE_API_BASE_URL https://api.us-south.codeengine.cloud.ibm.com Literal CE_APP myhelloapp Literal CE_DOMAIN us-south.codeengine.appdomain.cloud Literal CE_PROJECT_ID abcdefgh-abcd-abcd-abcd-1a2b3c4d5e6f Literal CE_REGION us-south Literal CE_SUBDOMAIN abcdabcdab Image: us.icr.io/mynancesnamespace/codeengine-helloworld Resource Allocation: CPU: 1 Ephemeral Storage: 400M Memory: 4G Registry Secrets: myregistry Revisions: helloapp-00003: Age: 2m46s Latest: true Traffic: 100% Image: us.icr.io/mysnamespace/codeengine-helloworld (pinned to eeca2b) Running Instances: 1 [...]
{: screen}