通过minikube和helm这2个工具,可以实现快速部署k8s环境及应用
安装minikube
需要先安装docker环境
#docker官方脚本自动安装
curl -fsSL get.docker.com -o get-docker.sh
sh get-docker.sh --mirror Aliyun
下载可执行文件
curl -Lo minikube https://github.com/kubernetes/minikube/releases/download/v1.4.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
部署k8s环境
minikube start --vm-driver=none --image-mirror-country=cn
查看状态
minikube status
安装helm
wget https://get.helm.sh/helm-v2.16.0-linux-amd64.tar.gz
tar -xvf helm-v2.16.0-linux-amd64.tar.gz
cd linux-amd64
chmod +x helm && mv helm /usr/local/bin/
helm init
替换源
helm repo remove stable
helm repo add stable https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
helm repo update
这时候还无法使用,还需要部署tiller服务
apiVersion: v1
kind: ServiceAccount
metadata:
name: tiller
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: tiller
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: tiller
namespace: kube-system
/root/.minikube/cache/v1.16.0/kubectl create -f rbac.yaml
helm init --service-account tiller --upgrade -i registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.11.0 --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
这样就可以一键安装各类helm chart了
helm install stable/mysql