Skip to content

Commit 3aee02c

Browse files
authored
Making changes to step 9 in Manually join Hub and Spoke using AWS-based authentication document (open-cluster-management-io#786)
Signed-off-by: Amrutha <[email protected]>
1 parent 037aa3c commit 3aee02c

File tree

1 file changed

+13
-10
lines changed
  • solutions/joining-hub-and-spoke-with-aws-auth-manually

1 file changed

+13
-10
lines changed

solutions/joining-hub-and-spoke-with-aws-auth-manually/README.md

+13-10
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,20 @@ While the implementation of this feature is in progress, in the hub and spoke si
155155

156156
9. Generate the secret called `hub-kubeconfig-secret` in `open-cluster-management-agent` namespace using above kubeconfig:
157157
```shell
158-
HUB_KUBECONFIG=$(aws eks update-kubeconfig --name $HUB_CLUSTER_NAME --kubeconfig /awscli/kubeconfig.kubeconfig --role-arn arn:aws:iam::"$HUB_ACCOUNT_ID":role/$HUB_ROLE_NAME --dry-run)
158+
aws eks update-kubeconfig --name $HUB_CLUSTER_NAME --kubeconfig /awscli/kubeconfig.kubeconfig --role-arn arn:aws:iam::"$HUB_ACCOUNT_ID":role/$HUB_ROLE_NAME --dry-run > hub-kubeconfig
159159

160+
# Updating the clusterName to "hub" to make it same as bootstrap-kubeconfig
161+
# to pass a validation in ocm. Install yq, if missing.
162+
# Note - The yq command works only on a Linux machine. Please use a text editor to manually replace the values otherwise.
163+
NEW_CLUSTER_NAME="hub"
164+
yq eval "
165+
(.clusters[].name = \"${NEW_CLUSTER_NAME}\") |
166+
(.contexts[].context.cluster = \"${NEW_CLUSTER_NAME}\") |
167+
del(.users[].user.exec.env)
168+
" -i "hub-kubeconfig"
169+
170+
HUB_KUBECONFIG=$(cat hub-kubeconfig)
171+
160172
AGENT_NAME_ENCODED=$(kubectl get klusterlet klusterlet -o jsonpath='{.metadata.uid}' | tr -d '\n' | base64 | tr -d '\n')
161173
SPOKE_CLUSTER_NAME_ENCODED=$(echo -n "$SPOKE_CLUSTER_NAME" | base64 | tr -d '\n')
162174
HUB_KUBECONFIG_ENCODED=$(echo -n "$HUB_KUBECONFIG" | base64 | tr -d '\n')
@@ -166,15 +178,6 @@ While the implementation of this feature is in progress, in the hub and spoke si
166178
-e "s|\${SPOKE_CLUSTER_NAME_ENCODED}|$SPOKE_CLUSTER_NAME_ENCODED|g" \
167179
-e "s|\${HUB_KUBECONFIG_ENCODED}|$HUB_KUBECONFIG_ENCODED_ESCAPED|g" \
168180
templates/Template-hub-kubeconfig-secret.yaml > hubKubeconfigSecret.yaml
169-
170-
# Updating the clusterName to "hub" to make it same as bootstrap-kubeconfig
171-
# to pass a validation in ocm. Install yq, if missing, for following command
172-
NEW_CLUSTER_NAME="hub"
173-
yq eval "
174-
(.clusters[].name = \"${NEW_CLUSTER_NAME}\") |
175-
(.contexts[].context.cluster = \"${NEW_CLUSTER_NAME}\") |
176-
del(.users[].user.exec.env)
177-
" -i "hubKubeconfigSecret.yaml"
178181

179182
kubectl apply -f hubKubeconfigSecret.yaml
180183
```

0 commit comments

Comments
 (0)