minikube 安装
安装
luwei@luweideMacBook-Pro-2 mall-donglei % curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/amd64/kubectl"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 154 100 154 0 0 192 0 --:--:-- --:--:-- --:--:-- 192
100 50.6M 100 50.6M 0 0 644k 0 0:01:20 0:01:20 --:--:-- 524k
luwei@luweideMacBook-Pro-2 mall-donglei % chmod +x ./kubectl
luwei@luweideMacBook-Pro-2 mall-donglei % sudo mv ./kubectl /usr/local/bin/kubectl
Password:
luwei@luweideMacBook-Pro-2 mall-donglei % sudo chown root: /usr/local/bin/kubectl
luwei@luweideMacBook-Pro-2 mall-donglei % kubectl version --client
Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.4", GitCommit:"e6c093d87ea4cbb530a7b2ae91e54c0842d8308a", GitTreeState:"clean", BuildDate:"2022-02-16T12:38:05Z", GoVersion:"go1.17.7", Compiler:"gc", Platform:"darwin/amd64"}
查看节点
说明未安装 Minikube
luwei@luweideMacBook-Pro-2 mall-donglei % kubectl get nodes
The connection to the server localhost:8080 was refused - did you specify the right host or port?
luwei@luweideMacBook-Pro-2 mall-donglei % kubectl cluster-info
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
The connection to the server localhost:8080 was refused - did you specify the right host or port?
拉取 minikube
luwei@luweideMacBook-Pro-2 tmp % git clone https://github.com/kubernetes/minikube.git
Cloning into 'minikube'...
remote: Enumerating objects: 172661, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 172661 (delta 0), reused 1 (delta 0), pack-reused 172660
Receiving objects: 100% (172661/172661), 163.33 MiB | 5.15 MiB/s, done.
Resolving deltas: 100% (115564/115564), done.
Updating files: 100% (1487/1487), done.
luwei@luweideMacBook-Pro-2 tmp %
luwei@luweideMacBook-Pro-2 tmp %
luwei@luweideMacBook-Pro-2 tmp % ls
minikube
luwei@luweideMacBook-Pro-2 tmp % pwd
/Users/myself/tmp
luwei@luweideMacBook-Pro-2 tmp %
启动
luwei@luweideMacBook-Pro-2 mall-donglei % minikube start
😄 minikube v1.18.1 on Darwin 11.2.3
🎉 minikube 1.24.0 is available! Download it: https://github.com/kubernetes/minikube/releases/tag/v1.24.0
💡 To disable this notice, run: 'minikube config set WantUpdateNotification false'
✨ Automatically selected the docker driver. Other choices: hyperkit, virtualbox, ssh
👍 Starting control plane node minikube in cluster minikube
🔥 Creating docker container (CPUs=2, Memory=1985MB) ...
> kubeadm.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
> kubelet.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
> kubelet: 108.73 MiB / 108.73 MiB [-----------] 100.00% 1.16 MiB p/s 1m35s
▪ Generating certificates and keys ...
▪ Booting up control plane ...
▪ Configuring RBAC rules ...
🔎 Verifying Kubernetes components...
▪ Using image registry.cn-hangzhou.aliyuncs.com/google_containers/storage-provisioner:v4 (global image repository)
🌟 Enabled addons: storage-provisioner, default-storageclass
❗ /usr/local/bin/kubectl is version 1.23.4, which may have incompatibilites with Kubernetes 1.20.2.
▪ Want kubectl v1.20.2? Try 'minikube kubectl -- get pods -A'
🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
luwei@luweideMacBook-Pro-2 mall-donglei %
luwei@luweideMacBook-Pro-2 mall-donglei %
luwei@luweideMacBook-Pro-2 mall-donglei %
luwei@luweideMacBook-Pro-2 mall-donglei % kubectl cluster-info
Kubernetes control plane is running at https://127.0.0.1:60250
KubeDNS is running at https://127.0.0.1:60250/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
luwei@luweideMacBook-Pro-2 mall-donglei % kubectl cluster-info dump
{
"kind": "NodeList",
"apiVersion": "v1",
"metadata": {
"resourceVersion": "549"
},
启动 redis.yaml
luwei@luweideMacBook-Pro-2 mall-donglei % kubectl apply -f redis.yaml
Error from server (NotFound): error when creating "redis.yaml": namespaces "adhoc" not found
Error from server (NotFound): error when creating "redis.yaml": namespaces "adhoc" not found
Error from server (NotFound): error when creating "redis.yaml": namespaces "adhoc" not found
Error from server (NotFound): error when creating "redis.yaml": namespaces "adhoc" not found
luwei@luweideMacBook-Pro-2 mall-donglei %
解决报错
luwei@luweideMacBook-Pro-2 mall-donglei % kubectl create namespace adhoc
namespace/adhoc created
luwei@luweideMacBook-Pro-2 mall-donglei %
再次启动成功
luwei@luweideMacBook-Pro-2 mall-donglei % kubectl apply -f redis.yaml
deployment.apps/redis created
service/redis-svc created
horizontalpodautoscaler.autoscaling/redis-hpa-c created
horizontalpodautoscaler.autoscaling/redis-hpa-m created
luwei@luweideMacBook-Pro-2 mall-donglei %
查看
luwei@luweideMacBook-Pro-2 mall-donglei % kubectl get all -n adhoc
NAME READY STATUS RESTARTS AGE
pod/redis-6fd88ff795-mwnwj 1/1 Running 0 94s
pod/redis-6fd88ff795-rk9rz 1/1 Running 0 94s
pod/redis-6fd88ff795-xwn6l 1/1 Running 0 94s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/redis-svc ClusterIP 10.105.57.82 <none> 6379/TCP 94s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/redis 3/3 3 3 94s
NAME DESIRED CURRENT READY AGE
replicaset.apps/redis-6fd88ff795 3 3 3 94s
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
horizontalpodautoscaler.autoscaling/redis-hpa-c Deployment/redis <unknown>/80% 3 10 3 94s
horizontalpodautoscaler.autoscaling/redis-hpa-m Deployment/redis <unknown>/80% 3 10 3 93s
luwei@luweideMacBook-Pro-2 mall-donglei %
查看nodes
luwei@luweideMacBook-Pro-2 mall-donglei % kubectl get nodes
NAME STATUS ROLES AGE VERSION
minikube Ready control-plane,master 40m v1.20.2
luwei@luweideMacBook-Pro-2 mall-donglei %
本作品采用《CC 协议》,转载必须注明作者和本文链接