当前位置:网站首页>Practice of hierarchical management based on kubesphere
Practice of hierarchical management based on kubesphere
2022-06-25 07:04:00 【KubeSphere】
author : Xu Wei , R & D Engineer of aerospace network information
K8s Is a leader in container orchestration and distributed application deployment , stay K8s Environment , We only need to care about the business logic of the application , It reduces the management burden of our server network and storage . For a user ,K8s Is a very complex container orchestration platform , The cost of learning is very high .KubeSphere Abstracts the underlying K8s, And a high degree of productization , Build a full stack multi tenant container cloud platform , It provides a robust 、 Security 、 Rich in functions 、 With the ultimate experience Web Console , It's solved K8s High barriers to use and numerous cloud native ecological tools , Enables us to focus on rapid iterations of the business , Its multi-dimensional data monitoring , For the positioning of the problem , It's a great help .
Why are you in KuberSphere Realize hierarchical management on
stay KubeSphere in , Resources can be shared among tenants , According to the different roles assigned , Various resources can be operated . Between tenant and resource 、 There is a high degree of freedom between resources , Permission granularity is also relatively large . In our system , Resources have permission levels , For example, low-level users can invite 、 Give permission and other operations to operate high-level resources , Or like in a low-level project Pod It can be dispatched to high-level nodes , The resource . Such problems as cross level operation of resources , We are KubeSphere Based on this, the hierarchical management is realized .
What is a hierarchy
classification , As the name suggests, it is to decompose the whole according to the established standards 、 classification . We abstract it into a pyramid model , There are many levels from the foundation to the top of the tower , We use public resources as the foundation of the pyramid , With the highest authority admin As tower top , Other resources are divided into different levels according to permission levels . Low level resources cannot access high-level resources , A high-level resource can obtain all resources below its level , Constructed such a diminishing equity 、 A hierarchical system of hierarchical isolation .

How to realize hierarchical management
We define a label that represents the level kubernetes.io/level. Take a multi node cluster as an example , First of all, we will give users 、 Enterprise space 、 Nodes and other resources are labeled as representing levels . When inviting users to join an enterprise space or project , The level of enterprise space or project required to be added shall not be higher than the user's level , Similarly, when the project is bound to the enterprise space , It is also required that the level of the project shall not be higher than that of the enterprise space , To manage resources ; We believe that the level of resources under the same project is the same , Loads created based on the project 、Pod、 The level of services and other resources shall be consistent with the project ; meanwhile Pod Add node affinity to , In order to make Pod Dispatch to a node not higher than its permission level .

For example, here , We created a permission level that is 3 Users of demo-user, He can join with permission level no higher than 3 In the enterprise space or project .
kind: UserapiVersion: iam.kubesphere.io/v1alpha2metadata: name: demo-user labels: kubernetes.io/level: 3spec: email: [email protected] Creating a permission level is 2 Project demo-ns, Then the load created based on the project 、Pod、 The permission level of storage and other resources is also 2.
apiVersion: v1kind: Namespacemetadata: name: demo-ns labels: kubernetes.io/level: 2 be based on demo-ns The project creates a nginx Of Pod, His authority level is also 2, At the same time, add node affinity , It is required that the authority level shall not be higher than 2 Node .
apiVersion: apps/v1kind: Podmetadata: labels: kubernetes.io/level: 2 name: nginxspec: containers: - name: nginx image: nginx imagePullPolicy: IfNotPresent ports: - containerPort: 80 protocol: TCP affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/level operator: Lt values: - 2 - matchExpressions: - key: kubernetes.io/level operator: In values: - 2How to upgrade or downgrade resources
In the hierarchical management system , Support unlimited division of levels , Just define an intermediate value , You can insert a new level between the two levels , No need to manipulate other resources ; When upgrading or upgrading resources , You only need to modify the corresponding resource label label , You can upgrade or downgrade resources . Of course , When upgrading or degrading resources , We need to test the resources , Ensure that when upgrading , The permission level of its upper level resources shall not be lower than the target level ; meanwhile , When demoted , The permission level of its lower level resources shall not be higher than the target level . When the upgrade and downgrade operation conditions are not met , The corresponding resources need to be adjusted accordingly .

