Creating a context

The next step is to create a context. As we did in the preceding example, we'll need to set a user and cluster name for the context. If we don't specify those, the empty value will be set. The command to create a context is as follows:

$ kubectl config set-context <context_name> --namespace=<namespace_name> --cluster=<cluster_name> --user=<user_name>

Multiple contexts can be created in the same cluster. The following is an example of how to create a context for chapter5 in my GKE cluster, gke_devops-with-kubernetes_us-central1-b_cluster:

// create a context with my GKE cluster
# kubectl config set-context chapter5 --namespace=chapter5 --cluster=gke_devops-with-kubernetes_us-central1-b_cluster --user=gke_devops-with-kubernetes_us-central1-b_cluster
Context "chapter5" created.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset