Home Kubernetes环境安装
Post
Cancel

Kubernetes环境安装

1. 安装Docker

2. 配置镜像加速服务

国内下载 Kubernetes 集群所需的镜像速度太慢,因此需要在 Preferences»Docker Engine 中配置一下,注意主要增加这个参数即可registry-mirrors

1
2
3
4
5
6
7
8
{
  "insecure-registries": [],
  "registry-mirrors": [
    "https://dockerhub.azk8s.cn"
  ],
  "experimental": true,
  "debug": true
}

我这边翻墙了,所以没配置代理

3. 安装Kubernetes

Docker设置中勾选上后这两个选项后,会自动下载

安装完以后docker images,会列出k8s相关的镜像

4. 验证Kubernetes是否安装成功

kubectl get nodes

kubectl get pods -n kube-system

5. 部署 Kubernetes Dashboard

5.1 安装Kubernetes Dashboard

1
2
3
4
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended.yaml

# 开启本机访问代理,默认监听 8001 端口
kubectl proxy

5.2 访问登录页面

img_5.png

5.3 选择Token登陆

5.3.1 创建管理员用户

创建文件dashboard-admin.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kubernetes-dashboard
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: admin-user
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
  - kind: ServiceAccount
    name: admin-user
    namespace: kubernetes-dashboard

5.3.2 执行配置文件

1
2
3
4
5
6
7
8
9
# 创建 ServiceAccount kubernetes-dashboard-admin 并绑定集群管理员权限
kubectl apply -f dashboard-admin.yml

# 获取登陆 token
kubectl -n kubernetes-dashboard create token admin-user

# 清空账号
kubectl -n kubernetes-dashboard delete serviceaccount admin-user
kubectl -n kubernetes-dashboard delete clusterrolebinding admin-user

5.3.3 启动本地代理

kubectl proxy

5.3.4 填入Token,并登陆

官方文档

weixin.png

公众号名称:怪味Coding
微信扫码关注或搜索公众号名称
This post is licensed under CC BY 4.0 by the author.