目录
Docker安装
1.brew安装docker
2.如果安装成功就点击启动里面的docker图标进入到如下操作。
Docker安装可能碰到的问题:
K8S安装
1.拉取安装代码
?2.加载docker镜像
3.然后进入到 docker的设置页面
?4.安装dashboad
5.启动代理
6.获取秘钥登录
7.访问管理地址
Docker安装
1.brew安装docker
ruishens-MacBook-Pro:docker ruishen$ brew install --cask --appdir=/Applications docker
==> Downloading https://desktop.docker.com/mac/main/amd64/69879/Docker.dmg
######################################################################## 100.0%
==> Installing Cask docker
==> Moving App 'Docker.app' to '/Applications/Docker.app'
==> Linking Binary 'docker-compose.bash-completion' to '/usr/local/etc/bash_completion.d/docker-compose'
==> Linking Binary 'docker.zsh-completion' to '/usr/local/share/zsh/site-functions/_docker'
==> Linking Binary 'docker.fish-completion' to '/usr/local/share/fish/vendor_completions.d/docker.fish'
==> Linking Binary 'docker-compose.fish-completion' to '/usr/local/share/fish/vendor_completions.d/docker-compose.fish'
==> Linking Binary 'docker-compose.zsh-completion' to '/usr/local/share/zsh/site-functions/_docker_compose'
==> Linking Binary 'docker.bash-completion' to '/usr/local/etc/bash_completion.d/docker'
docker was successfully installed!
ruishens-MacBook-Pro:docker ruishen$
2.如果安装成功就点击启动里面的docker图标进入到如下操作。
在接下来有个入门级 的引导使用
上边安装参考:MacOS Docker 安装 | 菜鸟教程
Docker安装可能碰到的问题:
执行?brew install 抱错
?
ruishens-MacBook-Pro:docker ruishen$ brew install --cask --appdir=/Applications docker
Error:
??homebrew-core is a shallow clone.
??homebrew-cask is a shallow clone.
To `brew update`, first run:
??git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
??git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
These commands may take a few minutes to run due to the large size of the repositories.
This restriction has been made on GitHub's request because updating shallow
clones is an extremely expensive operation due to the tree layout and traffic of
Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
automatically to avoid repeatedly performing an expensive unshallow operation in
CI systems (which should instead be fixed to not use shallow clones). Sorry for
the inconvenience!
==> Downloading https://desktop.docker.com/mac/stable/amd64/65384/Docker.dmg
######################################################################## 100.0%
Error: SHA256 mismatch
Expected: 55e036c4c078a0d1e357d487e7c1a5f13762bfaebace0f9a363ab45f523a828e
??Actual: ded6aab91f0d77e2c7420f429462086fc90f3805ff723a65c029a40535de004c
????File: /Users/ruishen/Library/Caches/Homebrew/downloads/491180351d0f0034d8b727b3a09b70027b84dc6ad7ccafa8aef31198b7706159--Docker.dmg
To retry an incomplete download, remove the file above.
ruishens-MacBook-Pro:docker ruishen$
?
?参考:https://ld246.com/article/1612446591942 ?执行删除即可。
ruishens-MacBook-Pro:docker ruishen$ rm -rf /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
ruishens-MacBook-Pro:docker ruishen$ rm -rf /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask
ruishens-MacBook-Pro:docker ruishen$
执行update操作
ruishens-MacBook-Pro:docker ruishen$ brew update
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 1074126, done.
remote: Counting objects: 100% (5719/5719), done.
remote: Compressing objects: 100% (397/397), done.
remote: Total 1074126 (delta 5401), reused 5572 (delta 5322), pack-reused 1068407
Receiving objects: 100% (1074126/1074126), 408.03 MiB | 3.11 MiB/s, done.
Resolving deltas: 100% (739246/739246), done.
Updating files: 100% (6190/6190), done.
Tapped 2 commands and 5877 formulae (6,201 files, 450.0MB).
Already up-to-date.
ruishens-MacBook-Pro:docker ruishen$
注意要是网不好,可能失败
手工安装cask模块
ruishens-MacBook-Pro:docker ruishen$ brew install caskroom/cask/brew-cask
Error: caskroom/cask was moved. Tap homebrew/cask instead.
ruishens-MacBook-Pro:docker ruishen$ brew install caskroom/casbrew cask searchk/brew-cask
ruishens-MacBook-Pro:docker ruishen$ brew cask search
Error: Unknown command: cask
ruishens-MacBook-Pro:docker ruishen$ brew tap homebrew/cask
Updating Homebrew...
==> Tapping homebrew/cask
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask'...
remote: Enumerating objects: 599962, done.
remote: Counting objects: 100% (270/270), done.
remote: Compressing objects: 100% (154/154), done.
remote: Total 599962 (delta 134), reused 246 (delta 116), pack-reused 599692
Receiving objects: 100% (599962/599962), 267.96 MiB | 1.52 MiB/s, done.
Resolving deltas: 100% (424005/424005), done.
Tapped 3940 casks (4,021 files, 287.2MB).
K8S安装
1.拉取安装代码
git clone https://github.com/gotok8s/k8s-docker-desktop-for-mac.git
?2.加载docker镜像
进入到刚才拉取的目录
ruishens-MacBook-Pro:k8s-docker-desktop-for-mac ruishen$ ./load_images.sh
images found.
v1.21.5: Pulling from gotok8s/kube-proxy
fe5d561940df: Pull complete
40c307f83de6: Pull complete
Digest: sha256:d74589846c98d715da65e36d78c2d3393a3e838f944d2b63831c74932ea41953
Status: Downloaded newer image for gotok8s/kube-proxy:v1.21.5
docker.io/gotok8s/kube-proxy:v1.21.5
Untagged: gotok8s/kube-proxy:v1.21.5
Untagged: gotok8s/kube-proxy@sha256:d74589846c98d715da65e36d78c2d3393a3e838f944d2b63831c74932ea41953
v1.21.5: Pulling from gotok8s/kube-controller-manager
b49b96595fd4: Pull complete
8342ce73f773: Pull complete
661410539ca4: Pull complete
Digest: sha256:d9efa3d5179e044f19b102d0a4b6b76bb77f3be3baa38c1b0d71d314e18d49aa
Status: Downloaded newer image for gotok8s/kube-controller-manager:v1.21.5
docker.io/gotok8s/kube-controller-manager:v1.21.5
Untagged: gotok8s/kube-controller-manager:v1.21.5
Untagged: gotok8s/kube-controller-manager@sha256:d9efa3d5179e044f19b102d0a4b6b76bb77f3be3baa38c1b0d71d314e18d49aa
v1.21.5: Pulling from gotok8s/kube-scheduler
b49b96595fd4: Already exists
8342ce73f773: Already exists
723dba3b6b85: Pull complete
Digest: sha256:18b9a029502a0c065616f2f2a10545719385a6aa63ba1bf8eac4153b271b203b
Status: Downloaded newer image for gotok8s/kube-scheduler:v1.21.5
docker.io/gotok8s/kube-scheduler:v1.21.5
Untagged: gotok8s/kube-scheduler:v1.21.5
Untagged: gotok8s/kube-scheduler@sha256:18b9a029502a0c065616f2f2a10545719385a6aa63ba1bf8eac4153b271b203b
v1.21.5: Pulling from gotok8s/kube-apiserver
b49b96595fd4: Already exists
8342ce73f773: Already exists
208ac02c9e03: Pull complete
Digest: sha256:8791213e0325b87c4c2208d85a7f89ddf44e55f6e82874557701f20865c0e72a
Status: Downloaded newer image for gotok8s/kube-apiserver:v1.21.5
docker.io/gotok8s/kube-apiserver:v1.21.5
Untagged: gotok8s/kube-apiserver:v1.21.5
Untagged: gotok8s/kube-apiserver@sha256:8791213e0325b87c4c2208d85a7f89ddf44e55f6e82874557701f20865c0e72a
v1.8.0: Pulling from gotok8s/coredns
c6568d217a00: Pull complete
5984b6d55edf: Pull complete
Digest: sha256:10ecc12177735e5a6fd6fa0127202776128d860ed7ab0341780ddaeb1f6dfe61
Status: Downloaded newer image for gotok8s/coredns:v1.8.0
docker.io/gotok8s/coredns:v1.8.0
Untagged: gotok8s/coredns:v1.8.0
Untagged: gotok8s/coredns@sha256:10ecc12177735e5a6fd6fa0127202776128d860ed7ab0341780ddaeb1f6dfe61
3.4.1: Pulling from gotok8s/pause
fac425775c9d: Pull complete
Digest: sha256:9ec1e780f5c0196af7b28f135ffc0533eddcb0a54a0ba8b32943303ce76fe70d
Status: Downloaded newer image for gotok8s/pause:3.4.1
docker.io/gotok8s/pause:3.4.1
Untagged: gotok8s/pause:3.4.1
Untagged: gotok8s/pause@sha256:9ec1e780f5c0196af7b28f135ffc0533eddcb0a54a0ba8b32943303ce76fe70d
3.4.13-0: Pulling from gotok8s/etcd
4000adbbc3eb: Pull complete
d72167780652: Pull complete
d60490a768b5: Pull complete
4a4b5535d134: Pull complete
0dac37e8b31a: Pull complete
Digest: sha256:bd4d2c9a19be8a492bc79df53eee199fd04b415e9993eb69f7718052602a147a
Status: Downloaded newer image for gotok8s/etcd:3.4.13-0
docker.io/gotok8s/etcd:3.4.13-0
Untagged: gotok8s/etcd:3.4.13-0
Untagged: gotok8s/etcd@sha256:bd4d2c9a19be8a492bc79df53eee199fd04b415e9993eb69f7718052602a147a
ruishens-MacBook-Pro:k8s-docker-desktop-for-mac ruishen$
3.然后进入到 docker的设置页面
选中 ? enable ?kubernetes 。然后apply && restart
稍等几分钟,ok了。
?4.安装dashboad
接下来安装dashboad,
1.recommended.yaml文件
安装recommended.yaml文件时,如果下载不下来官方的,自己手工编辑一个复制下边地址内容? https://www.yht7.com/news/102739
ruishens-MacBook-Pro:k8s-docker-desktop-for-mac ruishen$ kubectl apply -f 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/kubernetes-metrics-scraper created
ruishens-MacBook-Pro:k8s-docker-desktop-for-mac ruishen$
2.kubernetes-dashboard.yaml 文件
下载不下来,参考下边这个?www.jianshu.com/p/d0a01ff39c82
ruishens-MacBook-Pro:k8s-docker-desktop-for-mac ruishen$ kubectl apply -f kubernetes-dashboard.yaml
secret/kubernetes-dashboard-certs created
serviceaccount/kubernetes-dashboard created
role.rbac.authorization.k8s.io/kubernetes-dashboard-minimal created
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard-minimal created
deployment.apps/kubernetes-dashboard created
service/kubernetes-dashboard created
ruishens-MacBook-Pro:k8s-docker-desktop-for-mac ruishen$
5.启动代理
?kubectl proxy >proxy.log?&
ruishens-MacBook-Pro:k8s-docker-desktop-for-mac ruishen$ Starting to serve on 127.0.0.1:8001
6.获取秘钥登录
取下边的token信息
ruishens-MacBook-Pro:k8s-docker-desktop-for-mac ruishen$ kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep kubernetes-dashboard-admin | awk '{print $1}')
Name: default-token-z4hz5
Namespace: kubernetes-dashboard
Labels: <none>
Annotations: kubernetes.io/service-account.name: default
kubernetes.io/service-account.uid: 793deb85-f5c7-4796-b9d9-9b0b3ac7a420
Type: kubernetes.io/service-account-token
Data
====
token: eyJhbGciOiJSUzI1NiIsImtpZCI6InVEc3E0RnBqeEt5Ylo4NVE0QUYyYkRtUGZZcFE1bmk0N1dJMkhha2NKeEEifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkZWZhdWx0LXRva2VuLXo0aHo1Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImRlZmF1bHQiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiI3OTNkZWI4NS1mNWM3LTQ3OTYtYjlkOS05YjBiM2FjN2E0MjAiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZXJuZXRlcy1kYXNoYm9hcmQ6ZGVmYXVsdCJ9.1X_PoLB8JLk1h41O4hGOictGspTRZc_7HuuglWOVOERc9OMXVSejomRUR7ijp7XT5N3Bhi0w3TbaQqbPug4nN2yd6EQJ_KI9OYXSWMOxnKNNJtjNzmqr16Tl16zyszDh_yM9kcm2al4qH8GrI6maELj3WqyS3jmGcCrpS8fcSZPh7eVgLHvAnA8nHTj5c3ju2ZiX7p3i2ZIeMPIYwDBgESJxkEs3VvyumQZQGkgLqoJrHR4VUWqgyhyNdHZTLx7IYMmDMsZOagXfmryOEBk-f8BCd7qYOmbRhhvUernXiZf2TP9IO9OBGkuDTqAvhYSQxYtQ7tyzyXjm_pYDVTe03A
ca.crt: 1066 bytes
namespace: 20 bytes
Name: kubernetes-dashboard-certs
Namespace: kubernetes-dashboard
Labels: k8s-app=kubernetes-dashboard
Annotations: <none>
Type: Opaque
Data
====
Name: kubernetes-dashboard-csrf
Namespace: kubernetes-dashboard
Labels: k8s-app=kubernetes-dashboard
Annotations: <none>
Type: Opaque
Data
====
csrf: 256 bytes
Name: kubernetes-dashboard-key-holder
Namespace: kubernetes-dashboard
Labels: <none>
Annotations: <none>
Type: Opaque
Data
====
pub: 459 bytes
priv: 1675 bytes
Name: kubernetes-dashboard-token-8vfpv
Namespace: kubernetes-dashboard
Labels: <none>
Annotations: kubernetes.io/service-account.name: kubernetes-dashboard
kubernetes.io/service-account.uid: a7b195c4-a779-49dd-932a-b079e0fe2d99
Type: kubernetes.io/service-account-token
Data
====
ca.crt: 1066 bytes
namespace: 20 bytes
token: eyJhbGciOiJSUzI1NiIsImtpZCI6InVEc3E0RnBqeEt5Ylo4NVE0QUYyYkRtUGZZcFE1bmk0N1dJMkhha2NKeEEifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZC10b2tlbi04dmZwdiIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6ImE3YjE5NWM0LWE3NzktNDlkZC05MzJhLWIwNzllMGZlMmQ5OSIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlcm5ldGVzLWRhc2hib2FyZDprdWJlcm5ldGVzLWRhc2hib2FyZCJ9.hbetMgUqBiKGhmNQBhe6idJ-EGyyoWJ4uR-IGtm7v9AsuUZxIe-JsXOCJIKdy4y4vEJhULoTtrRznhw7cnXEVYYdr0T66VgtsYCKK0wK3Q_GnK9AAAmabPOp6c0HegrsaxjUulLWOI2-cVAMFICXVqtOxr_3dgp64HbBaZaQRdntgo0sZQ214CK5Xeu0SncvkiDfbZLDVf4Ha9SkJuz9fLQHOuNcN76NPEtqsCGHMDK-xSTtDE1KQOzdRZ0alQel6095tELYmEfXYTC6rZ8KX_4dzGyRx863ZzC-6s-LNRZUZqpKbhSMeZqRrnY2DwPWL_1I7XH2on0RVraWXFwKCg
ruishens-MacBook-Pro:k8s-docker-desktop-for-mac ruishen$
7.访问管理地址
??????http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
ok,以上算是K8s启动完成了。
参考:www.jianshu.com/p/a6abdc6f76e1
|