In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Introduction: installing and enabling kubernetes on Windows is very helpful for developers who are new to Kubernetes.
Install Docker Desktop on Windows 10
Windows version of Docker Desktop is a community version, which you can download directly from Docker Hub. The download link is as follows:
Https://hub.docker.com/?overlay=onboarding
Note: when using stable version (2.1.0.5), Docker Desktop occasionally has a lifecycleserver timeout that does not start properly, while using Edge (2.1.7.0) version is normal.
System requirements:
1. Windows 10 64-bit, Professional Edition, Enterprise Edition, Education Edition (15063 or higher). It is recommended to download cn_windows_10_business_editions_version_1903_updated_sept_2019_x64_dvd_2f5281e1.iso (ed2k:// | file | cn_windows_10_business_editions_version_1903_updated_sept_2019_x64_dvd_2f5281e1.iso | 5231140864 | B1D5C4C401036B0B1EBA64476A95F338 | /) from msdn.
2. Hyper-V and windows container features must be enabled
Hardware requirements:
1. 64-bit processors that support SLAT (Second Level Address Translation)
2. 4GB or above memory
3. Hardware virtualization must be enabled in BIOS
Users who use Docker Toolbox and Docker Machine or Vmware need to know
Docker Desktop needs to install and enable Microsoft Hyper-V and restart your computer. When Hyper-V is enabled, VirtualBox or Vmware will no longer work properly. However, any existing virtual machine images are retained.
VirtualBox virtual machines created with docker-machine, including the default virtual machines created during the installation of Toolbox, will not start. These virtual machines cannot be used in conjunction with Docker Desktop. However, you can still use docker machine to manage vms.
Note: after you disable Hyper-V, you can still use VirtualBox and vmware normally.
Installing Docker Desktop will include the following
1. Docker engine, Docker CLI, Docker Compose, Docker Machine and Kitematic.
2. Containers and images created using Docker Desktop are shared among all user accounts on the computer where Docker Desktop is installed. This is because all Windows accounts use the same VM to build and run the container.
3. Nested virtualization scenarios, such as running Docker Desktop on VMWare or Parallels instances, may work properly, but there is no guarantee.
Note: for complete Docker compatibility information with the Windows server, see the Docker compatibility list (https://success.docker.com/article/compatibility-matrix).
Install Hyper-V and Containers
Click Control Panel-- > all Control panels-- > programs and Features-- > enable or disable Windows functionality, and check "Containers" and "Hyper-V", as shown in figure 1.1 below.
Figure 1.1
After installing Hyper-V, we will be prompted to restart the system. After restarting, we can see in the task manager that the virtualization of CPU is enabled in the performance menu, as shown in figure 1.2.
Figure 1.2
Install Docker Desktop
Next, start installing Docker Desktop, and double-click "Docker Desktop Installer" to start the installation, as shown in figure 1.3.
Figure 1.3
Press the default check box to complete the installation, as shown in figure 1.4.
Figure 1.4
About Windows Container
Use Windows containers instead of Linux containers (this can be changed after installation) indicates whether to replace the Linux container with the Windows container (this switching operation can also be switched after the software has been installed)
Switching between Windows and Linux containers describes how to switch between Linux and Windows containers in Docker Desktop (see https://docs.docker.com/docker-for-windows/#switch-between-windows-and-linux-containers).
Getting started with Windows containers provides tutorials on how to set up and run Windows containers on Windows 10, Windows Server 2016, and Windows Server 2019 (see https://github.com/docker/labs/blob/master/windows/windows-containers/README.md).
After the installation is complete, you will be prompted to log out of the current user and log in again, click "Close and log out", and after re-login, Docker Desktop will run automatically, which will take some time to complete the startup. During the startup process, you may be informed that the features of Hyper-V and Containers have not been enabled, ask whether it is enabled, as shown in figure 1.5, click "OK".
Figure 1.5
After Docker Desktop starts successfully, you should see the Docker icon in the system tray in the lower right corner of the computer, and the color is white (red indicates abnormal startup), as shown in figure 1.6. Then a dialog box will pop up to log in to Docker Hub, as shown in the following figure. If you have registered an account on Docker Hub, you can log in at this time, as shown in figure 1.7.
Figure 1.6
Figure 1.7
Right-click the docker icon in the system tray and click "About Docker Desktop" to get the version information of each component, as shown in figure 1.8.
Figure 1.8
Enable Kubernetes
Right-click the docker icon in the system tray, and in navigation, select "Settints", as shown in figure 1.9.
Figure 1.9
First of all, set the mirror source of Docker to daocloud to facilitate subsequent images to speed up the download, as shown in figure 1.10.
Figure 1.10
{
"registry-mirrors": ["http://f1361db2.m.daocloud.io"],"
"insecure-registries": []
"debug": true
"experimental": true
}
If we directly check and start kubernetes in Setttings, we will not be able to start successfully, because the image image used by Docker Desktop to initialize kubernetes is from foreign sources and cannot be downloaded successfully. Can be downloaded from https://github.com/AliyunContainerService/k8s-for-docker-desktop.
The current master branch defaults to version 1.15.5, and the Kubernetes version in the Docker Desktop we installed is 1.15.5, so after cloning, there is no need to checkout to other branches.
# git clone https://github.com/AliyunContainerService/k8s-for-docker-desktop.git
On Windows, use PowerShell to execute command commands, as shown in figure 1.11
.\ load_images.ps1
If you are prompted to prohibit running the script, first run PowerShell as an administrator, and execute the following command, press the "Y" key to confirm
Set-ExecutionPolicy-ExecutionPolicy
Figure 1.11
After the kubernetes image has been downloaded successfully, go to Docker Desktop's "Settings", select the check box marked "Enable Kubernetes", as shown in figure 1.12, and then click "Apply&Restart". Docker Desktop starts setting up and starting Kubernetes. When Kubernetes is started successfully, we can see "Kubernetes is running" and the status on the left is green, and you will know that everything has been completed successfully.
Figure 1.12
Configure the Kubernetes console
A Kubernetes without Web management interface is soulless for rookies.
Deploy Kubernetes dashboard
# kubectl apply-f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
Note: if you prompt "Unable to connect to the server...", you can execute it a few more times, or Wget it down through other ways, and then execute the command kubectl apply-f kubernetes-dashboard.yaml.
Open the API Server access agent (of course, we can also use NodePort to publish the port of Kubernetes dashboard, so there is no need to start kube proxy, the relevant settings will be explained in the Linux deployment version)
# kubectl proxy &
Access Kubernetes dashboard through the following URL, as shown in figure 1.13, and log in using kubeconfig.
Http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/overview?namespace=default
Figure 1.13
Login mode 1
Log in using the Kubeconfig file, which is located at: C:\ Users\ xxuser\ .kube\ config
Login mode 2
Configure the console token and log in using the token, as shown in figure 1.14
Figure 1.14
The method of creating and viewing access tokens is shown in figure 1.15.
PS C:\ Users\ tgh > kubectl get pods-n kube-system
NAME READY STATUS RESTARTS AGE
Coredns-5c98db65d4-gctdb 1/1 Running 0 122m
Coredns-5c98db65d4-kbvbt 1/1 Running 0 122m
Etcd-docker-desktop 1/1 Running 0 121m
Kube-apiserver-docker-desktop 1/1 Running 0 121m
Kube-controller-manager-docker-desktop 1/1 Running 0 120m
Kube-proxy-v6lln 1/1 Running 0 122m
Kube-scheduler-docker-desktop 1/1 Running 0 121m
Kubernetes-dashboard-7d75c474bb-znk76 1/1 Running 0 22m
$TOKEN= ((kubectl-n kube-system describe secret default | Select-String "token:")-split "+") [1]
Kubectl config set-credentials docker-for-desktop-- token= "${TOKEN}"
Echo $TOKEN
EyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkZWZhdWx0LXRva2VuLXN4azhyIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImRlZmF1bHQiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiIyZjZmZWZiYi05NGM3LTQ0NzAtYWNkOS1mNzE1NDBhZDNmN2IiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06ZGVmYXVsdCJ9.SeZDjaQsXdXyYyCh9hXqoAs93C9KXk766BfRBqy_E0u35uonHtLA6hezahMJUPJxcri1-cJHGhAACjTPZvhwq1hJnEQk2WHErh9DUlrcfSbEN0gQ5xxafhFa76praHHgpkRNZD0lgypfRzOtixwee3OPtMm2Jy_4nmwTr2lGAV-_Vu70VMutM1gk9QLVaBJS2NCDKoL_0z6JPqwpNbkIr3fsW8LWOVUSh2NNYbGlnKhjE9EnN_TbviXJpZQ4BUxgIA1IgbUZ9K6mch8Fp4Vawug_kxWu-ZhM21yK35I-cQ-FB7lRamdxhrr2nv8mRI5GX5_D74PbxUC98Uil3iUixA
Figure 1.15
Log in to the Kubernetes console successfully, as shown in figure 1.16.
Figure 1.16
To verify that Kubernetes is up and running, now create a text file called pod.yaml that contains the following:
ApiVersion: v1
Kind: Pod
Metadata:
Name: demo
Spec:
Containers:
-name: testpod
Image: alpine:3.5
Command: ["ping", "114.114.114.114"]
As shown in figure 1.17
Figure 1.17
This yaml configuration is used to create a pod, and there is only one container in the pod (1 copies) in which the ping command is executed.
Create the pod by executing the following command in Powershell.
Kubectl apply-f pod.yaml
Check to see if pod is running properly
# kubectl get pods
View pod Log
# kubectl logs demo
As shown in figure 1.18.
Figure 1.18
Finally, delete the pod, as shown in figure 1.19.
Figure 1.19
Then we can begin our journey to explore Kubernetes.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.