|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * rosa_hcp/rosa-hcp-sts-creating-a-cluster-quickly.adoc |
| 4 | +// * rosa_hcp/rosa-hcp-sts-creating-a-cluster-ext-auth.adoc |
| 5 | + |
| 6 | +:_mod-docs-content-type: PROCEDURE |
| 7 | +[id="rosa-hcp-sts-creating-a-break-glass-cred-cli_{context}"] |
| 8 | += Creating a break glass credential for a {hcp-title} cluster |
| 9 | + |
| 10 | +As a {hcp-title} cluster owner, you can use the break glass credential to create temporary administrative client credentials to access your clusters that are configured with custom OpenID Connect (OIDC) token issuers. Creating a break glass credential generates a new cluster-admin `kubeconfig` file. The `kubeconfig` file contains information about the cluster that the CLI uses to connect a client to the correct cluster and API server. You can use the newly generated `kubeconfig` file to allow access to the {hcp-title} cluster. |
| 11 | + |
| 12 | +.Prerequisites |
| 13 | + |
| 14 | +* You have created a {hcp-title} cluster with external authentication enabled. For more information, see _Creating a {hcp-title} with HCP cluster that uses external authentication providers_. |
| 15 | +* You have created an external authentication provider. For more information, see _Creating an external authentication provider_. |
| 16 | +* You have an account with `cluster admin` permissions. |
| 17 | +
|
| 18 | +.Procedure |
| 19 | + |
| 20 | +. Create a break glass credential by using one of the following commands: |
| 21 | + |
| 22 | +** To create a break glass credential by using the interactive command interface to interactively specify custom settings, run the following command: |
| 23 | ++ |
| 24 | +[source,terminal] |
| 25 | +---- |
| 26 | +$ rosa create break-glass-credential -c <cluster_name> -i <1> |
| 27 | +---- |
| 28 | +<1> Replace <cluster_name> with the name of your cluster. |
| 29 | ++ |
| 30 | +This command starts an interactive CLI process: |
| 31 | ++ |
| 32 | +.Example output |
| 33 | +[source,terminal] |
| 34 | +---- |
| 35 | +I: Enabling interactive mode |
| 36 | +? Username (optional): <1> |
| 37 | +? Expiration duration (optional): <2> |
| 38 | +I: Successfully created a break glass credential for cluster 'ac-hcp-test'. |
| 39 | +---- |
| 40 | +<1> If left blank, the value in the `username` will have a randomly generated username value. |
| 41 | +<2> The minimum validity of the break glass credential is 10 minutes, and the maximum validity is 24 hours. If left blank, the expiration duration value defaults to 24 hours. |
| 42 | ++ |
| 43 | +** To create a break glass credential for cluster called `mycluster` with specified values: |
| 44 | ++ |
| 45 | +[source,terminal] |
| 46 | +---- |
| 47 | +$ rosa create break-glass-credential -c mycluster --username test-username --expiration 1h |
| 48 | +---- |
| 49 | ++ |
| 50 | +. List the break glass credential IDs, status, and associated users that are available for a cluster called `mycluster` by running the following command: |
| 51 | ++ |
| 52 | +[source,terminal] |
| 53 | +---- |
| 54 | +$ rosa list break-glass-credential -c mycluster |
| 55 | +---- |
| 56 | ++ |
| 57 | +.Example output |
| 58 | +[source,terminal] |
| 59 | +---- |
| 60 | +ID USERNAME STATUS |
| 61 | +2a7jli9n4phe6c02ul7ti91djtv2o51d test-user issued |
| 62 | +---- |
| 63 | ++ |
| 64 | +[NOTE] |
| 65 | +==== |
| 66 | +You can also view the credentials in a JSON output by adding the `-o json` argument to the command. |
| 67 | +==== |
| 68 | + |
| 69 | +. To view the status of a break glass credential, run the following command, replacing <break_glass_credential_id> with the break glass credential ID: |
| 70 | ++ |
| 71 | +[source,terminal] |
| 72 | +---- |
| 73 | +$ rosa describe break-glass-credential <break_glass_credential_id> -c <cluster_name> |
| 74 | +---- |
| 75 | ++ |
| 76 | +.Example output |
| 77 | +[source,terminal] |
| 78 | +---- |
| 79 | +ID: 2a7jli9n4phe6c02ul7ti91djtv2o51d |
| 80 | +Username: test-user |
| 81 | +Expire at: Dec 28 2026 10:23:05 EDT |
| 82 | +Status: issued |
| 83 | +---- |
| 84 | ++ |
| 85 | +The following is a list of possible `Status` field values: |
| 86 | ++ |
| 87 | +* `issued` The break glass credential has been issued and is ready to use. |
| 88 | +* `expired` The break glass credential has expired and can no longer be used. |
| 89 | +* `failed` The break glass credential has failed to create. In this case, you receive a service log detailing the failure. For more information about service logs, see _Accessing the service logs for Red Hat OpenShift Service on AWS clusters_. For steps to contact Red Hat Support for assistance, see _Getting support_. |
| 90 | +* `awaiting_revocation` The break glass credential is currently being revoked, meaning it cannot be used. |
| 91 | +* `revoked` The break glass credential has been revoked and can no longer be used. |
| 92 | ++ |
| 93 | +. To retrieve the `kubeconfig`, run the following commands: |
| 94 | +** Create a `kubeconfigs` directory: |
| 95 | ++ |
| 96 | +[source,terminal] |
| 97 | +---- |
| 98 | +$ mkdir ~/kubeconfigs |
| 99 | +---- |
| 100 | ++ |
| 101 | +** Export the newly generated `kubeconfig` file, replacing <cluster_name> with the name of your cluster: |
| 102 | ++ |
| 103 | +[source,terminal] |
| 104 | +---- |
| 105 | +$ export CLUSTER_NAME=<cluster_name> && export KUBECONFIG=~/kubeconfigs/break-glass-${CLUSTER_NAME}.kubeconfig |
| 106 | +---- |
| 107 | ++ |
| 108 | +** View the `kubeconfig`: |
| 109 | ++ |
| 110 | +[source,terminal] |
| 111 | +---- |
| 112 | +$ rosa describe break-glass-credential <break_glass_credential_id> -c mycluster --kubeconfig |
| 113 | +---- |
| 114 | +.Example output |
| 115 | ++ |
| 116 | +[source,terminal] |
| 117 | +---- |
| 118 | +apiVersion: v1 |
| 119 | +clusters: |
| 120 | +- cluster: |
| 121 | + server: <server_url> |
| 122 | + name: cluster |
| 123 | +contexts: |
| 124 | +- context: |
| 125 | + cluster: cluster |
| 126 | + namespace: default |
| 127 | + user: test-username |
| 128 | + name: admin |
| 129 | +current-context: admin |
| 130 | +kind: Config |
| 131 | +preferences: {} |
| 132 | +users: |
| 133 | +- name: test-user |
| 134 | + user: |
| 135 | + client-certificate-data: <client-certificate-data> <1> |
| 136 | + client-key-data: <client-key-data> <2> |
| 137 | +---- |
| 138 | +<1> The client-certificate contains a certificate for the user signed by the Kubernetes certificate authorities (CA). |
| 139 | +<2> The client-key contains the key that signed the client certificate. |
| 140 | ++ |
| 141 | +. Optional: To save the `kubeconfig`, run the following command : |
| 142 | ++ |
| 143 | +[source,terminal] |
| 144 | +---- |
| 145 | +$ rosa describe break-glass-credential <break_glass_credential_id> -c mycluster --kubeconfig > $KUBECONFIG |
| 146 | +---- |
| 147 | + |
| 148 | + |
| 149 | + |
| 150 | + |
| 151 | + |
| 152 | + |
| 153 | + |
0 commit comments