跳到主要内容

安装 Kubebb

准备环境

准备基础环境

准备Kubernetes集群

提示

如果没有kubernets集群,可按照下述教程通过kind部署一个开发集群。默认情况下,为适配building base,集群至少有一个节点需要为Ingress Controller服务节点,并暴露80443端口。

  1. 安装kind

参考: https://kind.sigs.k8s.io/docs/user/quick-start/#installation

Linux环境为例:

# For AMD64 / x86_64
[ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
# For ARM64
[ $(uname -m) = aarch64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-arm64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
  1. 准备单节点集群配置文件kind-config.yaml
提示
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: kubebb-core
nodes:
- role: control-plane
image: kindest/node:v1.24.13
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
  1. 创建集群
kind create cluster --config=kind-config.yaml
  1. 查看集群状态
kubectl cluster-info --context kind-kubebb-core

如果一切正常,输出如下:

Kubernetes control plane is running at https://127.0.0.1:42607
CoreDNS is running at https://127.0.0.1:42607/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
  1. 查看集群节点
kubectl get nodes

如果一切正常,输出如下:

NAME                              STATUS   ROLES           AGE   VERSION
kubebb-core-control-plane Ready control-plane 21m v1.24.13

通过docker ps可发现该节点已经暴露了80443端口:

(base) ➜  building-base git:(azure) docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e4e3820cdb5a kindest/node:v1.24.13 "/usr/local/bin/entr…" 22 minutes ago Up 22 minutes 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 127.0.0.1:33611->6443/tcp kubebb-core-control-plane

安装内核

提示

Kubebb官方提供了helm仓库,方便用户安装: https://kubebb.github.io/components/

  1. 添加helm仓库
helm repo add kubebb https://kubebb.github.io/components/
helm repo update
  1. 创建命名空间

请根据实际情况修改命名空间名称

kubectl create namespace kubebb-system
  1. 安装
helm install -nkubebb-system kubebb-core kubebb/kubebb-core
  1. 查看安装状态
kubectl get pods -nkubebb-system 

如果一切正常,输入如下:

NAME                           READY   STATUS    RESTARTS   AGE
kubebb-core-6bd7c5f679-742mq 1/1 Running 0 21h

安装底座

1. 创建官方组件仓库

可参考使用官方组件仓库

2. 创建底座组件空间

提示

目前仅支持使用命名空间u4a-system

    kubectl create namespace u4a-system

3. 部署Cluster Component

组件部署信息cluster_componentplan.yaml如下:

详细可参考

apiVersion: core.kubebb.k8s.com.cn/v1alpha1
kind: ComponentPlan
metadata:
name: cluster-component
namespace: u4a-system
spec:
approved: true
name: cluster-component
version: 0.1.4
override:
set:
- ingress-nginx.controller.nodeSelector.kubernetes\.io/hostname=kubebb-core-control-plane
component:
name: kubebb.cluster-component
namespace: kubebb-system

需调整参数:

  • override.set.ingress-nginx.controller.nodeSelector.kubernetes\.io/hostname 将作为ingress-nginx服务节点

此处基于kind开发集群kubebb-core-control-plane节点。

通过一下命令部署:

    kubectl apply -nu4a-system -f cluster_componentplan.yaml

Cluster Component部署完成后,可通过以下命令查看组件部署状态:

    kubectl get componentplan -nu4a-system cluster-component -oyaml

当组件部署状态如下时,表示组件部署成功:

status:
conditions:
- lastTransitionTime: "2023-07-25T08:15:41Z"
reason: ""
status: "True"
type: Approved
- lastTransitionTime: "2023-07-25T08:15:44Z"
reason: InstallSuccess
status: "True"
type: Actioned
- lastTransitionTime: "2023-07-25T08:15:44Z"
reason: ""
status: "True"
type: Succeeded

4. 部署U4A Component

组件部署信息u4a_componentplan.yaml如下:

apiVersion: core.kubebb.k8s.com.cn/v1alpha1
kind: ComponentPlan
metadata:
name: u4a-component
namespace: u4a-system
spec:
approved: true
name: u4a-component
version: 0.1.10
wait: true
override:
valuesFrom:
- kind: ConfigMap
name: u4acm
valuesKey: "values.yaml"
component:
name: kubebb.u4a-component
namespace: kubebb-system

其中,组件U4A-Component的参数通过ConfigMap方式注入,ConfigMap的创建流程可参考U4A组件部署流程

通过一下命令部署:

    kubectl apply -nu4a-system -f u4a_componentplan.yaml

U4A Component部署完成后,可通过以下命令查看组件部署状态:

    kubectl get componentplan -nu4a-system u4a-component -oyaml

5. 访问底座服务门户

通过以下命令获取门户服务的访问地址:

(base) ➜  ~ kubectl get ingress -nu4a-system
NAME CLASS HOSTS ADDRESS PORTS AGE
bff-server-ingress <none> portal.172.18.0.2.nip.io 80, 443 4h55m
bff-server-ingress-socket <none> portal.172.18.0.2.nip.io 80, 443 4h55m
kube-oidc-proxy-server-ingress <none> k8s.172.18.0.2.nip.io 80, 443 4h55m

通过浏览器访问https://portal.172.18.0.2.nip.io即可进入服务门户。默认的用户名密码为

  • 用户名: admin
  • 密码: kubebb-admin

注意: 由于使用了nip.io作为域名解析服务,因此需要将HOSTS中的域名解析到ADDRESS对应的IP地址上。

6. 安装组件市场

参考 组件市场 的部署文档进行安装,参考用户手册 进行组件的浏览和使用。

卸载

1. 卸载U4A Component

    kubectl delete componentplan -nu4a-system u4a-component

2. 卸载Cluster Component

    kubectl delete componentplan -nu4a-system cluster-component