diff --git a/charts/pisa-controller/Chart.yaml b/charts/pisa-controller/Chart.yaml index 80c7fc75..2aa44a9f 100644 --- a/charts/pisa-controller/Chart.yaml +++ b/charts/pisa-controller/Chart.yaml @@ -37,11 +37,11 @@ version: 0.2.0 # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "0.2.0" +appVersion: "0.3.1" dependencies: - name: common repository: https://charts.bitnami.com/bitnami tags: - bitnami-common - version: 1.x.x \ No newline at end of file + version: 1.x.x diff --git a/charts/pisa-controller/values.yaml b/charts/pisa-controller/values.yaml index 58266ef4..ddbde0c3 100644 --- a/charts/pisa-controller/values.yaml +++ b/charts/pisa-controller/values.yaml @@ -28,14 +28,14 @@ image: repository: pisanixio/controller pullPolicy: Always # Overrides the image tag whose default is the chart appVersion. - tag: "v0.3.0" + tag: "v0.3.1" imagePullSecrets: [ ] ## @param proxyImage.repository 需要注入的 pisa-proxy 的镜像名 ## @param proxyImage.tag 需要注入的 pisa-proxy 镜像tag proxyImage: repository: pisanixio/proxy - tag: "v0.3.0" + tag: "v0.3.1" ## @param resources.limits pisa-controller 资源限制数值 ## @param resources.requests.cpu pisa-controller 资源申请cpu核数 diff --git a/docs/docs/Features/traffic-qos.md b/docs/docs/Features/traffic-qos.md new file mode 100644 index 00000000..2c887389 --- /dev/null +++ b/docs/docs/Features/traffic-qos.md @@ -0,0 +1,86 @@ +--- +sidebar_position: 8 +--- + +# Pisa-Daemon + +Pisa-Daemon 是用 rust 实现的数据面,主要通过主机内核的各种能力来实现资源管理。 +目前的主要功能是: +* 运行时流量管理 +借助 eBPF 技术为数据库访问流量提供 QoS 保证,以减少流量之间的互相干扰。 + +Pisa-Daemon 即可以部署在 kubernetes 中以 daemonset 的方式部署,也可以单独部署。 + +# 现状 +当前 Pisa-Damon 实现了 Service 级别的 QoS,Service 来自 VirtualDatabase 中的定义。 + +主要实现技术是 ebpf + tc。 + +# 配置 + +* 在 kubernetes 中部署,需要依赖 `QoSClaim` CRD, Spec 配置项如下: + +| 属性 | 值类型 | 是否依赖 | 默认值 | 含义 | +|-----|-------|---------|-------|-----| +|trafficQoS | [object](#trafficQoS-配置) | 是 | 无 | traffic qos | + + +## trafficQoS 配置 +| 属性 | 值类型 | 是否依赖 | 默认值 | 含义 | +|-----|-------|---------|-------|-----| +|name | string| 是 | 无 | qos 名称 | +|qos_group| [object](#qos_group-配置)| 否 | 无 | 具体带宽限制 | + +### qos_group 配置 +| 属性 | 值类型 | 是否依赖 | 默认值 | 含义 | +|-----|-------|---------|-------|-----| +|rate | string| 否 | 无 | 带宽最大值| +|ceil | string| 否 | 无 | 如果带宽有剩余,带宽可以达到的最大值 | + +rate 和 ceil 的单位可以是 + +bit, kbit, mbit, gbit,tbit 表示 bit/s。 + +bps,kbps, mbps, gbps, tbps 表示 bps/s。 + + +注意点: + + * 配置了 QoSClaim 后,需要在 VirtualDatabase 中配置 `qosClaim` 以生效。 + * trafficQos 的 name 名称要包含在 VirtualDatabase 的 Serivice 中。 + +示例: +``` yaml +apiVersion: core.database-mesh.io/v1alpha1 +kind: QoSCliam +metadata: + name: test + namespace: default +spec: + trafficQoS: + name: svc1 + qos_group: + rate: 1mps + ceil: 2mps +``` + +* 单独部署配置如下: + +``` toml +[global] +egress_device = "cali16adef18cfd" +bridge_device = "tunl0" + +[[app]] +name = "test1" + +[[app.service]] +name = "test" +[[app.service.endpoints]] +ip = "192.168.136.29" +port = 5201 + +[app.service.qos_group] +rate = "5mbps" +ceil = "5mbps" +``` diff --git a/example/sharding/app.yml b/example/sharding/database-strategy/app.yml similarity index 100% rename from example/sharding/app.yml rename to example/sharding/database-strategy/app.yml diff --git a/example/sharding/database-strategy/databaseendpoint1.yml b/example/sharding/database-strategy/databaseendpoint1.yml new file mode 100644 index 00000000..0b20794a --- /dev/null +++ b/example/sharding/database-strategy/databaseendpoint1.yml @@ -0,0 +1,31 @@ +## +## Copyright 2022 SphereEx Authors +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## + +apiVersion: core.database-mesh.io/v1alpha1 +kind: DatabaseEndpoint +metadata: + labels: + source: test + name: ds001 + namespace: default +spec: + database: + MySQL: + db: test + host: mysql1.default + password: root + port: 3306 + user: root diff --git a/example/sharding/database-strategy/databaseendpoint2.yml b/example/sharding/database-strategy/databaseendpoint2.yml new file mode 100644 index 00000000..1fa43ec1 --- /dev/null +++ b/example/sharding/database-strategy/databaseendpoint2.yml @@ -0,0 +1,31 @@ +## +## Copyright 2022 SphereEx Authors +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## + +apiVersion: core.database-mesh.io/v1alpha1 +kind: DatabaseEndpoint +metadata: + labels: + source: test + name: ds002 + namespace: default +spec: + database: + MySQL: + db: test + host: mysql2.default + password: root + port: 3306 + user: root diff --git a/example/sharding/database-strategy/datashard.yml b/example/sharding/database-strategy/datashard.yml new file mode 100644 index 00000000..eb9ad1d5 --- /dev/null +++ b/example/sharding/database-strategy/datashard.yml @@ -0,0 +1,35 @@ +## +## Copyright 2022 SphereEx Authors +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## + +apiVersion: core.database-mesh.io/v1alpha1 +kind: DataShard +metadata: + name: test + namespace: default + labels: + source: test +spec: + rules: + - tableName: "t_order" + databaseStrategy: + databaseShardingAlgorithmName: "mod" + databaseShardingColumn: "id" + actualDatanodes: + valueSource: + nodes: + - value: "ds001" + - value: "ds002" + diff --git a/example/sharding/database-strategy/mysql1.yml b/example/sharding/database-strategy/mysql1.yml new file mode 100644 index 00000000..37bfe001 --- /dev/null +++ b/example/sharding/database-strategy/mysql1.yml @@ -0,0 +1,70 @@ +## +## Copyright 2022 SphereEx Authors +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## + +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: mysql1 + name: mysql1 + namespace: default +spec: + progressDeadlineSeconds: 600 + replicas: 1 + revisionHistoryLimit: 10 + selector: + matchLabels: + app: mysql1 + strategy: + type: Recreate + template: + metadata: + labels: + app: mysql1 + spec: + containers: + - env: + - name: MYSQL_ROOT_PASSWORD + value: root + image: mysql:5.7 + imagePullPolicy: IfNotPresent + name: mysql + ports: + - containerPort: 3306 + protocol: TCP + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 30 +--- +apiVersion: v1 +kind: Service +metadata: + name: mysql1 + namespace: default +spec: + ports: + - port: 3306 + protocol: TCP + targetPort: 3306 + selector: + app: mysql1 + sessionAffinity: None + type: ClusterIP diff --git a/example/sharding/database-strategy/mysql2.yml b/example/sharding/database-strategy/mysql2.yml new file mode 100644 index 00000000..3b8d2e2b --- /dev/null +++ b/example/sharding/database-strategy/mysql2.yml @@ -0,0 +1,70 @@ +## +## Copyright 2022 SphereEx Authors +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## + +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: mysql2 + name: mysql2 + namespace: default +spec: + progressDeadlineSeconds: 600 + replicas: 1 + revisionHistoryLimit: 10 + selector: + matchLabels: + app: mysql2 + strategy: + type: Recreate + template: + metadata: + labels: + app: mysql2 + spec: + containers: + - env: + - name: MYSQL_ROOT_PASSWORD + value: root + image: mysql:5.7 + imagePullPolicy: IfNotPresent + name: mysql + ports: + - containerPort: 3306 + protocol: TCP + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 30 +--- +apiVersion: v1 +kind: Service +metadata: + name: mysql2 + namespace: default +spec: + ports: + - port: 3306 + protocol: TCP + targetPort: 3306 + selector: + app: mysql2 + sessionAffinity: None + type: ClusterIP diff --git a/example/sharding/trafficstrategy.yml b/example/sharding/database-strategy/trafficstrategy.yml similarity index 100% rename from example/sharding/trafficstrategy.yml rename to example/sharding/database-strategy/trafficstrategy.yml diff --git a/example/sharding/virtualdatabase.yml b/example/sharding/database-strategy/virtualdatabase.yml similarity index 100% rename from example/sharding/virtualdatabase.yml rename to example/sharding/database-strategy/virtualdatabase.yml diff --git a/example/sharding/table-strategy/app.yml b/example/sharding/table-strategy/app.yml new file mode 100644 index 00000000..b8d59104 --- /dev/null +++ b/example/sharding/table-strategy/app.yml @@ -0,0 +1,108 @@ +## +## Copyright 2022 SphereEx Authors +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## + +--- +apiVersion: v1 +data: + nginx.conf: |- + user nginx; + worker_processes 1; + + error_log /var/log/nginx/error.log warn; + pid /var/run/nginx.pid; + + + events { + worker_connections 1024; + } + + stream { + upstream mysql { + server 127.0.0.1:3306; + } + + server { + listen 3307; + proxy_pass mysql; + } + + } +kind: ConfigMap +metadata: + name: test + namespace: default + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: nginx + name: test + namespace: default +spec: + progressDeadlineSeconds: 600 + replicas: 1 + revisionHistoryLimit: 10 + selector: + matchLabels: + app: nginx + strategy: + rollingUpdate: + maxSurge: 25% + maxUnavailable: 25% + type: RollingUpdate + template: + metadata: + labels: + app: nginx + pisanix.io/inject: enabled + spec: + volumes: + - name: nginx + configMap: + name: test + containers: + - name: nginx + image: nginx:1.19.10 + volumeMounts: + - name: nginx + mountPath: /etc/nginx/nginx.conf + subPath: nginx.conf + ports: + - containerPort: 3307 + protocol: TCP +--- +apiVersion: v1 +kind: Service +metadata: + name: test + namespace: default +spec: + ports: + - port: 3307 + protocol: TCP + targetPort: 3307 + name: nginx + - port: 3306 + protocol: TCP + targetPort: 3306 + name: pisa-proxy + selector: + app: nginx + sessionAffinity: None + type: ClusterIP + \ No newline at end of file diff --git a/example/sharding/databaseendpoint.yml b/example/sharding/table-strategy/databaseendpoint.yml similarity index 100% rename from example/sharding/databaseendpoint.yml rename to example/sharding/table-strategy/databaseendpoint.yml diff --git a/example/sharding/datashard.yml b/example/sharding/table-strategy/datashard.yml similarity index 100% rename from example/sharding/datashard.yml rename to example/sharding/table-strategy/datashard.yml diff --git a/example/sharding/mysql.yml b/example/sharding/table-strategy/mysql.yml similarity index 98% rename from example/sharding/mysql.yml rename to example/sharding/table-strategy/mysql.yml index bf47d662..eb9f62a2 100644 --- a/example/sharding/mysql.yml +++ b/example/sharding/table-strategy/mysql.yml @@ -67,4 +67,4 @@ spec: selector: app: mysql sessionAffinity: None - type: ClusterIP \ No newline at end of file + type: ClusterIP diff --git a/example/sharding/table-strategy/trafficstrategy.yml b/example/sharding/table-strategy/trafficstrategy.yml new file mode 100644 index 00000000..95f99691 --- /dev/null +++ b/example/sharding/table-strategy/trafficstrategy.yml @@ -0,0 +1,28 @@ +## +## Copyright 2022 SphereEx Authors +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## + +apiVersion: core.database-mesh.io/v1alpha1 +kind: TrafficStrategy +metadata: + name: test + namespace: default +spec: + loadBalance: + simpleLoadBalance: + kind: random + selector: + matchLabels: + source: test diff --git a/example/sharding/table-strategy/virtualdatabase.yml b/example/sharding/table-strategy/virtualdatabase.yml new file mode 100644 index 00000000..d1e6328d --- /dev/null +++ b/example/sharding/table-strategy/virtualdatabase.yml @@ -0,0 +1,32 @@ +## +## Copyright 2022 SphereEx Authors +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## + +apiVersion: core.database-mesh.io/v1alpha1 +kind: VirtualDatabase +metadata: + name: test + namespace: default +spec: + services: + - databaseMySQL: + db: test + host: 127.0.0.1 + password: "root" + port: 3306 + user: root + name: mysql + trafficStrategy: test + dataShard: test