-
Notifications
You must be signed in to change notification settings - Fork 111
https://issues.redhat.com/browse/ACM-20220 Access apiserver token doc #7951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
oafischer
wants to merge
13
commits into
2.14_stage
Choose a base branch
from
of-20220
base: 2.14_stage
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6418045
https://issues.redhat.com/browse/ACM-20220 Access apiserver token doc
oafischer 8aca8fb
https://issues.redhat.com/browse/ACM-20220 Access apiserver token doc
oafischer 1ee5ef7
https://issues.redhat.com/browse/ACM-20220 Access apiserver token doc
oafischer 7600f08
https://issues.redhat.com/browse/ACM-20220 Access apiserver token doc
oafischer d22beb3
Update mce_whats_new.adoc
oafischer 6d2dd73
Open https://issues.redhat.com/browse/ACM-20220 Access apiserver tok…
oafischer 5eca082
Open https://issues.redhat.com/browse/ACM-20220 Access apiserver tok…
oafischer 95540c0
https://issues.redhat.com/browse/ACM-20220 Access apiserver token doc
oafischer 2b4f6c1
https://issues.redhat.com/browse/ACM-20220 Access apiserver token doc
oafischer 90e2cd5
https://issues.redhat.com/browse/ACM-20220 Access apiserver token doc
oafischer d59cabd
https://issues.redhat.com/browse/ACM-20220 Access apiserver token doc
oafischer 7c9bbf2
https://issues.redhat.com/browse/ACM-20220 Access apiserver token doc
oafischer 0fdb72e
https://issues.redhat.com/browse/ACM-20220 Access apiserver token doc
oafischer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
clusters/cluster_lifecycle/cluster_proxy_addon_use.adoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
[#use-cluster-proxy-addon] | ||
= Using cluster proxy add-ons | ||
|
||
Use cluster proxy add-ons to access the managed cluster kube API server or managed cluster services by using different methods. See the following topics to learn more about the different ways you can use cluster proxy add-ons: | ||
|
||
* <<use-cluster-proxy-addon-prereq,Prerequisites>> | ||
* <<access-kube-apiserver-managed-token,Accessing the managed cluster `kube-apiserver` by using a managed cluster user token>> | ||
* <<access-kube-apiserver-hub-token,Accessing the managed cluster `kube-apiserver` by using a hub cluster user token>> | ||
* <<access-managed-cluster-services,Accessing managed cluster services>> | ||
|
||
*Required access:* Editor | ||
|
||
[#use-cluster-proxy-addon-prereq] | ||
== Prerequisites | ||
|
||
* You must xref:../cluster_proxy_addon_config#config-cluster-proxy-addon[enable cluster proxy add-ons]. | ||
|
||
[#access-kube-apiserver-managed-token] | ||
== Accessing the managed cluster `kube-apiserver` by using a managed cluster user token | ||
|
||
Use the cluster proxy add-on to list pods in the default namespace of a managed cluster by completing the following steps: | ||
|
||
. Export your cluster proxy URL by running the following command. Replace values where needed: | ||
|
||
+ | ||
[source,bash] | ||
---- | ||
export CLUSTER_PROXY_URL=https://$(oc get route -n multicluster-engine cluster-proxy-addon-user -o=jsonpath='{.spec.host}')/<managed-cluster-name> | ||
---- | ||
|
||
. Get the `ConfigMap` by running the following command: | ||
|
||
+ | ||
[source,bash] | ||
---- | ||
oc get configmap kube-root-ca.crt -o=jsonpath='{.data.ca\.crt}' > hub-ca.crt | ||
---- | ||
|
||
. Transfer your certificate authority (CA) certificate by running the following command: | ||
|
||
+ | ||
[source,bash] | ||
---- | ||
curl --cacert hub-ca.crt -H "Authorization: Bearer $TOKEN" https://$CLUSTER_PROXY_URL/api/v1/namespaces/default/pods | ||
---- | ||
+ | ||
*Note:* You need a user token that has permission to list pods in the default namespace of the managed cluster. | ||
|
||
[#access-kube-apiserver-hub-token] | ||
== Accessing the `kube-apiserver` of a managed cluster by using a hub cluster user token | ||
|
||
The target hub cluster and target managed cluster both need to use the same external identity provider so that both clusters can recognize the same user. | ||
|
||
To list pods in the default namespace by using the the hub cluster `developer` user token, you must first create the correct `Role` and `RoleBinding` for the `developer` on the managed cluster. | ||
|
||
If you are using {rhacm}, you can use the `ClusterPermission` API to create `Role` and `RoleBinding` objects from the hub cluster. | ||
|
||
See the following example that binds the `get` and `list` permissions for pods to the user `developer`: | ||
|
||
[source,yaml] | ||
---- | ||
apiVersion: rbac.open-cluster-management.io/v1alpha1 | ||
kind: ClusterPermission | ||
metadata: | ||
name: <name> | ||
namespace: <cluster-namespace> | ||
spec: | ||
roles: | ||
- namespace: default | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["pods"] | ||
verbs: ["get","list"] | ||
roleBindings: | ||
- namespace: default | ||
roleRef: | ||
kind: Role | ||
subject: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: User | ||
name: developer | ||
---- | ||
|
||
[#access-managed-cluster-services] | ||
== Accessing managed cluster services | ||
|
||
To access managed cluster services, the managed cluster must be an {ocp} cluster and the service must use the `services-serving-certificate` service to generate server certificates. | ||
|
||
Complete the following steps: | ||
|
||
. Get the Prometheus service token from the managed cluster. Run the following command: | ||
|
||
+ | ||
[source,bash] | ||
---- | ||
export PROMETHEUS_TOKEN=$(kubectl get secret -n openshift-monitoring $(kubectl get serviceaccount -n openshift-monitoring prometheus-k8s -o=jsonpath='{.secrets[0].name}') -o=jsonpath='{.data.token}' | base64 -d) | ||
---- | ||
|
||
. Get the Prometheus managed cluster metrics from the hub cluster. Run the following commands: | ||
|
||
+ | ||
[source,bash] | ||
---- | ||
export SERVICE_NAMESPACE=openshift-monitoring | ||
export SERVICE_NAME=prometheus-k8s | ||
export SERVICE_PORT=9091 | ||
export SERVICE_PATH="api/v1/query?query=machine_cpu_sockets" | ||
curl --cacert hub-ca.crt $CLUSTER_PROXY_URL/api/v1/namespaces/$SERVICE_NAMESPACE/services/$SERVICE_NAME:$SERVICE_PORT/proxy-service/$SERVICE_PATH -H "Authorization: Bearer $PROMETHEUS_TOKEN" | ||
---- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you need a
+
here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only needed when it comes after a step (
.
)