Update Self-Managed Commerce Images
This topic describes how to update the container images of a Self-Managed Commerce stack, and how to deploy the updated images to your Commerce environments. For an overview of how to update all CloudOps for Kubernetes components, see Update CloudOps for Kubernetes Components.
The Self-Managed Commerce stack in each Commerce environment runs these container images:
- The Self-Managed Commerce application images, such as
cortexandcm. - The base images that the application images are built from:
amazonlinux-javaandtomcat. - The
activemqimage. - The
mysqlimage, in Commerce environments that use a MySQL container database.
Where Image Updates Come From
Java, Tomcat, ActiveMQ, and MySQL
The ops-spec.json file in your ep-commerce branch defines the versions of the Java Virtual Machine (JVM), Apache Tomcat, ActiveMQ, and MySQL. Elastic Path delivers security patches for these components as Self-Managed Commerce patches that update ops-spec.json. To update the JVM, Tomcat, or ActiveMQ, consume these patches and then rebuild and deploy the images.
For more information, see Operations Specification.
Operating System
How the images get operating system updates depends on which Jenkins jobs you use to build them.
-
Existing Jenkins build jobs: The existing CloudOps for Kubernetes Jenkins build jobs from release 3.x build the images from the Elastic Path Docker project. The
amazonlinux-javaimage starts from the latest Amazon Linux 2023 image, and the build installs all available operating system updates. Thetomcatandactivemqimages are built from theamazonlinux-javaimage. Each build therefore includes the latest operating system updates. Themysqlimage starts from the latest official MySQL image for the MySQL version that you select.Rebuild and deploy the images regularly, for example once a month, even when there are no new Self-Managed Commerce patches.
-
New V2 pipelines: The new V2 pipelines, introduced in CloudOps for Kubernetes 4.0.x, build the images with the Self-Managed Commerce build tools in your
ep-commercebranch. These build tools use a pinned Amazon Linux base image version, and they do not install operating system updates. Rebuilding an image without new patches does not add operating system updates to it. The images get new operating system updates when you consume a Self-Managed Commerce patch that updates the pinned base image version.
Update the Images
To update the Commerce images, complete these steps:
Step 1: Consume any Application Patches
- Identify and obtain the latest Self-Managed Commerce patches and merge them into your
ep-commercebranch. Include all patches that updateops-spec.json, because these patches update the JVM, Tomcat, and ActiveMQ versions. For instructions, see Consuming Support Fixes in the Self-Managed Commerce documentation. - Review the patch release notes. Note any patch that requires a database update. You must run data population with the
update-dbcommand when you deploy those patches. - If you use the existing Jenkins build jobs, also update your branch of the Elastic Path Docker project to the latest compatible release. These jobs build the base, ActiveMQ, and MySQL images from that project. For the changes in each release, see the Elastic Path Docker Changelog.
Step 2: Build the Images
Run the below jobs, or a pipeline that runs jobs that build the ep-commerce code and the images.
Using the Existing Jenkins Jobs
- Run the
build-deployment-packageJenkins job. SetepCommerceBranchto the branch that includes the patches. - Run the
build-selected-docker-imagesJenkins job:- Set
epCommerceBranchto the same branch. The job readsops-spec.jsonfrom this branch to find the JVM, Tomcat, and ActiveMQ versions. - Leave
deploymentPackageUrlempty. The job then uses the deployment package that you built in the previous step. - Leave the Self-Managed Commerce application images selected, such as
buildCortexandbuildCm. These are selected by default. - Select
buildBaseandbuildActivemq. These are not selected by default. - If any of your Commerce environments use a MySQL container database, select
buildMysqland setmysqlVersionto the MySQL version of those environments. - Set
dockerBranchto your branch of the Elastic Path Docker project. - Set
imageTagto the tag for the new images.
- Set
Using the New V2 Pipelines
Run the v2-build-commerce-images Jenkins job:
- Set
epCommerceBranchto the branch that includes the patches. - Leave
buildJava,buildTomcat, andbuildActivemqselected. - If any of your Commerce environments use a MySQL container database, leave
buildMysqlselected and setmysqlVersionto the MySQL version of those environments. If the parameter is empty, the job builds the default MySQL version of yourep-commercecode, which might be different.
The default image tag is a short hash of the ep-commerce Git commit.
For more information, see V2 Builds and Artifacts.
Step 3: Deploy the Images to Each Commerce Environment
Deploy and test the new images in your non-production environments before you deploy them to production. Keep the author and live environments of a Commerce stack at the same patch level.
Use your existing code deployment process and jobs to roll out the updated Commerce application images.
Be sure to update the ActiveMQ container image in each environment. For any environments that use the MySQL containerized database, also update the MySQL container image.
ActiveMQ and the MySQL container each run as one pod. While the pod is replaced, the service is unavailable. Messages and data are kept on persistent volumes. Deploy the updates at a time of low traffic.
To deploy the images to a Commerce environment, complete these steps:
- Optionally, retag the images, or promote them from another AWS account, with the
pull-docker-imagesJenkins job. Do this if it fits your team's tagging or image promotion strategy. If you built a MySQL image, addep/mysqlto theepImageReposparameter. - Update the services. The procedure depends on the image tag that the environment uses:
- If the environment already uses the tag of the new images, see Restart the Services.
- If the environment uses a different tag, see Update the Image Tag.
Restart the Services
The services pull their image every time a pod starts. When you build or retag images with a tag that is already deployed, any pod that starts uses the new image, even before you restart the services. For example, pods start when a node is replaced, when the cluster scales, or when a pod fails. The environment can then run a mix of old and new images, or run new code before the database update. You also cannot roll back to the old images by their tag.
The restart-commerce-stack Jenkins job restarts all the services that you specify at the same time. To restart the services in the correct order, run the job several times. Each run waits until its services are running again.
- If the environment uses a MySQL container database, run the
restart-commerce-stackJenkins job withcontainersToRestartset tomysql. - Run the
restart-commerce-stackJenkins job withcontainersToRestartset toactivemq. - If the patches require a database update, run the
run-data-pop-toolJenkins job with theupdate-dbcommand. LeaverestartAppscleared. - Run the
restart-commerce-stackJenkins job withcontainersToRestartset tosearchmaster. - Run the
restart-commerce-stackJenkins job withcontainersToRestartset tocortex cm integration batch searchslave data-sync mock. The job skips the services that are not deployed in the environment.
Update the Image Tag
Using the Existing Jenkins Jobs
- Run the
create-or-delete-activemq-containerJenkins job withimageTagset to the new tag. For more information, see Manage ActiveMQ Deployments. - If the environment uses a MySQL container database, run the
create-or-delete-mysql-containerJenkins job withimageTagset to the new tag. - If the patches require a database update, run the
run-data-pop-toolJenkins job with theupdate-dbcommand. - Run the
deploy-or-delete-commerce-stackJenkins job withdockerImageTagset to the new tag.
For more information, see Updating Self Managed Commerce.
Using the New V2 Pipelines
To update all the services, complete these steps:
- In the environment files in
environments/<kubernetesNickname>/, setimageTagto the new tag in these files:activemq-values.yamlmysql-container.yaml, if the environment uses a MySQL container databasecommerce-values.yaml
- Commit and push the changes to the Git branch that the job reads the environment files from.
- Run the
v2-configure-commerce-environmentJenkins job:- Set
envFileSourcetofromGit. - Set
commerceImageTagSourcetofromYaml. With the default value,fromCluster, the job does not change the image tag of the Self-Managed Commerce services. - If the patches require a database update, set
dataPopCommandtoupdate-db.
- Set
If you rebuilt only the Self-Managed Commerce application images, run the v2-deploy-commerce-images Jenkins job instead. Set sourceImageTag to the new tag. If the patches require a database update, set dataPopCommand to update-db.
For more information, see Configuring Environments with V2 Pipelines and Environment Files Reference.