失效链接处理 |
Start Kubernetes The Beginner's Guide to Kubernetes PDF 下载
本站整理下载:
相关截图:
主要内容:
After you’ve installed one of these tools, make sure you download the Kubernetes CLI. Kubernetes
CLI is a single binary called kubectl, and it allows you to run commands against your cluster. To
make sure everything is working correctly, you can run kubectl get nodes to list all nodes in the
Kubernetes cluster. The output from the command should look like this:
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
docker-desktop Ready master 63d v1.16.6-beta.0
You can also check that the context is set correctly to docker-desktop. Kubernetes uses a
configuration file called config to find the information it needs to connect to the cluster. Kubernetes
CLI reads this file from your home folder - for example $HOME/.kube/config. Context is an element
inside that config file, and it contains a reference to the cluster, namespace, and the user. If you’re
accessing or running a single cluster, you will only have one context in the config file. However,
you can have multiple contexts defined that point to different clusters.
Using the kubectl config command, you can view these contexts and switch between them. You can
run the current-context command to view the current context:
$ kubectl config current-context
docker-desktop
There are other commands such as use-context, set-context, view-contexts, etc. I prefer to use a tool
called kubectx. This tool allows you to switch between different Kubernetes contexts quickly. For
example, if I have three clusters (contexts) set in the config file, running kubectx outputs this:
$ kubectx
docker-desktop
peterj-cluster
minikube
The tool highlights the currently selected context when you run the command. To switch to the
minikube context, I can run: kubectx minikube.
The equivalent commands you can run with kubectl would be kubectl config get-contexts to view
all contexts, and kubectl config use-context minikube to switch the context.
Before you continue, make sure your context is set to docker-desktop if you’re using Docker for
Mac/Windows or minikube if you’re using Minikube.
Let’s get started with your journey to Kubernetes and cloud-native world with the container
orchestration!
|