diff --git a/Documentation/CRDs/Cluster/external-cluster.md b/Documentation/CRDs/Cluster/external-cluster.md index 2dd19fedeab5..8a803fe33cab 100644 --- a/Documentation/CRDs/Cluster/external-cluster.md +++ b/Documentation/CRDs/Cluster/external-cluster.md @@ -127,7 +127,16 @@ export RGW_POOL_PREFIX=default 1. Paste the above output from `create-external-cluster-resources.py` into your current shell to allow importing the source data. -2. Run the [import](https://github.com/rook/rook/blob/master/deploy/examples/import-external-cluster.sh) script. +1. The import script in the next step uses the current kubeconfig context by + default. If you want to specify the kubernetes cluster to use without + changing the current context, you can specify the cluster name by setting + the KUBECONTEXT environment variable. + + ```console + export KUBECONTEXT=hub-cluster + ``` + +1. Run the [import](https://github.com/rook/rook/blob/master/deploy/examples/import-external-cluster.sh) script. !!! note If your Rook cluster nodes are running a kernel earlier than or equivalent to 5.4, remove diff --git a/deploy/examples/import-external-cluster.sh b/deploy/examples/import-external-cluster.sh index 241f53333244..fac910aa10e8 100644 --- a/deploy/examples/import-external-cluster.sh +++ b/deploy/examples/import-external-cluster.sh @@ -66,11 +66,17 @@ function checkEnvVars() { echo "Providing both ROOK_EXTERNAL_ADMIN_SECRET and ROOK_EXTERNAL_USER_SECRET is not supported, choose one only." exit 1 fi + if [ -n "$KUBECONTEXT" ]; then + echo "Using $KUBECONTEXT as the context value for kubectl commands" + KUBECTL="kubectl --context=$KUBECONTEXT" + else + KUBECTL="kubectl" + fi } function createClusterNamespace() { - if ! kubectl get namespace "$NAMESPACE" &>/dev/null; then - kubectl \ + if ! $KUBECTL get namespace "$NAMESPACE" &>/dev/null; then + $KUBECTL \ create \ namespace \ "$NAMESPACE" @@ -80,8 +86,8 @@ function createClusterNamespace() { } function createRadosNamespaceCR() { - if ! kubectl -n "$NAMESPACE" get CephBlockPoolRadosNamespace $RADOS_NAMESPACE &>/dev/null; then - cat </dev/null; then + cat </dev/null; then - cat </dev/null; then + cat </dev/null; then - kubectl -n "$NAMESPACE" \ + if ! $KUBECTL -n "$NAMESPACE" get secret "$MON_SECRET_NAME" &>/dev/null; then + $KUBECTL -n "$NAMESPACE" \ create \ secret \ generic \ @@ -147,8 +153,8 @@ function importSecret() { } function importConfigMap() { - if ! kubectl -n "$NAMESPACE" get configmap "$MON_ENDPOINT_CONFIGMAP_NAME" &>/dev/null; then - kubectl -n "$NAMESPACE" \ + if ! $KUBECTL -n "$NAMESPACE" get configmap "$MON_ENDPOINT_CONFIGMAP_NAME" &>/dev/null; then + $KUBECTL -n "$NAMESPACE" \ create \ configmap \ "$MON_ENDPOINT_CONFIGMAP_NAME" \ @@ -161,8 +167,8 @@ function importConfigMap() { } function importCsiRBDNodeSecret() { - if ! kubectl -n "$NAMESPACE" get secret "rook-$CSI_RBD_NODE_SECRET_NAME" &>/dev/null; then - kubectl -n "$NAMESPACE" \ + if ! $KUBECTL -n "$NAMESPACE" get secret "rook-$CSI_RBD_NODE_SECRET_NAME" &>/dev/null; then + $KUBECTL -n "$NAMESPACE" \ create \ secret \ generic \ @@ -176,8 +182,8 @@ function importCsiRBDNodeSecret() { } function importCsiRBDProvisionerSecret() { - if ! kubectl -n "$NAMESPACE" get secret "rook-$CSI_RBD_PROVISIONER_SECRET_NAME" &>/dev/null; then - kubectl -n "$NAMESPACE" \ + if ! $KUBECTL -n "$NAMESPACE" get secret "rook-$CSI_RBD_PROVISIONER_SECRET_NAME" &>/dev/null; then + $KUBECTL -n "$NAMESPACE" \ create \ secret \ generic \ @@ -191,8 +197,8 @@ function importCsiRBDProvisionerSecret() { } function importCsiCephFSNodeSecret() { - if ! kubectl -n "$NAMESPACE" get secret "rook-$CSI_CEPHFS_NODE_SECRET_NAME" &>/dev/null; then - kubectl -n "$NAMESPACE" \ + if ! $KUBECTL -n "$NAMESPACE" get secret "rook-$CSI_CEPHFS_NODE_SECRET_NAME" &>/dev/null; then + $KUBECTL -n "$NAMESPACE" \ create \ secret \ generic \ @@ -206,8 +212,8 @@ function importCsiCephFSNodeSecret() { } function importCsiCephFSProvisionerSecret() { - if ! kubectl -n "$NAMESPACE" get secret "rook-$CSI_CEPHFS_PROVISIONER_SECRET_NAME" &>/dev/null; then - kubectl -n "$NAMESPACE" \ + if ! $KUBECTL -n "$NAMESPACE" get secret "rook-$CSI_CEPHFS_PROVISIONER_SECRET_NAME" &>/dev/null; then + $KUBECTL -n "$NAMESPACE" \ create \ secret \ generic \ @@ -221,8 +227,8 @@ function importCsiCephFSProvisionerSecret() { } function importRGWAdminOpsUser() { - if ! kubectl -n "$NAMESPACE" get secret "$RGW_ADMIN_OPS_USER_SECRET_NAME" &>/dev/null; then - kubectl -n "$NAMESPACE" \ + if ! $KUBECTL -n "$NAMESPACE" get secret "$RGW_ADMIN_OPS_USER_SECRET_NAME" &>/dev/null; then + $KUBECTL -n "$NAMESPACE" \ create \ secret \ generic \ @@ -236,8 +242,8 @@ function importRGWAdminOpsUser() { } function createECRBDStorageClass() { - if ! kubectl -n "$NAMESPACE" get storageclass $RBD_STORAGE_CLASS_NAME &>/dev/null; then - cat </dev/null; then + cat </dev/null; then - cat </dev/null; then + cat </dev/null; then - cat </dev/null; then + cat <