KubeSphere的使用

默认的 dashboard 没啥用,我们用 kubesphere 可以打通全部的 devops 链路。
Kubesphere 集成了很多套件,集群要求较高 https://kubesphere.io/ Kuboard 也很不错,集群要求不高
官方文档:https://kuboard.cn/support/,但是我们也不用它。

一 、简介

KubeSphere 是一款面向云原生设计的开源项目,在目前主流容器调度平台 Kubernetes 之 上构建的分布式多租户容器管理平台,提供简单易用的操作界面以及向导式操作方式,在降 低用户使用容器调度平台学习成本的同时,极大降低开发、测试、运维的日常工作的复杂度。

二、安装

kubesphere官网:https://kubesphere.com.cn/

2.1 前提条件

https://kubesphere.io/docs/v2.1/zh-CN/installation/prerequisites/

2.2 安装前提环境

安装文档:https://helm.sh/zh/docs/intro/install/

## 在master节点安装 helm
curl -L https://git.io/get_helm.sh | bash
## 
chmod 700 get_helm_ma.sh 
2.2.1 安装 helm(master 节点执行)

Helm 是 Kubernetes 的包管理器。包管理器类似于我们在 Ubuntu 中使用的 apt、Centos 中使用的 yum 或者 Python 中的 pip 一样,能快速查找、下载和安装软件包。Helm 由客 户端组件 helm 和服务端组件 Tiller 组成, 能够将一组 K8S 资源打包统一管理, 是查找、共 享和使用为 Kubernetes 构建的软件的最佳方式。
错误代码:
SHA sum of /tmp/helm-installer-ezodFH/helm–linux-amd64.tar.gz does not match. Aborting

安装文档:https://helm.sh/zh/docs/intro/install/
二进制安装
第一步:下载 需要的版本
第二步:解压(tar -zxvf helm-v2.17.0-linux-amd64.tar.gz)
第三步:在解压目中找到helm程序,移动到需要的目录中(mv linux-amd64/helm /usr/local/bin/helm)

## 在mster节点随便找一个文件加解压这个文件
tar -zxvf helm-v2.17.0-linux-amd64.tar.gz
## 把helm 文件移动到/usr/local/bin/helm 目录下
mv linux-amd64/helm /usr/local/bin/helm
## 查看版本,会发现有两个版本,一个服务端的,一个客户端的。
helm version
kubectl get pods --all-namespaces
## 创建权限(master 执行)新建一个文件,helm-rbac.yaml 文件的内容在下方
vi helm-rbac.yaml
## 执行这个文件 新建tiller
kubectl apply -f helm-rbac.yaml
## 初始化装好 –tiller-image 指定镜像,否则会被墙,等待节点上部署的tiller完成即可。这个过程可能需要4-5分钟,请耐心等待
helm init --service-account=tiller --tiller-image=sapcc/tiller:v2.17.0 --history-max 300 

helm-rbac.yaml 文件内容如下

apiVersion: v1
kind: ServiceAccount
metadata:
  name: tiller
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: tiller
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
  - kind: ServiceAccount
    name: kubernetes-dashboard
    namespace: kube-system

过程:
第一步:下载 需要的版本
https://helm.sh/zh/docs/intro/install/
在这里插入图片描述
https://github.com/helm/helm/tags
在这里插入图片描述

第二步:解压(tar -zxvf helm-v2.16.3-linux-amd64.tar.gz)
在这里插入图片描述
第三步:在解压目中找到helm程序,移动到需要的目录中(mv linux-amd64/helm /usr/local/bin/helm)


验证,等待节点上部署tiller
在这里插入图片描述

2.2.2 存储类型

https://v2-1.docs.kubesphere.io/docs/zh-CN/appendix/install-openebs/
在这里插入图片描述

## 查看所有节点,找到主节点名称
kubectl get node -o wide
## 在主节点上查看有没有污点有污点,表示被人占用
kubectl describe node k8s-node1 | grep Taint
## 去除污点
kubectl taint nodes k8s-node1 node-role.kubernetes.io/master:NoSchedule-
## 创建 openebs 为存储器
kubectl apply -f https://openebs.github.io/charts/openebs-operator-1.5.0.yaml
## 查看安装情况
kubectl get pods --all-namespaces
## 安装 OpenEBS 后将自动创建 4 个 StorageClass
kubectl get sc --all-namespaces
##如下将 openebs-hostpath设置为 默认的 StorageClass
kubectl patch storageclass openebs-hostpath -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
## 将污点重新设置回来
kubectl taint nodes k8s-node1 node-role.kubernetes.io/master=:NoSchedule
## 测试存储类型是否安装成功demo-openebs-hostpath.yaml 这个文件下面有
kubectl apply -f demo-openebs-hostpath.yaml -n openebs
## 如果 PVC 的状态为 Bound并且 Pod 状态为 running,则说明已经成功挂载,证明了默认的 StorageClass(openebs-hostpath)是正常工作的
kubectl get pvc -n openebs

在这里插入图片描述
在这里插入图片描述
测试:如下创建一个 demo-openebs-hostpath.yaml,其中定义的 Deployment 与 PVC 用作测试,检验 openebs-hostpath 的 StorageClass 是否创建成功

## 注意,若您的 K8s 版本是 1.15,这里的 apiVersion 需要改为 apps/v1beta1
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: percona
  labels:
    name: percona
spec:
  replicas: 1
  selector:
    matchLabels:
      name: percona
  template:
    metadata:
      labels:
        name: percona
    spec:
      securityContext:
        fsGroup: 999
      tolerations:
      - key: "ak"
        value: "av"
        operator: "Equal"
        effect: "NoSchedule"
      containers:
        - resources:
            limits:
              cpu: 0.5
          name: percona
          image: percona
          args:
            - "--ignore-db-dir"
            - "lost+found"
          env:
            - name: MYSQL_ROOT_PASSWORD
              value: k8sDem0
          ports:
            - containerPort: 3306
              name: percona
          volumeMounts:
            - mountPath: /v
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值