Kubernetes-mac上安装docker以及k8s

Kubernetes-mac上安装docker以及k8s

    • 安装 Docker Desktop
    • 下载kubernetes镜像
    • 开启kubernetes
    • 使用 dashboard

mac电脑重做系统后,发现之前mac上安装k8s的方法已经失效,特写一篇博文记录下安装过程。

安装 Docker Desktop

下载 Docker Desktop 按提示进行安装。
这块不再赘述。
配置Docker镜像国内加速:
加入一行:“https://docker.mirrors.ustc.edu.cn”
也可选择其他源。
Kubernetes-mac上安装docker以及k8s_第1张图片

下载kubernetes镜像

由于国内被墙的缘故,可选择阿里云git这种方式下载k8s镜像,这里适配docker的k8s版本地址可以查看:
Kubernetes-mac上安装docker以及k8s_第2张图片
下载:
git clone -b v1.16.5 https://github.com/AliyunContainerService/k8s-for-docker-desktop.git
执行脚本下拉镜像:
./load_images.sh
查看:

 ~/k8s-for-docker-desktop   v1.16.5  docker images
REPOSITORY                                                       TAG                 IMAGE ID            CREATED             SIZE
k8s.gcr.io/kube-proxy                                            v1.16.5             0ee1b8a3ebe0        4 months ago        82.7MB
k8s.gcr.io/kube-apiserver                                        v1.16.5             fc838b21afbb        4 months ago        159MB
k8s.gcr.io/kube-controller-manager                               v1.16.5             441835dd2301        4 months ago        151MB
k8s.gcr.io/kube-scheduler                                        v1.16.5             b4d073a9efda        4 months ago        83.5MB
quay.io/kubernetes-ingress-controller/nginx-ingress-controller   0.26.1              29024c9c6e70        7 months ago        483MB
k8s.gcr.io/etcd                                                  3.3.15-0            b2756210eeab        8 months ago        247MB
k8s.gcr.io/coredns                                               1.6.2               bf261d157914        9 months ago        44.1MB
k8s.gcr.io/pause                                                 3.1                 da86e6ba6ca1        2 years ago         742kB

开启kubernetes

开启 Kubernetes,并等待 Kubernetes 开始运行
Kubernetes-mac上安装docker以及k8s_第3张图片
大概等待五分钟,就可以看到k8s是running状态了。

 ~  kubectl get nodes
NAME             STATUS   ROLES    AGE   VERSION
docker-desktop   Ready    master   19m   v1.16.6-beta.0
 ~  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'.

使用 dashboard

dashboard的yaml文件已经在git下来的仓库中
进入k8s-for-docker-desktop目录,执行:

kubectl create -f kubernetes-dashboard.yaml

查看状态:

kubectl get pod -n kubernetes-dashboard
NAME                                         READY   STATUS    RESTARTS   AGE
dashboard-metrics-scraper-7b8b58dc8b-zkh4l   1/1     Running   0          3m6s
kubernetes-dashboard-866f987876-v276r        1/1     Running   0          3m6s

开启代理:

 adson@huangs-MacBook-Air  ~/k8s-for-docker-desktop   v1.16.5  kubectl proxy
Starting to serve on 127.0.0.1:8001

之后通过http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/login就可以访问dashboard
这里选择token的方式登陆:
Kubernetes-mac上安装docker以及k8s_第4张图片
查看token,登陆:

 adson@huangs-MacBook-Air  ~  kubectl -n kube-system describe secret default| awk '$1=="token:"{print $2}'
eyJhbGciOiJSUzI1NiIsImtpZCI6IjFIOEJrdFB5Q3FldzFkV1FqZzRHc0xfVnFoTHQzWXBMUXY0aDQyaXozSTQifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkZWZhdWx0LXRva2VuLWZuaHZkIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImRlZmF1bHQiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiIyZDNiNWYzYS04MTJjLTQ2NGUtYmQ0ZC0wNzI1NWM3NTc2MjQiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06ZGVmYXVsdCJ9.R9_B1JNZC_UIsX9ZWb8IosF8UAvs-6bTOO24EbshEeSLLe-rSpX5Cqh85w-xhou1imxxBWtLCuq-FUN7oQUOfbNO91NFHcX_iXrqQDBXzSxNyapaSbSq5RAMul3vGOkQPq7ORtDUX8NJuHzQu7o4EBSfgqunveAmJaLEg20fMGZbnMStm728SEGdoXht5leHoXRdioCLS2XR4-mXTK6CXNnvkg0LAWZjUJqxf5D2AvXHqaXRDMI88EecGDMRwzD8IVhA0ak4CsYJ0EotiKHPGbX4oB2y-b2QH6dt1zdd-qDdGyBTv7ebI4SPDgosppg9CJrU57FPzwtFQ9zujII-UQ

Kubernetes-mac上安装docker以及k8s_第5张图片

你可能感兴趣的:(容器云,mac,docker,k8s)