K8S(一)

minikube

minikube is local Kubernetes, focusing on making it easy to learn and develop for Kubernetes.

All you need is Docker (or similarly compatible) container or a Virtual Machine environment, and Kubernetes is a single command away: minikube start

To install the latest minikube stable release on x86-64 Linux using binary download:

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube

[xwl@VM-0-15-centos ~]$ curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 73.1M  100 73.1M    0     0  13.3M      0  0:00:05  0:00:05 --:--:-- 12.3M
[xwl@VM-0-15-centos ~]$ sudo install minikube-linux-amd64 /usr/local/bin/minikube
[xwl@VM-0-15-centos ~]$ minikube version
minikube version: v1.28.0
commit: 986b1ebd987211ed16f8cc10aed7d2c42fc8392f
[xwl@VM-0-15-centos ~]$ docker version
Client: Docker Engine - Community
 Version:           20.10.5
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        55c4c88
 Built:             Tue Mar  2 20:33:55 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.5
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       363e9a8
  Built:            Tue Mar  2 20:32:17 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
[xwl@VM-0-15-centos ~]$ minikube start
* minikube v1.28.0 on Centos 7.9.2009 (amd64)
* Automatically selected the docker driver. Other choices: ssh, none
* Using Docker driver with root privileges
* Starting control plane node minikube in cluster minikube
* Pulling base image ...
* Downloading Kubernetes v1.25.3 preload ...
    > preloaded-images-k8s-v18-v1...:  385.44 MiB / 385.44 MiB  100.00% 8.46 Mi
    > gcr.io/k8s-minikube/kicbase:  386.27 MiB / 386.27 MiB  100.00% 5.46 MiB p
    > gcr.io/k8s-minikube/kicbase:  0 B [________________________] ?% ? p/s 36s
* Creating docker container (CPUs=2, Memory=3900MB) ...
* Preparing Kubernetes v1.25.3 on Docker 20.10.20 ...
  - Generating certificates and keys ...
  - Booting up control plane ...
  - Configuring RBAC rules ...
* Verifying Kubernetes components...
  - Using image gcr.io/k8s-minikube/storage-provisioner:v5
* Enabled addons: storage-provisioner, default-storageclass
* kubectl not found. If you need it, try: 'minikube kubectl -- get pods -A'
* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

Dashboard

minikube has integrated support for the Kubernetes Dashboard UI.

The Dashboard is a web-based Kubernetes user interface. You can use it to:

  • deploy containerized applications to a Kubernetes cluster
  • troubleshoot your containerized application
  • manage the cluster resources
  • get an overview of applications running on your cluster
  • creating or modifying individual Kubernetes resources (such as Deployments, Jobs, DaemonSets, etc)

For example, you can scale a Deployment, initiate a rolling update, restart a pod or deploy new applications using a deploy wizard.

To access the dashboard:

minikube dashboard

If you don’t want to open a web browser, the dashboard command can also simply emit a URL:

minikube dashboard --url

kubectl

The Kubernetes command-line tool, kubectl, allows you to run commands against Kubernetes clusters. You can use kubectl to deploy applications, inspect and manage cluster resources, and view logs. For more information including a complete list of kubectl operations, see the kubectl reference documentation.

Use kubectl inside minikube

[xwl@VM-0-15-centos ~]$ alias kubectl=”minikube kubectl –“
[xwl@VM-0-15-centos ~]$ kubectl version
> kubectl.sha256: 64 B / 64 B [————————-] 100.00% ? p/s 0s
> kubectl: 42.93 MiB / 42.93 MiB [————] 100.00% 16.38 MiB p/s 2.8s
WARNING: This version information is deprecated and will be replaced with the output from kubectl version –short. Use –output=yaml|json to get the full version.
Client Version: version.Info{Major:”1″, Minor:”25″, GitVersion:”v1.25.3″, GitCommit:”434bfd82814af038ad94d62ebe59b133fcb50506″, GitTreeState:”clean”, BuildDate:”2022-10-12T10:57:26Z”, GoVersion:”go1.19.2″, Compiler:”gc”, Platform:”linux/amd64″}
Kustomize Version: v4.5.7
Server Version: version.Info{Major:”1″, Minor:”25″, GitVersion:”v1.25.3″, GitCommit:”434bfd82814af038ad94d62ebe59b133fcb50506″, GitTreeState:”clean”, BuildDate:”2022-10-12T10:49:09Z”, GoVersion:”go1.19.2″, Compiler:”gc”, Platform:”linux/amd64″}

[xwl@VM-0-15-centos ~]$ kubectl version –short
Flag –short has been deprecated, and will be removed in the future. The –short output will become the default.
Client Version: v1.25.3
Kustomize Version: v4.5.7
Server Version: v1.25.3

[xwl@VM-0-15-centos ~]$ kubectl get po -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-565d847f94-96ddg 1/1 Running 0 24m
kube-system etcd-minikube 1/1 Running 0 24m
kube-system kube-apiserver-minikube 1/1 Running 0 24m
kube-system kube-controller-manager-minikube 1/1 Running 0 24m
kube-system kube-proxy-phgl7 1/1 Running 0 24m
kube-system kube-scheduler-minikube 1/1 Running 0 24m
kube-system storage-provisioner 1/1 Running 1 (23m ago) 24m