Skip to content

Commit cf8bdf8

Browse files
Piotr GodowskiPiotr Godowski
authored andcommitted
Add stop gap image registry redirection for OCP Hosted Control Planes
Signed-off-by: Author Name <[email protected]>
1 parent d4a42e2 commit cf8bdf8

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Overview
2+
3+
On [OpenShift Hosted Control Planes](https://docs.redhat.com/en/documentation/openshift_container_platform/4.18/html/hosted_control_planes/hosted-control-planes-overview), there is no first class support for image registry redirection, which is on OpenShift deployments provided via [`ImageContentSourcePolicy`](https://docs.redhat.com/en/documentation/openshift_container_platform/4.18/html/images/image-configuration#images-configuration-blocked-payload) or [`ImageDigestMirrorSet`](https://docs.redhat.com/en/documentation/openshift_container_platform/4.14/html/config_apis/imagedigestmirrorset-config-openshift-io-v1)
4+
5+
There if RFE to provide support for image registry redirection https://issues.redhat.com/browse/XCMSTRAT-994 , yet this document provides stop-gap solution on Hosted Control Planes, before the first class support is provided.
6+
7+
The procedure consists of two steps:
8+
- creating an image pull secret for the registry mirror to use
9+
- create a (privileged) `DaemonSet` which updates the worker node's container runtime configuration file, `/var/lib/kubelet/config.json`
10+
11+
## Step 1 - create a secret for the additional config.json.
12+
13+
The config.json can be created by `podman login --authfile`:
14+
15+
```sh
16+
podman login -u [user]] -p [password] --authfile=/path/to/your/additional/config.json [registry]
17+
```
18+
19+
Create the image pull secret `docker-auth-secret` in `kube-system` namespace:
20+
21+
```sh
22+
oc create secret generic docker-auth-secret \
23+
--namespace kube-system \
24+
--from-file=.dockerconfigjson=/path/to/your/additional/config.json \
25+
--type=kubernetes.io/dockerconfigjson --dry-run=client -o yaml | oc apply -f
26+
```
27+
28+
## Step 2 - create a DaemonSet updating container runtime configuration
29+
30+
The DeamonSet init container updates the container runtime configuration on each of the worker node and then sleeps indefinitely.
31+
32+
```sh
33+
oc apply -f update-docker-config-ds.yaml
34+
```
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
apiVersion: apps/v1
2+
kind: DaemonSet
3+
metadata:
4+
name: update-docker-config
5+
namespace: kube-system
6+
labels:
7+
app: update-docker-config
8+
spec:
9+
selector:
10+
matchLabels:
11+
name: update-docker-config
12+
template:
13+
metadata:
14+
labels:
15+
name: update-docker-config
16+
spec:
17+
initContainers:
18+
- command: ["/bin/sh", "-c"]
19+
args:
20+
- >
21+
echo "Backing up or restoring config.json";
22+
[[ -s /docker-config/config.json ]] && cp /docker-config/config.json /docker-config/config.json.bak || cp /docker-config/config.json.bak /docker-config/config.json;
23+
echo "Merging secret with config.json";
24+
/host/usr/bin/jq -s '.[0] * .[1]' /docker-config/config.json /auth/.dockerconfigjson > /docker-config/config.tmp;
25+
mv /docker-config/config.tmp /docker-config/config.json;
26+
systemctl reload crio
27+
image: registry.access.redhat.com/ubi9:latest
28+
imagePullPolicy: IfNotPresent
29+
name: updater
30+
resources: {}
31+
securityContext:
32+
privileged: true
33+
volumeMounts:
34+
- name: docker-auth-secret
35+
mountPath: /auth
36+
- name: docker
37+
mountPath: /docker-config
38+
- name: bin
39+
mountPath: /host/usr/bin
40+
- name: lib64
41+
mountPath: /lib64
42+
containers:
43+
- resources:
44+
requests:
45+
cpu: "0.01"
46+
image: registry.access.redhat.com/ubi9:latest
47+
name: sleepforever
48+
command: ["/bin/sh", "-c"]
49+
args:
50+
- >
51+
while true; do
52+
sleep 100000;
53+
done
54+
hostPID: true
55+
volumes:
56+
- name: docker-auth-secret
57+
secret:
58+
secretName: docker-auth-secret
59+
- name: docker
60+
hostPath:
61+
path: /var/lib/kubelet/
62+
- name: bin
63+
hostPath:
64+
path: /usr/bin
65+
- name: lib64
66+
hostPath:
67+
path: /lib64
68+
hostPathType: Directory

0 commit comments

Comments
 (0)