Between different levels Pod Network isolation
In the hierarchy , We require high-grade Pod Access to low-level Pod, But low grade Pod Cannot access high-level Pod, So how do we ensure that different levels Pod Network communication .
The project does not open network isolation ,Pod The network is interconnected , Therefore, a blacklist network strategy will be added here .
apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata: name: deny-all namespace: demo-ns labels: kubernetes.io/level: 2spec: podSelector: {} policyTypes: - IngresspodSelector:{} Apply to all... In the project Pod, Prevent all flow from flowing in .
Then the release label level is greater than the target level ( Here is 2) The flow into ( We are right. Ingress The flow is not limited ).
apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata: name: level-match-network-policy namespace: demo-ns labels: kubernetes.io/level: 2spec: podSelector: matchExpressions: - key: kubernetes.io/level operator: Gt values: - 2 policyTypes: - Ingresssummary
KubeSphere It solves the problem of user building 、 Deploy 、 Pain points in management and observability , Its resources can be shared among multiple tenants . But in scenarios where resources have permission levels , Low level resources can operate high-level resources , Cause the problem of ultra vires management of resources . To solve this problem , We are KubeSphere On the basis of the transformation , To adapt to the hierarchical management between tenants and resources and between resources , At the same time, in the network strategy of the project , Add blacklist and whitelist strategies , Enhanced network isolation between projects , Make resource management more secure .
This article by the blog one article many sends the platform OpenWrite Release !
边栏推荐
- [Shangshui Shuo series] day 5
- Blue Bridge Cup SCM module code (matrix key) (code + comments)
- fastadmin 联级清空数据
- Direct select sort and quick sort
- Cs5092 5V USB input boost two section lithium battery charging management IC, SOT23-6 miniature package
- [core content and derivation] the mystery of human memory system may be just like this
- ACWING/2004. 错字
- Solar orbiter captured the full picture of the largest prominence eruption in history
- Analysis of common interview questions in redis
- Jameswebb Space Telescope goes into operation to help study interstellar objects
猜你喜欢

cos(a-b)=cosa*cosb+sina*sinb的推导过程

Navicat prevent new query from being deleted by mistake

レ / leilei

Entry level use of flask

Drosophila played VR and entered nature. It was found that there were attention mechanisms and working memory. The insect brain was no worse than that of mammals

【他字字不提爱,却句句都是爱】

Can TCP syn handshake messages transmit data

CTFHub-Web-信息泄露-目录遍历

Flask 的入门级使用

レレ / 蕾蕾
随机推荐
【一起上水硕系列】Day 5
2022 biological fermentation Exhibition (Jinan), which is a must read before the exhibition. The most comprehensive exhibition strategy will take you around the "fermentation circle"
After unplugging the network cable, does the original TCP connection still exist?
R & D thinking 07 - embedded intelligent product safety certification required
Why did Yanjing Beer come here?
Make fertilizer Safi from crop residues locally to increase yield by 30% and improve soil
[200 opencv routines of youcans] 104 Motion blur degradation model
Is the number of indexes in a table the more the better?
レ / leilei
Kubernetes cluster dashboard & kuboard installation demo
Direct select sort and quick sort
Flask 的入门级使用
父爱的表达方式
The process of making wooden barrels with 3DMAX software: a three-step process
Entry level use of flask
joda.time获取日期总结
了解zbrush雕刻软件,以及游戏建模的分析
Analysis on the output, market scale and development status of China's children's furniture industry in 2020 and the competition pattern of children's furniture enterprises [figure]
ACWING/2004. 错字
Unity get resource path