Skip to content

Commit c5d4d0f

Browse files
committed
data: add approve-csr service to approve CSRs until bootstrap is complete
PR for cluster-machine-approver [1] is taking over the approval of CSRs for client certificates for Machines that end up as Nodes in Openshift clusters. But during bootstrapping, cluster-machine-approver is not available and therefore, this service is required to approve CSRs until we have successfully bootstrapped the control plane, after which cluster-machine-approver or users take over the role of approving any new CSRs. Currently, all CSRs are automatically approved without any condition, this PR scopes it to only during bootstrapping phase, securing the endpoint for later use. [1]: openshift/cluster-machine-approver#26
1 parent 403a93d commit c5d4d0f

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
KUBECONFIG="${1}"
4+
5+
echo "Approving all CSR requests until bootstrapping is complete..."
6+
while [ ! -f /opt/openshift/bootkube.done ]
7+
do
8+
oc --config="$KUBECONFIG" get csr --no-headers | grep Pending | \
9+
awk '{print $1}' | \
10+
xargs --no-run-if-empty oc --config="$KUBECONFIG" adm certificate approve
11+
sleep 20
12+
done
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[Unit]
2+
Description=Approve CSRs during bootstrap phase
3+
Wants=bootkube.service
4+
After=bootkube.service
5+
6+
[Service]
7+
ExecStart=/usr/local/bin/approve-csr.sh /opt/openshift/auth/kubeconfig
8+
9+
Restart=on-failure
10+
RestartSec=5s
11+
12+
[Install]
13+
WantedBy=multi-user.target

pkg/asset/ignition/bootstrap/bootstrap.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ func (a *Bootstrap) addSystemdUnits(uri string, templateData *bootstrapTemplateD
248248
"kubelet.service": {},
249249
"chown-gatewayd-key.service": {},
250250
"systemd-journal-gatewayd.socket": {},
251+
"approve-csr.service": {},
251252
}
252253

253254
directory, err := data.Assets.Open(uri)

0 commit comments

Comments
 (0)