赞
踩
在Mac中安装了Docker之后,会自动安装了Kubernetes,正常情况下,我们只需要在Docker的Preferrences->Kubernetes中勾选Enable Kubernetes,然后点击Apply按钮即可。但由于伟大的墙的存在,这么一个简单的启动也会变得一波三折。
如果您是直接在Docker中启用Kubernetes,Kubernetes的状态会一直都是kubernetes is starting…,原因是有一些Kubernetes依赖的镜像不能正常的下载。
参考:http://www.fwhyy.com/2019/05/building-kubernetes-in-mac/
Github上有个开源项目可以帮我们手动拉取镜像,执行下面命令拉去改项目代码到本地
git clone https://github.com/maguowei/k8s-docker-for-mac
在Docker中修改镜像地址为国内,如下图:
在命令行进入到k8s-docker-for-mac目录,执行sh load_images.sh就可以拉去镜像了。
(base) lcc@lcc github$ git clone https://github.com/maguowei/k8s-docker-for-mac
Cloning into 'k8s-docker-for-mac'...
remote: Enumerating objects: 10, done.
remote: Counting objects: 100% (10/10), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 223 (delta 2), reused 7 (delta 2), pack-reused 213
Receiving objects: 100% (223/223), 850.63 KiB | 53.00 KiB/s, done.
Resolving deltas: 100% (83/83), done.
(base) lcc@lcc github$ cd k8s-docker-for-mac/
(base) lcc@lcc k8s-docker-for-mac$ sh load_images.sh
后来没搞定,还是用外网下载的才可以
验证集群状态
lcc@lcc ~$ kubectl cluster-info
Kubernetes master is running at https://kubernetes.docker.internal:6443
KubeDNS is running at https://kubernetes.docker.internal:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
(base) lcc@lcc ~$
(base) lcc@lcc ~$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
docker-desktop Ready master 3h32m v1.16.6-beta.0
(base) lcc@lcc ~$
查看详情
(base) lcc@lcc ~$ kubectl describe node Name: docker-desktop Roles: master Labels: beta.kubernetes.io/arch=amd64 beta.kubernetes.io/os=linux kubernetes.io/arch=amd64 kubernetes.io/hostname=docker-desktop kubernetes.io/os=linux node-role.kubernetes.io/master= Annotations: kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock node.alpha.kubernetes.io/ttl: 0 volumes.kubernetes.io/controller-managed-attach-detach: true CreationTimestamp: Mon, 18 May 2020 08:42:43 +0800 Taints: <none> Unschedulable: false Conditions: Type Status LastHeartbeatTime LastTransitionTime Reason Message ---- ------ ----------------- ------------------ ------ ------- MemoryPressure False Mon, 18 May 2020 12:15:02 +0800 Mon, 18 May 2020 08:42:38 +0800 KubeletHasSufficientMemory kubelet has sufficient memory available DiskPressure False Mon, 18 May 2020 12:15:02 +0800 Mon, 18 May 2020 08:42:38 +0800 KubeletHasNoDiskPressure kubelet has no disk pressure PIDPressure False Mon, 18 May 2020 12:15:02 +0800 Mon, 18 May 2020 08:42:38 +0800 KubeletHasSufficientPID kubelet has sufficient PID available Ready True Mon, 18 May 2020 12:15:02 +0800 Mon, 18 May 2020 08:42:38 +0800 KubeletReady kubelet is posting ready status Addresses: InternalIP: 192.168.65.3 Hostname: docker-desktop Capacity: cpu: 2 ephemeral-storage: 61255492Ki hugepages-1Gi: 0 hugepages-2Mi: 0 memory: 2039264Ki pods: 110 Allocatable: cpu: 2 ephemeral-storage: 56453061334 hugepages-1Gi: 0 hugepages-2Mi: 0 memory: 1936864Ki pods: 110 System Info: Machine ID: 01675cd8-892b-4dcd-8d18-f912f731d55c System UUID: d15a4cac-0000-0000-b965-c09f8687dea1 Boot ID: 426d1ee6-228a-42ff-bf5f-a6f245745104 Kernel Version: 4.19.76-linuxkit OS Image: Docker Desktop Operating System: linux Architecture: amd64 Container Runtime Version: docker://19.3.8 Kubelet Version: v1.16.6-beta.0 Kube-Proxy Version: v1.16.6-beta.0 Non-terminated Pods: (14 in total) Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits AGE --------- ---- ------------ ---------- --------------- ------------- --- docker compose-78f95d4f8c-548vm 0 (0%) 0 (0%) 0 (0%) 0 (0%) 3h31m docker compose-api-6ffb89dc58-65qkc 0 (0%) 0 (0%) 0 (0%) 0 (0%) 3h31m kube-system coredns-5644d7b6d9-db9gw 100m (5%) 0 (0%) 70Mi (3%) 170Mi (8%) 3h32m kube-system coredns-5644d7b6d9-j4wb9 100m (5%) 0 (0%) 70Mi (3%) 170Mi (8%) 3h32m kube-system etcd-docker-desktop 0 (0%) 0 (0%) 0 (0%) 0 (0%) 3h31m kube-system kube-apiserver-docker-desktop 250m (12%) 0 (0%) 0 (0%) 0 (0%) 3h31m kube-system kube-controller-manager-docker-desktop 200m (10%) 0 (0%) 0 (0%) 0 (0%) 3h31m kube-system kube-proxy-vnw6l 0 (0%) 0 (0%) 0 (0%) 0 (0%) 3h32m kube-system kube-scheduler-docker-desktop 100m (5%) 0 (0%) 0 (0%) 0 (0%) 3h31m kube-system kubernetes-dashboard-7c54d59f66-b7dvl 0 (0%) 0 (0%) 0 (0%) 0 (0%) 13m kube-system storage-provisioner 0 (0%) 0 (0%) 0 (0%) 0 (0%) 3h31m kube-system vpnkit-controller 0 (0%) 0 (0%) 0 (0%) 0 (0%) 3h31m kubernetes-dashboard dashboard-metrics-scraper-c79c65bb7-n7jjw 0 (0%) 0 (0%) 0 (0%) 0 (0%) 5m16s kubernetes-dashboard kubernetes-dashboard-56484d4c5-5z7dk 0 (0%) 0 (0%) 0 (0%) 0 (0%) 5m17s Allocated resources: (Total limits may be over 100 percent, i.e., overcommitted.) Resource Requests Limits -------- -------- ------ cpu 750m (37%) 0 (0%) memory 140Mi (7%) 340Mi (17%) ephemeral-storage 0 (0%) 0 (0%) Events: <none> (base) lcc@lcc ~$
(base) lcc@lcc kubernetes$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml namespace/kubernetes-dashboard created serviceaccount/kubernetes-dashboard created service/kubernetes-dashboard created secret/kubernetes-dashboard-certs created secret/kubernetes-dashboard-csrf created secret/kubernetes-dashboard-key-holder created configmap/kubernetes-dashboard-settings created role.rbac.authorization.k8s.io/kubernetes-dashboard created clusterrole.rbac.authorization.k8s.io/kubernetes-dashboard created rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created deployment.apps/kubernetes-dashboard created service/dashboard-metrics-scraper created deployment.apps/dashboard-metrics-scraper created (base) lcc@lcc kubernetes$ ll total 0 drwxr-xr-x 2 lcc staff 64 5 18 12:09 ./ drwxr-xr-x@ 43 lcc staff 1376 5 18 12:09 ../ (base) lcc@lcc kubernetes$ kubectl proxy --port=8080 Starting to serve on 127.0.0.1:8080
该文件默认位置在
(base) lcc@lcc kubernetes$ cat /System/Volumes/Data/Users/lcc/soft/kubernetes/kubernetes-dashboard.yaml
404: Not Found(base)
(base) lcc@lcc kubernetes$ cat kubernetes-dashboard.yaml
404: Not Found(base)
这个居然为空,先不管他。不过我感觉为空肯定会埋下炸弹
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。