Tech Tip

Using the Kubernetes Plug-in with CI/CD

Print

<< Back to Getting Started with IBM UrbanCode Deploy and Containers

If you have looked at the tutorials and examples regarding the usage of the Kubernetes plug-in for UrbanCode Deploy, you have seen how the plug-in’s Process YAML File step reads YAML files and creates components based on images found in the YAML file. This allows users to gain a visual representation and governance of which image tags (versions) are deployed where. Users may change which image tags are deployed by using the UrbanCode Deploy user interface, eliminating the need to update YAML files in order to change which image tag is deployed.

By default, after the initial deployment, if a user deployed YAML files but did not specify which image tags to deploy using the UrbanCode Deploy user interface, the Process YAML File step would default to the image tags in the current UrbanCode Deploy inventory. For example, let’s say your YAML file specifies a tag named v1 for an image. The first time you run the Process YAML File step, tag v1 will be deployed and a component representing your image will be created. Let’s say you create a second version of your YAML file which specifies the tag v2 for your image. If you run the Process YAML File step again, but do not specify a tag for the image component to use, UrbanCode Deploy will default to tag specified in UrbanCode Deploy’s inventory. In this example, if a tag was not specified for our image, tag v1 would again be deployed even though the YAML file specified tag v2.

There may be cases where this default behavior is not desired. For example, in continuous integration and continuous deployment (CI/CD) scenarios, users may always want the image tags specified in the YAML files to be deployed. Users may still want the governance that UrbanCode Deploy offers, but always want YAML files to dictate which image tags are deployed.

Starting in version 13 of the Kubernetes plug-in, users may chose to have the Process YAML File step always deploy the image tags specified in the YAML files. Version 13 introduces the Always Apply Image Tags from YAML property to the Process YAML File step:

In order to always apply the image tags specified in the YAML files, set this property to true. If not set to true, the default behavior of the Process YAML File step will be used (where unspecified image tags default to what is in the current UrbanCode Deploy inventory).

The default value for the Always Apply Image Tags from YAML property is ${p?:environment/alwaysApplyVersionsFromYaml}. This allows the use of an environment property to specify the behavior of the Process YAML File step by environment. For example, perhaps your Development environment always wants to deploy the image tags specified in the YAML files, while your Production environment wants the ability to change image tags without updating YAML files.

The Kubernetes application template has been updated to include this environment property. The application template’s Deploy from YAML file process has also been updated:

If using the default behavior, the Update Inventory step is run to ensure UrbanCode Deploy inventory is correctly set. If applying image tags specified in YAML files, the Process YAML File step updates the inventory for us, so the Update Inventory step is skipped.