How to update client secret in azure cloud credentials

Solution Verified - Updated -

Environment

  • Red Hat OpenShift Container Platform (RHOCP) 4.x
  • Microsoft Azure

Issue

  • Azure Service Principal has expired or is about to expire, and needs to be rotated.

  • Client secret expired presenting the following error:

    Status Code = '401'. Response body: {"error":"invalid_client","error_description":"AADSTS7000222: The provided client secret keys are expired. Visit the Azure Portal to create new keys for your app, or consider using certificate credentials for added security.
    

Resolution

Disclaimer: Links contained herein to external website(s) are provided for convenience only. Red Hat has not reviewed the links and is not responsible for the content or its availability. The inclusion of any link to an external website does not imply endorsement by Red Hat of the website or their entities, products or services. You agree that Red Hat is not responsible or liable for any loss or expenses that may result due to your use of (or reliance on) the external site or content.

NOTE: For Azure Red Hat OpenShift (ARO), please follow the Microsoft documentation or refer to this article.

  • Client secrets are generally stored in the azure-credentials secret within the kube-system project in base64 encode. If the Client secret got expired or new secret needs to be updated, please follow the below procedure:
  1. Take backup of the azure-credentials secret:

    $ oc get secret azure-credentials -n kube-system -o yaml > azurebackup.yaml
    
  2. Convert the new secret to base64 format:

    $ echo -n "<SECRETKEY>" | base64 -i
    
  3. Copy the base64 encoded value and update the same in the azure-credentials:

    $ oc edit secret azure-credentials -n kube-system
    ...
    data:
    azure_client_id: XXXXXXXXXXXXXX
    azure_client_secret: XXXXXXXXXXXXXX
    azure_region: XXXXXXXXXXXXXX
    azure_resource_prefix: XXXXXXXXXXXXXX
    azure_resourcegroup: XXXXXXXXXXXXXX
    azure_subscription_id: XXXXXXXXXXXXXX
    azure_tenant_id: XXXXXXXXXXXXXX
    
  4. Save and exit the file.

Root Cause

  • Whenever the Client secret got rotated as per organization policy, it also needs to be updated in OpenShift, otherwise it will misbehave as OpenShift will not be able to communicate with Azure.

Diagnostic Steps

  • Below error message will be displayed in the cloud-credential-operators logs:

    Status Code = '401'. Response body: {"error":"invalid_client","error_description":"AADSTS7000222: The provided client secret keys are expired. Visit the Azure Portal to create new keys for your app, or consider using certificate credentials for added security.
    

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments