容器编排(学习环境 k8s)安装kind
【摘要】 1.kind官网:kind2.安装kubectl,参考:k8s集群安装及相关问题解决3.依据官网引导,安装kindcurl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64chmod +x ./kind#移动kind至自己的目录,最好新建一个mv ~/kind /data/kindk8s/#创建默认集群./kind...
1.kind官网:kind
2.安装kubectl,参考:k8s集群安装及相关问题解决
3.依据官网引导,安装kind
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64
chmod +x ./kind
#移动kind至自己的目录,最好新建一个
mv ~/kind /data/kindk8s/
#创建默认集群
./kind create cluster
#下载kind镜像并创建完成后,查看创建的集群
kubectl cluster-info --context kind-kind
#查看节点信息
kubectl get nodes
4.以上是简单的安装,下面开始在kind中安装dashboard的方法
删除已安装的cluster
./kind delete cluster --name kind
在创建集群时指定暴露的端口,等下把dashboard的端口暴露到指定端口去
kind-example-config.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
# WARNING: It is _strongly_ recommended that you keep this the default
# (127.0.0.1) for security reasons. However it is possible to change this.
apiServerAddress: "0.0.0.0"
# By default the API server listens on a random open port.
# You may choose a specific port but probably don't need to in most cases.
# Using a random port makes it easier to spin up multiple clusters.
apiServerPort: 6443
nodes:
- role: control-plane
extraPortMappings:
- containerPort: 30001
hostPort: 30001
listenAddress: "0.0.0.0"
protocol: tcp
- containerPort: 30002
hostPort: 30002
listenAddress: "0.0.0.0"
protocol: tcp
- containerPort: 30003
hostPort: 30003
listenAddress: "0.0.0.0"
protocol: tcp
- containerPort: 30004
hostPort: 30004
listenAddress: "0.0.0.0"
protocol: tcp
- containerPort: 30005
hostPort: 30005
listenAddress: "0.0.0.0"
protocol: tcp
# 创建集群,不指定集群名称默认为kind
./kind create cluster --config kind-example-config.yaml --name mycluster
5.下载dashboard
dashboardgit
根据k8s版本选择要下载的yaml
wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.3.1/aio/deploy/recommended.yaml
修改vi recommended.yaml
---
kind: Service
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kubernetes-dashboard
spec:
type: NodePort # 新添加
ports:
- port: 443
targetPort: 8443
nodePort: 30001 #新添加
selector:
k8s-app: kubernetes-dashboard
修改成功后部署:kubectl apply -f recommended.yaml
查看deployment状态:
kubectl get deployments -n kubernetes-dashboard
6.生成token
参考链接:生成token参考
整合后的dashboard-acount.yaml
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
创建账号与授权:
kubectl apply -f dashboard-acount.yaml
查看token
kubectl -n kubernetes-dashboard get secret $(kubectl -n kubernetes-dashboard get sa/admin-user -o jsonpath="{.secrets[0].name}") -o go-template="{{.data.token | base64decode}}"
创建授权账号成功后查看token方式2
kubectl get secrets -n kubernetes-dashboard |grep admin-user
kubectl describe secrets admin-user-token-sqpw9 -n kubernetes-dashboard
访问:https://192.168.31.250:30001
dashboard使用官方文档:https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)