背景:
服务器的办理停留在xshell 登陆办理的时代,主机设备数量少,单人操作的时分还能满意运用。现在的主机数量不多不少也有大几十台。然后就面临的多人的登陆与办理。过去都是直接给账户暗码。但这样就会面临操作审计的问题。尽管给的机器都是测验环境的,但是追溯操作人,审计也仍是大问题。另外便是数据库的长途操作。小伙伴都运用navicat操作。也会面临许多的问题: 首位仍是操作审计,其次便是长途IP的信赖,增加安全组这中操作就很烦人。火急的需要一个中间操作的设备,便是堡垒机。jumpserser是一款优秀的堡垒机。很早之前就测验运用过。比如其时疫情开端的时分长途办公。由于一些公司保密原因,只允许长途操作公司电脑进行工作,不允许用户上传下载,其时就运用了jumpserver办理(windows环境)。最近又看了一眼jumpserver的文档,发现支撑了kubernetes and mysql的办理。正好体会一下呢!
jumpserver的简略装置
条件预备:
参照官方文档:docs.jumpserver.org/zh/v3/
腾讯云cvm rocky9操作体系为例:
关于操作体系 rocky9 腾讯云服务器:

数据库的创立and授权:
早些时分创立的TDSQL-C数据库,创立了数据库and 用户,并授权,如下:



创立redis 数据库 and设置暗码:

在线装置:
自界说主机名:
首要先自界说一下主机名,个人习气。也能够疏忽
hostnamectl set-hostname jumpserver
执行一键装置脚本
主线版本现在是v2 v3。这儿直接装置了V3.10版本(latest,当时最新吧).当然了能够自界说初始化先把mysql, redis设置为咱们前面开通的。这儿偷闲了。先一键装置,后边再去修正! docs.jumpserver.org/zh/v3/insta…
curl -sSL https://resource.fit2cloud.com/jumpserver/jumpserver/releases/latest/download/quick_start.sh | bash



docker ps
jmsctl status

自界说装备:
mysql and redis运用外部装备:
自界说修正config.txt中mysql redis装备:
vim /opt/jumpserver/config/config.txt


重启一切服务:
jmsctl指令拿来用了:
jmsctl restart

jmsctl status

jmsctl status
docker stop jms_mysql jms_redis

web拜访并修正默许暗码:
浏览器拜访自界说域名,默许用户名暗码应该是admin admin?






https证书装备:
参照:kb.fit2cloud.com/?p=152 先上传证书到 /opt/jumpserver/config/nginx/cert/目录下:


jmsctl restart
jmsctl status



jumpserver的简略运用:
比较关心常用的财物办理:


主机为例:
创立财物
创立-挑选平台Linux**(财物IP为10.0.4.18):



财物授权:
点击权限办理-财物授权,对10.0.4.18资源进行授权


点击提交:

切换到工作台验证:
左侧边栏,点击工作台切换:



持续增加一个node
开端认为一个账户能够用于多个财物测验了一下失利了…..创立财物的时分还看到了模板,就想创立一个模板测验一下: 首要创立一个账号模板:



数据库的增加办理:
创立数据库财物与用户
财物办理-财物列表-数据库:



测验数据库衔接
点击更多-测验。能够看到jumpserver与数据库正常衔接:



web-cli or navicat操作数据库:
通过web-cli操作数据库:



会话审计
操控台左侧边栏-审计台



云服务的增加办理:
参照:baijiahao.baidu.com/s?id=175207…
确定集群衔接url
依据集群config文件 获取衔接url:

K8S集群办理权限的SA,并且绑定cluster-admin人物
参照: www.i7ti.cn/1410.html cat jumpserver-admin.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: jumpserver-admin
namespace: kube-system
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: jumpserver-admin
subjects:
- kind: ServiceAccount
name: jumpserver-admin
namespace: kube-system
roleRef:
kind: ClusterRole
name: cluster-admin #此处绑定集群办理员权限,请依据自身需求绑定权限,这儿只是举个比如
apiGroup: rbac.authorization.k8s.io
kubectl apply -f jumpserver-admin.yaml

获取token令牌:
kubectl get secret -n kube-system |grep "jumpserver-admin"
kubectl describe secret jumpserver-admin-token-zb8vm -n kube-system

