This document describes how to add automatic approval of CSRs to an existing cluster.
Also, you can set up this feature at the cluster installation time by adding a special variable to your inventory file:
openshift_master_bootstrap_auto_approve=true |
This variable is mentioned here in OpenSHift docs.
Limitation
- OpenShift cluster's version is 3.11
- You must have cluster admin rights
- login to the cluster with CLI or web console;
apply autoapprover.yml file from the web console or using CLI:
oc apply -f autoapprover.ymlExpand to see autoapprover.yml's content Collapse sourcekind:ClusterRoleapiVersion:v1metadata:name:system:node-bootstrap-autoapproverrules:- apiGroups:-certificates.k8s.ioresources:-certificatesigningrequestsverbs:-delete-get-list-watch- apiGroups:-certificates.k8s.ioresources:-certificatesigningrequests/approvalverbs:-create-update---kind:ServiceAccountapiVersion:v1metadata:name:bootstrap-autoapprovernamespace:openshift-infra---kind:ClusterRoleBindingapiVersion:rbac.authorization.k8s.io/v1metadata:name:bootstrap-autoapproverroleRef:kind:ClusterRolename:system:node-bootstrap-autoapproversubjects:- kind:Username:system:serviceaccount:openshift-infra:bootstrap-autoapproverapiVersion:rbac.authorization.k8s.io/v1---kind:StatefulSetapiVersion:apps/v1beta1metadata:name:bootstrap-autoapprovernamespace:openshift-infraannotations:image.openshift.io/triggers:|[{"from":{"kind":"ImageStreamTag","name":"node:v3.11"},"fieldPath":"spec.template.spec.containers[?(@.name==\"signer\")].image"}]spec:updateStrategy:type:RollingUpdatetemplate:metadata:labels:app:bootstrap-autoapproverspec:nodeSelector:node-role.kubernetes.io/master:'true'serviceAccountName:bootstrap-autoapproverterminationGracePeriodSeconds:1containers:-name:signerimage:" "command:-/bin/bash--cargs:-|#!/bin/bashset -o errexitset -o nounsetset -o pipefailunset KUBECONFIGcat <<SCRIPT > /tmp/signer#!/bin/bash## It will approve any CSR that is not approved yet, and delete any CSR that expired more than 60 seconds# ago.#set -o errexitset -o nounsetset -o pipefailname=\${1}condition=\${2}certificate=\${3}username=\${4}# auto approveif[[-z"\${condition}"&& ("\${username}"=="system:serviceaccount:openshift-infra:node-bootstrapper"||"\${username}"=="system:node:"* ||"\${username}"=="system:admin")]]; thenoc adm certificate approve"\${name}"exit0fi# check certificate ageif[[-n"\${certificate}"]]; thentext="\$( echo "\${certificate}" | base64 -d - )"if ! echo"\${text}"| openssl x509 -noout; thenecho"error: Unable to parse certificate"2>&1exit1fiif ! echo"\${text}"| openssl x509 -checkend -60 > /dev/null; thenecho"Certificate is expired, deleting"oc delete csr"\${name}"fiexit0fiSCRIPTchmod u+x /tmp/signerexec oc observe csr --maximum-errors=1 --resync-period=10m -a'{.status.conditions[*].type}'-a'{.status.certificate}'-a'{.spec.username}'-- /tmp/signer---apiVersion:image.openshift.io/v1kind:ImageStreamTagmetadata:name:node:v3.11namespace:openshift-infratag:reference:truefrom:kind:DockerImagename:artifactorycn.ORG.com:17011/openshift/node:v3.11.0
Checks
Verify that bootstrap-autoapprover pod is up and running in openshift-infra namespace using web console or CLI:
oc get pod -n openshift-infra | grep bootstrap-autoapprover |
