在Kubernetes集群中安装Helm及证书认证

安装Kubernetes

测试环境使用kubeadm安装kubernetes v1.6.3版本, 安装过程略过.

为Helm创建客户端认证

客户端认证是为了能够使用helm命令行调用Helm的服务端Tiller.

cd /etc/kubernetes/pki/

# 编译认证文件
openssl genrsa -out helm.key 2048
openssl req -new -key helm.key -subj "/CN=helm" -out helm.csr openssl x509 -req -in helm.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out helm.crt -days 10000 openssl x509 -noout -text -in ./helm.crt # 创建Helm context kubectl config set-context helm@kubernetes --cluster=kubernetes --namespace=monitoring --user=helm # 设置helm用户的客户端认证 kubectl config set-credentials helm --client-certificate=helm.crt --client-key=helm.key --embed-certs=true # 切换至helm context kubectl config use-context helm@kubernetes 

为Helm设置服务端RBAC授权

服务端RBAC授权是为了让Tiller有权限在其他namesapce中创建资源.

# 切换至admin context
kubectl config use-context kubernetes-admin@kubernetes
# 创建helm使用的serviceaccount
kubectl create serviceaccount helm --namespace=kube-system
# 创建角色绑定
kubectl create clusterrolebinding helm-sa-admin --clusterrole=admin --serviceaccount=kube-system:helm --namespace=kube-system

安装Helm

# 切换至helm context
kubectl config use-context helm@kubernetes
# 安装helm, 使用授权好的serviceaccount
helm init --service-account=helm

使用helm安装prometheus

kubectl create namespace monitoring
helm install stable/prometheus --name=prometheu
helm status prometheus




链接:https://www.jianshu.com/p/XZ5PWC

猜你喜欢

转载自www.cnblogs.com/cheyunhua/p/10019663.html