创立云服务财物
jumpserver操控台操作 财物办理-财物列表-云服务-新建-挑选平台-kubernetes




财物授权:


web cli终端测验衔接:
切换操控台到工作台:




一般用户的测验:
注:以kubernetes云服务为例!
创立一般用户
上面的过程都是超级用户admin操作的,现在创立一个一般用户: 操控台-用户办理-用户列表-创立用户:



kubernetes相关资源创立:
网上一切的文章根本都是错的,关于一般用户的,比如:JumpServer:提升Kubernetes集群办理安全。但是一般用户的方法是不完整的。下面操作一下,请参照:k8s结合jumpserver做kubectl权限操控 用户在多个namespaces的拜访权限 rbac权限操控 !
- 创立serviceaccount
kubectl create sa develop-zhangpeng -n develop-xxx
kubectl get sa -n develop-xxxx
kubectl describe secrets/develop-zhangpeng-token-cddqx -n develop-xxxx

- 创立集群等级资源权限并绑定serviceaccount
网上许多的文章都是只绑定了namespace等级的资源,but jumpserver不能直接到namespace等级。故需要绑定一下集群等级的资源权限: cat jumpserver-admin-get-auth.yaml
其实这儿便是设置对k8s集群的一些权限的
apiVersion: rbac.authorization.k8s.io/v1 # api
kind: ClusterRole # 资源类型
metadata: # 元数据 ClusterRole 不受ns的限制,所以不必写ns
name: jumpserver-admin-get-auth # ClusterRole 的称号,能区别就行
rules:
- apiGroups: # apiGroups 便是api资源组,你kubectl get apiservice 就能够看到集群一切的api组
- "" # 我这儿代表为空,便是api组里面有一个v1. 这样的
resources: # 便是k8s资源的称号。kubectl api-resources 这个指令能够检查到,第一列是资源称号,便是能够写在这儿的。
# 第二列是简写,kubectl get 后边的能够简写。
# 第三列是APIGROUP组
# 第四列是是否归于NAMESPACED资源,便是你能够在ns下面看到的资源
# 第五列是kind的时分写的称号
# 资源还分子资源,后期会写一篇专门的文章介绍
- namespaces/status # 这个是ns状况
- namespaces # 这个是ns
- persistentvolumes # pv
verbs: # verbs是界说动作的
- get # 便是能够检查ns的权限
- list
- watch
- apiGroups:
- ""
resources: # 这儿界说的是能够检查node的权限,更新node的权限。
- nodes
- nodes/status
verbs:
- get
- list
- watch
- patch
- update
- apiGroups:
- "storage.k8s.io"
resources: # 这儿界说的是能够检查sc的权限,由于咱们有后端的存储集群,他们能够对sc的一切权限
- storageclasses
- storageclasses/status
resourceNames: # 由于sc归于集群资源,不同的业务方需要对自己的sc才有 全部权限。
- axersc # 一切这儿能够指定对哪一个sc有全部权限
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
- update
- watch
创立clusterrole apply yaml文件:
kubectl apply -f jumpserver-admin-get-auth.yaml
把上面界说的集群权限ClusterRole绑定给sa develop-zhangpeng: cat jumpserver-admin-get-auth-clusterrolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding # ClusterRoleBinding 用于绑定集群权限的
metadata:
name: jumpserver-admin-get-auth # 称号 ClusterRoleBinding 不受ns的限制,所以没有ns
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole # 上面界说的ClusterRole称号
name: jumpserver-admin-get-auth
subjects:
- kind: ServiceAccount # 上面界说的sa称号
name: develop-zhangpeng
namespace: develop-xxxx
kubectl apply -f jumpserver-admin-get-auth-clusterrolebinding.yaml
- namespace资源的绑定
cat jumpserver-admin-auth.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: jumpserver-admin-auth
rules:
- apiGroups:
- ""
resources: # 对pod的一些权限。
- pods/attach
- pods/exec # exec pod
- pods/portforward # 设置pod的转发
- pods/proxy
- secrets # secrets的权限
- services/proxy
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- serviceaccounts # sa的权限
verbs:
- impersonate
- apiGroups:
- ""
resources:
- pods
- pods/attach
- pods/exec
- pods/portforward
- pods/proxy
verbs:
- create
- delete
- deletecollection
- patch
- update
- apiGroups:
- ""
resources:
- configmaps
- endpoints
- persistentvolumeclaims
- replicationcontrollers
- replicationcontrollers/scale
- secrets
- serviceaccounts
- services
- services/proxy
verbs:
- create
- delete
- deletecollection
- patch
- update
- apiGroups:
- apps
resources:
- daemonsets
- deployments
- deployments/rollback
- deployments/scale
- replicasets
- replicasets/scale
- statefulsets
- statefulsets/scale
verbs:
- create
- delete
- deletecollection
- patch
- update
- apiGroups:
- autoscaling
resources:
- horizontalpodautoscalers
verbs:
- create
- delete
- deletecollection
- patch
- update
- apiGroups:
- batch
resources:
- cronjobs
- jobs
verbs:
- create
- delete
- deletecollection
- patch
- update
- apiGroups:
- extensions
resources:
- daemonsets
- deployments
- deployments/rollback
- deployments/scale
- ingresses
- networkpolicies
- replicasets
- replicasets/scale
- replicationcontrollers/scale
verbs:
- create
- delete
- deletecollection
- patch
- update
- apiGroups:
- policy
resources:
- poddisruptionbudgets
verbs:
- create
- delete
- deletecollection
- patch
- update
- apiGroups:
- networking.k8s.io
resources:
- ingresses
- networkpolicies
verbs:
- create
- delete
- deletecollection
- patch
- update
- apiGroups:
- metrics.k8s.io
resources:
- pods
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- configmaps
- endpoints
- persistentvolumeclaims
- pods
- replicationcontrollers
- replicationcontrollers/scale
- serviceaccounts
- services
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- bindings
- events
- limitranges
- pods/log
- pods/status
- replicationcontrollers/status
- resourcequotas
- resourcequotas/status
verbs:
- get
- list
- watch
- apiGroups:
- apps
resources:
- controllerrevisions
- daemonsets
- deployments
- deployments/scale
- replicasets
- replicasets/scale
- statefulsets
- statefulsets/scale
verbs:
- get
- list
- watch
- apiGroups:
- autoscaling
resources:
- horizontalpodautoscalers
verbs:
- get
- list
- watch
- apiGroups:
- batch
resources:
- cronjobs
- jobs
verbs:
- get
- list
- watch
- apiGroups:
- extensions
resources:
- daemonsets
- deployments
- deployments/scale
- ingresses
- networkpolicies
- replicasets
- replicasets/scale
- replicationcontrollers/scale
verbs:
- get
- list
- watch
- apiGroups:
- policy
resources:
- poddisruptionbudgets
verbs:
- get
- list
- watch
- apiGroups:
- networking.k8s.io
resources:
- ingresses
- networkpolicies
verbs:
- get
- list
- watch
- apiGroups:
- authorization.k8s.io
resources:
- localsubjectaccessreviews
verbs:
- create
- apiGroups:
- rbac.authorization.k8s.io
resources:
- rolebindings
- roles
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
- update
- watch
kubectl apply -f jumpserver-admin-auth.yaml
rolebingding 绑定sa: cat jumpserver-admin-auth-rolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: jumpserver-admin-auth
namespace: develop-xxxx
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: jumpserver-admin-auth
subjects:
- kind: ServiceAccount
name: develop-zhangpeng
namespace: develop-xxxxx
kubectl apply -f jumpserver-admin-auth-rolebinding.yaml
创立一般账号
账户办理-账号列表-增加账号develop-zhangpeng。暗码方法令牌方法,仿制kubernetes集群中刚创立的develop-zhangpeng的token!

财物授权:
权限办理-财物授权-创立财物授权规矩:

登陆一般用户测验:
开了一个火狐浏览器登陆了一般用户zhangpeng(看设置的暗码战略,或许第一非必须修正暗码!这儿就直接疏忽了)


点击web终端:






着重的:
- 用户 用户组的创立区别
- 账户模板的运用
- kubernetes一般用户的授权
- 财物后边进行更详细的区分
- 其他的:ldap集成,存储运用目标存储。至于邮件的修正就疏忽了。长途应用都是企业版的功能也疏忽了
- kubernetes的纳管有点意犹未尽:是纳管了,但是用户还需要实时看日志阿?我觉得我仍是不会用jumpserver纳管kubernetes……