+ CLUSTER_NAME="o2dmsk8s1" # set the cluster name
+
+ K8S_SERVER=$(curl -k -s -X 'GET' \
+ "https://${OAM_IP}:30205/o2ims-infrastructureInventory/v1/deploymentManagers/${dmsID}?profile=native_k8sapi" \
+ -H 'accept: application/json' -H "Authorization: Bearer ${SMO_TOKEN_DATA}" \
+ | jq --raw-output '.["extensions"]["profileData"]["cluster_api_endpoint"]')
+ K8S_CA_DATA=$(curl -k -s -X 'GET' \
+ "https://${OAM_IP}:30205/o2ims-infrastructureInventory/v1/deploymentManagers/${dmsID}?profile=native_k8sapi" \
+ -H 'accept: application/json' -H "Authorization: Bearer ${SMO_TOKEN_DATA}" \
+ | jq --raw-output '.["extensions"]["profileData"]["cluster_ca_cert"]')
+
+ K8S_USER_NAME=$(curl -k -s -X 'GET' \
+ "https://${OAM_IP}:30205/o2ims-infrastructureInventory/v1/deploymentManagers/${dmsID}?profile=native_k8sapi" \
+ -H 'accept: application/json' -H "Authorization: Bearer ${SMO_TOKEN_DATA}" \
+ | jq --raw-output '.["extensions"]["profileData"]["admin_user"]')
+ K8S_USER_CLIENT_CERT_DATA=$(curl -k -s -X 'GET' \
+ "https://${OAM_IP}:30205/o2ims-infrastructureInventory/v1/deploymentManagers/${dmsID}?profile=native_k8sapi" \
+ -H 'accept: application/json' -H "Authorization: Bearer ${SMO_TOKEN_DATA}" \
+ | jq --raw-output '.["extensions"]["profileData"]["admin_client_cert"]')
+ K8S_USER_CLIENT_KEY_DATA=$(curl -k -s -X 'GET' \
+ "https://${OAM_IP}:30205/o2ims-infrastructureInventory/v1/deploymentManagers/${dmsID}?profile=native_k8sapi" \
+ -H 'accept: application/json' -H "Authorization: Bearer ${SMO_TOKEN_DATA}" \
+ | jq --raw-output '.["extensions"]["profileData"]["admin_client_key"]')
+
+ # If you do not want to set up the CA data, you can execute following command without the secure checking
+ # kubectl config set-cluster ${CLUSTER_NAME} --server=${K8S_SERVER} --insecure-skip-tls-verify
+
+ kubectl config set-cluster ${CLUSTER_NAME} --server=${K8S_SERVER}
+ kubectl config set clusters.${CLUSTER_NAME}.certificate-authority-data ${K8S_CA_DATA}
+
+ kubectl config set-credentials ${K8S_USER_NAME}
+ kubectl config set users.${K8S_USER_NAME}.client-certificate-data ${K8S_USER_CLIENT_CERT_DATA}
+ kubectl config set users.${K8S_USER_NAME}.client-key-data ${K8S_USER_CLIENT_KEY_DATA}
+
+ # set the context and use it
+ kubectl config set-context ${K8S_USER_NAME}@${CLUSTER_NAME} --cluster=${CLUSTER_NAME} --user ${K8S_USER_NAME}
+ kubectl config use-context ${K8S_USER_NAME}@${CLUSTER_NAME}
+
+ kubectl get ns # check the command working with this context
+
+ Now you can use “kubectl”, which means you set up a successfully
+ Kubernetes client. But, it uses the default admin user, so I
+ recommend you create an account for yourself.
+
+ Create a new user and account for K8S with a “cluster-admin” role.
+ And, set the token of this user to the base environment.