This is the fourth day of my participation in Gwen Challenge

Everything starts with installation!

Learning a new technology usually starts with installation, actually installing it, using it, and learning more.

In order to facilitate the development, learning and experience of Kubernetes, Kubernetes community provides a local deployment of minikube, through the minikube way can run Kubernetes locally.

Kubernetes deployment mode there are many, this article is based on the local development environment deployment mode, learn it enough. It is not easy to deploy a cluster for a production environment, which will be covered in other chapters.)

1, Minikube

Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes cluster on a virtual machine on your computer for users to use or perform daily Kubernetes development on.

Features:

Minikube runs the latest stable version of Kubernetes and supports standard Kubernetes features such as:

  • Load balancing:useminikube tunnel
  • Multiple clusters:useminikube start -p <name>
  • NodePorts:useminikube service
  • Persistent volume
  • Ingress
  • Dashboard:Instrument panel, useminikube dashboardStart.

2, installation,

You can install it on a local VM.

Due to network access, many friends cannot install minikube directly. In the latest Minikube, the configuration method has been provided to help you use ali Cloud image address to obtain the required Docker image and configuration.

2.1 installation kubectl

Kubectl is a command line tool for managing Kubernetes. You can check cluster resources, create, delete, and update components, view your new cluster, and launch instance applications.

(1) Use domestic Ali Yunyuan installation

[xcbeyond@localhost ~]$ curl -LO http://kubernetes.oss-cn-hangzhou.aliyuncs.com/kubernetes-release/release/`curl -s http://kubernetes.oss-cn-hangzhou.aliyuncs.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/kubectl
Copy the code

(2) View the version

After the installation is complete, run the kubectl version command to check the version and check whether the installation is successful.

[xcbeyond@localhost ~]$ kubectl version Client Version: Version. The Info {Major: "1", Minor: "19", GitVersion: "v1.19.2 GitCommit:" f5743093fd1c663cb0cbc89748f730662345d44d." BuildDate GitTreeState: "clean" : "the 2020-09-16 T13:41:02 Z," GoVersion: "go1.15", the Compiler: "gc", Platform:"linux/amd64"} Server Version: Version. The Info {Major: "1", Minor: "19", GitVersion: "v1.19.0 GitCommit:" e19964183377d0ec2052d1f1fa930c4d7575bd50." GitTreeState:"clean", BuildDate:" 2020-08-26T14:23:04z ", GoVersion:" GO1.15 ", Compiler:" GC ", Platform:" Linux/AMD64 "}Copy the code

2.2 installation minikube

Minikube is an implementation of a local Kubernetes cluster. Minikube’s main goal is to become the best tool for local Kubernetes development and support for all features of Kubernetes. Use to run a single-node Kubernetes cluster on a virtual machine in your computer.

(1) Use domestic Ali Yunyuan installation

[xcbeyond@localhost ~]$ curl -Lo minikube https://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/v1.13.0/minikube-linux-amd64 && chmod + x minikube && sudo mv minikube /usr/local/bin/Copy the code

(2) Installation and start

You can start the local Kubernetes cluster by running the command minikube start.

To access overseas resources, Aliyun provides a series of infrastructures. Configure the following parameters. Common parameters:

  • — Driver =*** : Starting with version 1.5.0, Minikube defaults to using the best local drivers to create Kubernetes local environments, tested versions of Docker, KVM

  • – image – mirror – country cn: install the default using registry.cn-hangzhou.aliyuncs.com/google_containers as containers of Kubernetes mirror warehouse ali cloud version (optional)

  • — ISo-url =*** : Use ali cloud image address to download the corresponding. Iso file (Ali cloud version optional)

  • –registry-mirror=*** : To pull the Docker Hub image, you need to configure image acceleration for the Docker Daemon. See Aliyun Image Service

  • –cpus=2: specifies the number of CPU cores allocated to the MINIkube VM

  • –memory=2048mb: specifies the amount of memory allocated to the minikube vm

  • –kubernetes-version=*** : Minikube version of Kubernetes that the VIRTUAL machine will use

Start the minikube:

You need to download the image for the first startup. You need to be patient.

If the command fails, run the command again.

[xcbeyond@localhost ~]$minikube start --driver=docker * Centos 7.8.2003 minikube V1.13.0 * Use the docker driver according to the existing configuration file *  Starting control plane node minikube in cluster minikube * Pulling base image ... * Creating docker container (CPUs=2, Memory=2200MB) ... * Preparing Kubernetes V1.19.0 in Docker 19.03.8... > kubectl. Sha256:65 B / 65 B [-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -] 100.00%? P/s > 0 s kubelet. Sha256:65 B / 65 B [-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -] 100.00%? P/s > 0 s kubeadm. Sha256:65 B / 65 B [-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -] 100.00%? P /s 0s > kubectl: 41.01 MiB / 41.01 MiB [-----------] 100.00% 496.18kib P /s 1m24s > kubeadm: MiB / 37.30 37.30 MiB [-- -- -- -- -- -- -- -- -- -- -- -- -- -- -] 100.00% 3.15 MiB p/s 12 s > kubelet: 104.88 MiB / 104.88 MiB [-------------] 100.00% 3.34 MiB P /s 32s * Verifying Kubernetes components... * Enabled addons: default-storageclass, storage-provisioner * Done! kubectl is now configured to use "minikube" by defaultCopy the code

(3) Open Kubernetes console

When you run the minikube dashboard command locally (within the virtual machine desktop), the Kubernetes console will be automatically opened in the browser.

(If you use shell to remotely log in to the cli, an error message is displayed indicating that the browser fails to open the cli. You can ignore this error.)

[xcbeyond@localhost ~]$minikube dashboard 🤔 Verifying Dashboard operation... 🚀 Launching proxy... 🤔 verifying proxy health... 🎉 Opening in http://127.0.0.1:38620/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ your default browser... This tool has been deprecated, use 'gio open' instead. See 'gio help open' for more info.Copy the code

How can it be accessed externally? You just need to add a layer of agents.

Run the following command to proxy the vm to the specified port:

Kubectl proxy --port=< specified access port > --address=< actual IP> --accept-hosts='^.*' &Copy the code

Such as:

xcbeyond@localhost ~]$kubectl proxy --port=8001 --address='192.168.11.129' --accept-hosts='^.*' & [1] 83066 [xcbeyond@localhost ~]$Starting to serve on 192.168.11.129:8001Copy the code

Browser address: http://192.168.11.129:8001/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/#/overview? namespace=default

Now, explore the world of Kubernetes!

Reference article:

  1. Developer.aliyun.com/article/221…

  2. Kubernetes. IO/useful/docs/tas…