Deploying containers
If something happens during the build process, or if a vulnerability is discovered after an image has been deployed, you can use tooling for automated, policy-based deployment to remediate. You can use triggers to rebuild and replace images, ensuring the immutable containers process, instead of patching running containers, which is not recommended.
For example, you build an application using three container image layers: core, middleware, and applications. An issue is discovered in the core image and that image is rebuilt. After the build is complete, the image is pushed to your OpenShift Container Registry. OKD detects that the image has changed and automatically rebuilds and deploys the application image, based on the defined triggers. This change incorporates the fixed libraries and ensures that the production code is identical to the most current image.
You can use the command to set a deployment trigger. For example, to set a trigger for a deployment called deployment-example:
It is important that the intended images are actually being deployed, that the images including the contained content are from trusted sources, and they have not been altered. Cryptographic signing provides this assurance. OKD enables cluster administrators to apply security policy that is broad or narrow, reflecting deployment environment and security requirements. Two parameters define this policy:
trust type, such as accept, reject, or require public key(s)
You can use these policy parameters to allow, deny, or require a trust relationship for entire registries, parts of registries, or individual images. Using trusted public keys, you can ensure that the source is cryptographically verified. The policy rules apply to nodes. Policy may be applied uniformly across all nodes or targeted for different node workloads (for example, build, zone, or environment).
Example image signature policy file
The policy can be saved onto a node as /etc/containers/policy.json
. Saving this file to a node is best accomplished using a new MachineConfig
object. This example enforces the following rules:
Require images from your OpenShift Container Registry in the
openshift
namespace to be signed by the Red Hat public key.Require images from your OpenShift Container Registry in the
production
namespace to be signed by the public key forexample.com
.Reject all other registries not specified by the global
default
definition.
A signature transport is a way to store and retrieve the binary signature blob. There are two types of signature transports.
: Served as a local file or by a web server.
The OKD API manages signatures that use the atomic
transport type. You must store the images that use this signature type in your OpenShift Container Registry. Because the docker/distribution extensions
API auto-discovers the image signature endpoint, no additional configuration is required.
Signatures that use the docker
transport type are served by local file or web server. These signatures are more flexible; you can serve images from any container image registry and use an independent server to deliver binary signatures.
However, the docker
transport type requires additional configuration. You must configure the nodes with the URI of the signature server by placing arbitrarily-named YAML files into a directory on the host system, /etc/containers/registries.d
by default. The YAML configuration files contain a registry URI and a signature server URI, or sigstore:
Example registries.d file
The Secret
object type provides a mechanism to hold sensitive information such as passwords, OKD client configuration files, dockercfg
files, and private source repository credentials. Secrets decouple sensitive content from pods. You can mount secrets into containers using a volume plugin or the system can use secrets to perform actions on behalf of a pod.
For example, to add a secret to your deployment configuration so that it can access a private image repository, do the following:
Procedure
Log in to the OKD web console.
Create a new project.
Navigate to Resources → Secrets and create a new secret. Set
Secret Type
toImage Secret
andAuthentication Type
toImage Registry Credentials
to enter credentials for accessing a private image repository.When creating a deployment configuration (for example, from the Add to Project → Deploy Image page), set the
Pull Secret
to your new secret.
Config maps are similar to secrets, but are designed to support working with strings that do not contain sensitive information. The object holds key-value pairs of configuration data that can be consumed in pods or used to store configuration data for system components such as controllers.
You can integrate your own continuous deployment (CD) tooling with OKD.
By leveraging CI/CD and OKD, you can automate the process of rebuilding the application to incorporate the latest fixes, testing, and ensuring that it is deployed everywhere within the environment.