Accessing MCP by Using kubectl
kubectl can be used to configure resources such as Deployments of a specific MCP, as well as manage all MCP resources.
Prerequisites
If you select public network access, you must prepare an ECS that can connect to a public network.
Accessing MCP by Using kubectl
- Log in to the MCP console and click kubectl on the Dashboard page.
- Obtain the MCP access address and download the kubectl and its configuration file according to the instruction provided in Figure 1.
- Install and configure kubectl (A Linux OS is used as an example).
- Copy kubectl and its configuration file to the /home directory on your client.
- Log in to your client, and configure kubectl.
cd /home chmod +x kubectl mv -f kubectl /usr/local/bin mkdir -p $HOME/.kube mv -f kubeconfig.json $HOME/.kube/config
- Switch the kubectl access mode based on application scenarios.
- Run the following command to enable Internet access:
kubectl config use-context external
- Run the following command to enable intra-VPC access:
kubectl config use-context internal
This mode can be used only if you have already established an internal network connection.
- Run the following command to enable Internet access:
Deploying a Workload by Using kubectl
The following describes how to deploy a multi-cluster Nginx workload on different clusters.
- Access MCP by following the procedure described in Accessing MCP by Using kubectl.
- Query the clusters managed by MCP.
kubectl get clusters
- Create a Deployment.
kubectl create deployment nginx --image=nginx
- Create a propagation policy.
cat <<EOF | kubectl apply -f - apiVersion: policy.karmada.io/v1alpha1 kind: PropagationPolicy metadata: name: nginx-propagation spec: resourceSelectors: - apiVersion: apps/v1 kind: Deployment name: nginx placement: clusterAffinity: clusterNames: - cluster1 #Cluster name obtained in step 2 - cluster2 EOF
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot