概述
Rancher是一套容器管理平台,它可以帮助组织在生产环境中轻松快捷的部署和管理容器。 Rancher可以轻松地管理各种环境的Kubernetes,满足IT需求并为DevOps团队提供支持。
Kubernetes不仅已经成为的容器编排标准,它也正在迅速成为各类云和虚拟化厂商提供的标准基础架构。Rancher用户可以选择使用Rancher Kubernetes Engine(RKE)创建Kubernetes集群,也可以使用GKE,AKS和EKS等云Kubernetes服务。 Rancher用户还可以导入和管理现有的Kubernetes集群。
Rancher支持各类集中式身份验证系统来管理Kubernetes集群。例如,大型企业的员工可以使用其公司Active Directory凭证访问GKE中的Kubernetes集群。IT管理员可以在用户,组,项目,集群和云中设置访问控制和安全策略。 IT管理员可以在单个页面对所有Kubernetes集群的健康状况和容量进行监控。
Rancher为DevOps工程师提供了一个直观的用户界面来管理他们的服务容器,用户不需要深入了解Kubernetes概念就可以开始使用Rancher。 Rancher包含应用商店,支持一键式部署Helm和Compose模板。Rancher通过各种云、本地生态系统产品认证,其中包括安全工具,监控系统,容器仓库以及存储和网络驱动程序。下图说明了Rancher在IT和DevOps组织中扮演的角色。每个团队都会在他们选择的公共云或私有云上部署应用程序。
kubernetes中部署rancher
部署文档:https://www.cnrancher.com/docs/rancher/v2.x/cn/installation/other/
代码语言:javascript复制#生成证书
[root@localhost ~]# openssl genrsa -out tls.key 2048
Generating RSA private key, 2048 bit long modulus
......
....
e is 65537 (0x10001)
[root@localhost ~]# openssl req -new -x509 -key tls.key -out tls.crt -subj /C=CN/ST=Beijing/L=Beijing/O=DevOps/CN=sslrancher.foo.com
[root@localhost ~]# mv tls.* cert/
[root@localhost ~]# ll cert/
-rw-r--r-- 1 root root 1298 Jul 2 09:30 tls.crt
-rw-r--r-- 1 root root 1679 Jul 2 09:29 tls.key
#创建命名空间
[root@localhost ~]# kubectl create namespace cattle-system
namespace/cattle-system created
[root@localhost ~]# kubectl -n cattle-system create secret tls tls-rancher-ingress --cert=./cert/tls.crt --key=./cert/tls.key
secret/tls-rancher-ingress created
#添加chats仓库
[root@localhost ~]# helm repo add rancher-stable https://releases.rancher.com/server-charts/stable
"rancher-stable" has been added to your repositories
[root@localhost ~]# helm repo list
NAME URL
local http://127.0.0.1:8879/charts
stable https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
rancher-stable https://releases.rancher.com/server-charts/stable
#helm部署rancher
[root@localhost ~]# helm install rancher-stable/rancher --name rancher --namespace cattle-system --set hostname=sslrancher.foo.com --set ingress.tls.source=secret
NAME: rancher
LAST DEPLOYED: Tue Jul 2 09:36:28 2019
NAMESPACE: cattle-system
STATUS: DEPLOYED
RESOURCES:
==> v1/ClusterRoleBinding
NAME AGE
rancher 5s
==> v1/Deployment
NAME READY UP-TO-DATE AVAILABLE AGE
rancher 0/3 3 0 5s
==> v1/Pod(related)
NAME READY STATUS RESTARTS AGE
rancher-d95d845c9-7n8rn 0/1 ContainerCreating 0 4s
rancher-d95d845c9-pw5gf 0/1 ContainerCreating 0 3s
rancher-d95d845c9-wcl2r 0/1 ContainerCreating 0 3s
==> v1/Service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
rancher ClusterIP 10.0.0.100 <none> 80/TCP 5s
==> v1/ServiceAccount
NAME SECRETS AGE
rancher 1 6s
==> v1beta1/Ingress
NAME HOSTS ADDRESS PORTS AGE
rancher sslrancher.foo.com 80, 443 4s
NOTES:
Rancher Server has been installed.
NOTE: Rancher may take several minutes to fully initialize. Please standby while Certificates are being issued and Ingress comes up.
Check out our docs at https://rancher.com/docs/rancher/v2.x/en/
Browse to https://sslrancher.foo.com
Happy Containering!
#查看pod
[root@localhost ~]# kubectl get all -n cattle-system
NAME READY STATUS RESTARTS AGE
pod/rancher-d95d845c9-7n8rn 1/1 Running 0 110s
pod/rancher-d95d845c9-pw5gf 1/1 Running 0 109s
pod/rancher-d95d845c9-wcl2r 1/1 Running 0 109s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/rancher ClusterIP 10.0.0.100 <none> 80/TCP 111s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/rancher 3/3 3 3 111s
NAME DESIRED CURRENT READY AGE
replicaset.apps/rancher-d95d845c9 3 3 3 110s
[root@localhost ~]# kubectl get ingress -n cattle-system
NAME HOSTS ADDRESS PORTS AGE
rancher sslrancher.foo.com 80, 443 2m10s
浏览器访问
管理现有的kubernetes集群
Rancher 可以管理现有 Kubernetes 集群,通过在现有 Kubernetes 集群中启动一个 Rancher Agent 服务,就可以托管整个 Kubernetes 集群,然后在 Rancher UI 中导入即可。
参考资料
- Github Rancher
- Rancher 2.x Docs