|
4 | 4 |
|
5 | 5 | [id="containers-signature-verify-enable_{context}"] |
6 | 6 | = Enabling signature verification for Red Hat Container Registries |
7 | | -Enabling container signature validation requires files that link the registry URLs to the sigstore and then specifies the keys which verify the images. |
| 7 | +Enabling container signature validation for Red Hat Container Registries requires writing a signature verification policy file specifying the keys to verify images from these registries. The registries are already defined in `/etc/containers/registries.d` by default. |
8 | 8 |
|
9 | 9 | .Procedure |
10 | | -. Create the files that link the registry URLs to the sigstore and that specifies the key to verify the image. |
11 | | - |
12 | | -** Create the `policy.json` file: |
| 10 | +. Create a Butane config file, `51-worker-rh-registry-trust.bu`, containing the necessary configuration for the worker nodes. |
13 | 11 | + |
14 | | -[source,terminal] |
| 12 | +[NOTE] |
| 13 | +==== |
| 14 | +See "Creating machine configs with Butane" for information about Butane. |
| 15 | +==== |
| 16 | ++ |
| 17 | +[source,yaml] |
15 | 18 | ---- |
16 | | -$ cat > policy.json <<EOF |
17 | | -{ |
18 | | - "default": [ |
19 | | - { |
20 | | - "type": "insecureAcceptAnything" |
21 | | - } |
22 | | - ], |
23 | | - "transports": { |
24 | | - "docker": { |
25 | | - "registry.access.redhat.com": [ |
26 | | - { |
27 | | - "type": "signedBy", |
28 | | - "keyType": "GPGKeys", |
29 | | - "keyPath": "/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release" |
30 | | - } |
31 | | - ], |
32 | | - "registry.redhat.io": [ |
33 | | - { |
34 | | - "type": "signedBy", |
35 | | - "keyType": "GPGKeys", |
36 | | - "keyPath": "/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release" |
37 | | - } |
38 | | - ] |
39 | | - }, |
40 | | - "docker-daemon": { |
41 | | - "": [ |
| 19 | +variant: openshift |
| 20 | +version: 4.8.0 |
| 21 | +metadata: |
| 22 | + name: 51-worker-rh-registry-trust |
| 23 | + labels: |
| 24 | + machineconfiguration.openshift.io/role: worker |
| 25 | +storage: |
| 26 | + files: |
| 27 | + - path: /etc/containers/policy.json |
| 28 | + mode: 0644 |
| 29 | + overwrite: true |
| 30 | + contents: |
| 31 | + inline: | |
42 | 32 | { |
43 | | - "type": "insecureAcceptAnything" |
| 33 | + "default": [ |
| 34 | + { |
| 35 | + "type": "insecureAcceptAnything" |
| 36 | + } |
| 37 | + ], |
| 38 | + "transports": { |
| 39 | + "docker": { |
| 40 | + "registry.access.redhat.com": [ |
| 41 | + { |
| 42 | + "type": "signedBy", |
| 43 | + "keyType": "GPGKeys", |
| 44 | + "keyPath": "/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release" |
| 45 | + } |
| 46 | + ], |
| 47 | + "registry.redhat.io": [ |
| 48 | + { |
| 49 | + "type": "signedBy", |
| 50 | + "keyType": "GPGKeys", |
| 51 | + "keyPath": "/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release" |
| 52 | + } |
| 53 | + ] |
| 54 | + }, |
| 55 | + "docker-daemon": { |
| 56 | + "": [ |
| 57 | + { |
| 58 | + "type": "insecureAcceptAnything" |
| 59 | + } |
| 60 | + ] |
| 61 | + } |
| 62 | + } |
44 | 63 | } |
45 | | - ] |
46 | | - } |
47 | | - } |
48 | | -} |
49 | | -EOF |
50 | | ----- |
51 | | - |
52 | | -** Create the `registry.access.redhat.com.yaml` file: |
53 | | -+ |
54 | | -[source,terminal] |
55 | | ----- |
56 | | -$ cat <<EOF > registry.access.redhat.com.yaml |
57 | | -docker: |
58 | | - registry.access.redhat.com: |
59 | | - sigstore: https://access.redhat.com/webassets/docker/content/sigstore |
60 | | -EOF |
61 | 64 | ---- |
62 | 65 |
|
63 | | -** Create the `registry.redhat.io.yaml` file: |
| 66 | +. Use Butane to generate a machine config YAML file, `51-worker-rh-registry-trust.yaml`, containing the file to be written to disk on the worker nodes: |
64 | 67 | + |
65 | 68 | [source,terminal] |
66 | 69 | ---- |
67 | | -$ cat <<EOF > registry.redhat.io.yaml |
68 | | -docker: |
69 | | - registry.redhat.io: |
70 | | - sigstore: https://registry.redhat.io/containers/sigstore |
71 | | -EOF |
72 | | ----- |
73 | | - |
74 | | -. Set the files with a `base64` encode format that will be used for the machine config template: |
75 | | -+ |
76 | | -[source,terminal] |
77 | | ----- |
78 | | -$ export ARC_REG=$( cat registry.access.redhat.com.yaml | base64 -w0 ) |
79 | | -$ export RIO_REG=$( cat registry.redhat.io.yaml | base64 -w0 ) |
80 | | -$ export POLICY_CONFIG=$( cat policy.json | base64 -w0 ) |
81 | | ----- |
82 | | - |
83 | | -. Create a machine config that writes the exported files to disk on the worker nodes: |
84 | | -+ |
85 | | -[source,terminal] |
86 | | ----- |
87 | | -$ cat > 51-worker-rh-registry-trust.yaml <<EOF |
88 | | -apiVersion: machineconfiguration.openshift.io/v1 |
89 | | -kind: MachineConfig |
90 | | -metadata: |
91 | | - labels: |
92 | | - machineconfiguration.openshift.io/role: worker |
93 | | - name: 51-worker-rh-registry-trust |
94 | | -spec: |
95 | | - config: |
96 | | - ignition: |
97 | | - config: {} |
98 | | - security: |
99 | | - tls: {} |
100 | | - timeouts: {} |
101 | | - version: 2.2.0 |
102 | | - networkd: {} |
103 | | - passwd: {} |
104 | | - storage: |
105 | | - files: |
106 | | - - contents: |
107 | | - source: data:text/plain;charset=utf-8;base64,${ARC_REG} |
108 | | - verification: {} |
109 | | - filesystem: root |
110 | | - mode: 420 |
111 | | - path: /etc/containers/registries.d/registry.access.redhat.com.yaml |
112 | | - - contents: |
113 | | - source: data:text/plain;charset=utf-8;base64,${RIO_REG} |
114 | | - verification: {} |
115 | | - filesystem: root |
116 | | - mode: 420 |
117 | | - path: /etc/containers/registries.d/registry.redhat.io.yaml |
118 | | - - contents: |
119 | | - source: data:text/plain;charset=utf-8;base64,${POLICY_CONFIG} |
120 | | - verification: {} |
121 | | - filesystem: root |
122 | | - mode: 420 |
123 | | - path: /etc/containers/policy.json |
124 | | - osImageURL: "" |
125 | | -EOF |
| 70 | +$ butane 51-worker-rh-registry-trust.bu -o 51-worker-rh-registry-trust.yaml |
126 | 71 | ---- |
127 | 72 |
|
128 | 73 | . Apply the created machine config: |
|
132 | 77 | $ oc apply -f 51-worker-rh-registry-trust.yaml |
133 | 78 | ---- |
134 | 79 |
|
135 | | -. Create a machine config, which writes the exported files to disk on the master nodes: |
| 80 | +. Create a Butane config and corresponding machine config which writes the configuration to disk on the control plane nodes: |
136 | 81 | + |
137 | 82 | [source,terminal] |
138 | 83 | ---- |
139 | | -$ cat > 51-master-rh-registry-trust.yaml <<EOF |
140 | | -apiVersion: machineconfiguration.openshift.io/v1 |
141 | | -kind: MachineConfig |
142 | | -metadata: |
143 | | - labels: |
144 | | - machineconfiguration.openshift.io/role: master |
145 | | - name: 51-master-rh-registry-trust |
146 | | -spec: |
147 | | - config: |
148 | | - ignition: |
149 | | - config: {} |
150 | | - security: |
151 | | - tls: {} |
152 | | - timeouts: {} |
153 | | - version: 2.2.0 |
154 | | - networkd: {} |
155 | | - passwd: {} |
156 | | - storage: |
157 | | - files: |
158 | | - - contents: |
159 | | - source: data:text/plain;charset=utf-8;base64,${ARC_REG} |
160 | | - verification: {} |
161 | | - filesystem: root |
162 | | - mode: 420 |
163 | | - path: /etc/containers/registries.d/registry.access.redhat.com.yaml |
164 | | - - contents: |
165 | | - source: data:text/plain;charset=utf-8;base64,${RIO_REG} |
166 | | - verification: {} |
167 | | - filesystem: root |
168 | | - mode: 420 |
169 | | - path: /etc/containers/registries.d/registry.redhat.io.yaml |
170 | | - - contents: |
171 | | - source: data:text/plain;charset=utf-8;base64,${POLICY_CONFIG} |
172 | | - verification: {} |
173 | | - filesystem: root |
174 | | - mode: 420 |
175 | | - path: /etc/containers/policy.json |
176 | | - osImageURL: "" |
177 | | -EOF |
| 84 | +$ sed -e 's,\(machineconfiguration.openshift.io/role: \)worker,\1master,' \ |
| 85 | + -e 's,\(name: 51-\)worker,\1master,' 51-worker-rh-registry-trust.bu \ |
| 86 | + > 51-master-rh-registry-trust.bu |
| 87 | +$ butane 51-master-rh-registry-trust.bu -o 51-master-rh-registry-trust.yaml |
178 | 88 | ---- |
179 | 89 |
|
180 | | -. Apply the master machine config changes to the cluster: |
| 90 | +. Apply the control plane machine config to the cluster: |
181 | 91 | + |
182 | 92 | [source,terminal] |
183 | 93 | ---- |
|
0 commit comments