Container Registry (ACR), Key Management Service (KMS), Security Center, and the kritis-validation-hook add-on can automatically verify container image signatures. This ensures that only container images signed by trusted authorities are deployed, reducing the risk of accidental or malicious code in the environment.
Prerequisites
Security Center is activated:
Create a KMS key that uses an asymmetric encryption algorithm. For more information, see Manage keys.
ImportantContainer signing requires an asymmetric key. When creating the KMS key, set Key Type to RSA_2048 and Key Usage to Sign/Verify. For more information about KMS key algorithms, see Key Management Service overview.
An ACR Enterprise Edition instance with the Advanced specification is available.
Step 1: Install kritis-validation-hook
-
Log on to the ACK console. In the left navigation pane, click Clusters.
-
On the Clusters page, click the name of your cluster. In the left navigation pane, click Components and Add-ons .
On the Add-ons page, click the Security tab, find kritis-validation-hook, and then click Install.
Grant the permissions required to access the kritis-validation-hook add-on.
Ensure that the cluster has the required permissions to run the kritis-validation-hook component. For more information, see Configure access permissions for resources.
Step 2: Create a KMS key for image signing
To create a Customer Master Key (CMK), see Manage keys.
When creating the key, set Key Type to RSA_2048 and Key Usage to Sign/Verify.
Step 3: Create a witness in Security Center
Log on to the Security Center console.
In the left-side navigation pane, choose .
On the Witness tab, click Create Witness. After configuring the parameters, click OK.
Parameter
Description
Witness Name
When configuring a container signing security policy, a witness is selected to provide trusted authorization for container images. Use a descriptive name.
Select Certificate
From the certificate list, select the KMS key created earlier.
Description
Enter a description for the witness.
Step 4: Enable automatic image signing in ACR
Log on to the Container Registry console.
In the top navigation bar, select a region.
In the left-side navigation pane, click Instances.
On the Instance page, find the Enterprise Edition instance and click its name, or click Manage in the Actions row.
NoteTo create an Enterprise Edition instance, click Create ACR EE. Set Specification to Advanced.
In the left-side navigation pane of the instance details page, choose .
Create a namespace to enable image signing for all container images in the namespace. For more information, see Basic operations on namespaces.
Enable automatic image signing for the namespace created earlier.
When adding a signature rule, select the witness created in Security Center in Step 3.
In the left-side navigation pane of the instance details page, choose .
On the Image Signature tab, click Create a signature rule.
For more information, see Configure a rule for automatic image signing.
Step 5: Enable signature verification in Security Center
Create and enable a security policy in Security Center to enforce container image signature verification for a specific Kubernetes namespace.
Log on to the Security Center console.
In the left-side navigation pane, choose .
On the Security Policy tab, click Create Policy. After configuring the policy, click OK.
Parameter
Description
Policy Name
When you configure a signature security policy, you must select a witness to grant trusted authorization to your target cluster.
Enter a descriptive policy name that is easy to identify.
Witness
Select the witness created earlier.
Application Cluster
Click the cluster group that requires signature verification, and select the target Cluster Namespace.
Policy Status
Enable this option to activate the policy immediately.
NoteThe policy is disabled by default. A policy does not take effect unless you enable it.
Description
Enter a description for the security policy.
Step 6: Verify automatic signature verification
If image tag immutability is not enabled, use a digest-formatted image reference. For more information, see Enable image tag immutability.
Run the following commands to verify that signature verification is working as expected.
In the namespace where signature verification is enabled, attempts to deploy unsigned container images are rejected.
Use a tag-formatted image reference:
kubectl -n default create deployment not-sign --image=alpine:3.11 -- sleep 10Error from server: admission webhook "kritis-validation-hook-deployments.grafeas.io" denied the request: image alpine:3.11 is not attestedUse a digest-formatted image reference:
kubectl -n default create deployment not-sign --image=alpine@sha256:ddba4d27a7ffc3f86dd6c2f92041af252a1f23a8e742c90e6e1297bfa1bc0c45 -- sleep 10Error from server: admission webhook "kritis-validation-hook-deployments.grafeas.io" denied the request: image alpine@sha256:ddba4d27a7ffc3f86dd6c2f92041af252a1f23a8e742c90e6e1297bfa1bc0c45 is not attestedPush an image to the ACR namespace where automatic signing is enabled, and then verify that the signed container image can be deployed.
docker push kritis-demo***.cn-hongkong.cr.aliyuncs.com/kritis-demo***/alpine:3.11The push refers to repository [kritis-demo***.cn-hongkong.cr.aliyuncs.com/kritis-demo***/alpine] 5216338b40a7: Pushed 3.11: digest: sha256:ddba4d27a7ffc3f86dd6c2f92041af252a1f23a8e742c90e6e1297bfa1bc0c45 size: 528Deploy the automatically signed container image:
kubectl -n default create deployment is-signed --image=kritis-demo***.cn-hongkong.cr.aliyuncs.com/kritis-demo***/alpine@sha256:ddba4d27a7ffc3f86dd6c2f92041af252a1f23a8e742c90e6e1297bfa1bc0c45 -- sleep 10deployment.apps/is-signed created
Related documents
For an overview of the kritis-validation-hook component, see kritis-validation-hook component overview.
For the release notes of the kritis-validation-hook component, see kritis-validation-hook.