MiniKube 安装

使用MiniKube,快速部署体验单机版本的OneCloud服务

前提

环境准备

OneCloud 相关的组件运行在MiniKube之上,环境以及相关的软件依赖如下:

  • 操作系统: Centos 7.6
  • 最低配置要求: CPU 4核, 内存 8G, 存储 100G
  • 数据库: mariadb Ver 15.1 Distrib 5.5.56-MariaDB

安装MySQL开启远程访问

# 此密码为上面设置的 MySQL root 密码,为了方便,只读账号也使用此密码
$ MYSQL_PASSWD='your-sql-passwd'
$ mysql -uroot -p$MYSQL_PASSWD -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '$MYSQL_PASSWD' WITH GRANT OPTION;FLUSH PRIVILEGES"

开始部署

启动minikube

下载minikue/kubectl, 并启动minikube集群, 具体请参考: https://kubernetes.io/docs/tasks/tools/install-minikube/

minikube config -p onecloud set memory 8192 
minikube start  --nodes 2 -p onecloud
minikube dashboard -p onecloud

部署local-path-storage

参考:https://github.com/rancher/local-path-provisioner, 在minikube部署local-path-storage

wget https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml -O local-path-storage.yaml 
kubectl apply -f local-path-storage.yaml 

部署onecloud k8s operator

onecloud k8s operator地址: https://github.com/yunionio/onecloud-operator

wget https://raw.githubusercontent.com/yunionio/onecloud-operator/master/manifests/onecloud-operator.yaml -O onecloud-operator.yaml
kubectl apply -f onecloud-operator.yaml

部署onecloud 集群

wget https://raw.githubusercontent.com/yunionio/onecloud-operator/master/manifests/example-onecloud-cluster.yaml -O onecloud-cluster.yaml
vim onecloud-cluster.yaml
  • 修改onecloud-cluster.yaml mysql相关配额
    host: $MYSQL_HOST
    port: $MYSQL_PORT
    username: "$MYSQL_USERNAME"
    password: "$MYSQL_PASSWD"
kubectl apply -f onecloud-cluster.yaml

打开K8s Dashboard确认相关服务正常启动完成

创建账号登录WebUI

创建账号

kubectl exec -n onecloud `kubectl -n onecloud get pods  | grep "example-onecloud-cluster-climc"| cut -f1 -d" "` -c climc  -i -t -- /bin/bash -il
$ climc user-create demo --password demo123A --system-account --enabled

登陆webUI

kubectl -n onecloud port-forward `kubectl -n onecloud get pods  | grep "example-onecloud-cluster-web"| cut -f1 -d" "` 9999:443 --address=0.0.0.0

打开浏览器:https://localhost:9999

待解决的问题

4类Pod启动失败,问题还在分析中,但不影响体验onecloud

  • example-onecloud-cluster-notify
  • example-onecloud-cluster-host-deployer
  • example-onecloud-cluster-monitor
  • example-onecloud-cluster-autoupdate

集群清理

kubectl delete -f onecloud-cluster.yaml
kubectl delete -f onecloud-operator.yaml
kubectl delete -f local-path-storage.yaml
minikube -p onecloud stop

最后修改 01.01.0001