Esempio n. 1
0
 def get_resource_api(api_client: client.ApiClient = None,
                      **kwargs) -> "client.CertificatesV1Api":
     """
     Returns an instance of the kubernetes API client associated with
     this object.
     """
     if api_client:
         kwargs["apl_client"] = api_client
     return client.CertificatesV1Api(**kwargs)
Esempio n. 2
0
def run_csr_approval(client: k8s.ApiClient, node_csr_spec: Dict[str,
                                                                Any]) -> None:
    api = k8s.CertificatesV1Api(client)
    csrs: k8s.V1CertificateSigningRequestList \
        = api.list_certificate_signing_request()
    now = datetime.utcnow()
    csrs_to_approve = iterate_csrs(csrs, node_csr_spec)
    for csr in csrs_to_approve:
        try:
            create_approval_patch(csr, now)
            api.replace_certificate_signing_request_approval(csr.metadata.name,
                                                             body=csr)
        except BaseException as e:
            # Log, but don't quit -> continue processing other CSRs
            logger.error(e, exc_info=True)