add rulegroup definitions for different scopes (#5064)

Signed-off-by: junot <junotxiang@kubesphere.io>
This commit is contained in:
junot
2022-07-18 09:45:12 +08:00
committed by GitHub
parent 7a41af7c0c
commit e529703c49
10 changed files with 1855 additions and 3 deletions

View File

@@ -4,10 +4,10 @@
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true"
CRD_OPTIONS ?= "crd:trivialVersions=true,allowDangerousTypes=true"
GV="network:v1alpha1 servicemesh:v1alpha2 tenant:v1alpha1 tenant:v1alpha2 devops:v1alpha1 iam:v1alpha2 devops:v1alpha3 cluster:v1alpha1 storage:v1alpha1 auditing:v1alpha1 types:v1beta1 types:v1beta2 quota:v1alpha2 application:v1alpha1 notification:v2beta1 notification:v2beta2 gateway:v1alpha1"
MANIFESTS="application/* cluster/* iam/* network/v1alpha1 quota/* storage/* tenant/* gateway/*"
GV="network:v1alpha1 servicemesh:v1alpha2 tenant:v1alpha1 tenant:v1alpha2 devops:v1alpha1 iam:v1alpha2 devops:v1alpha3 cluster:v1alpha1 storage:v1alpha1 auditing:v1alpha1 types:v1beta1 types:v1beta2 quota:v1alpha2 application:v1alpha1 notification:v2beta1 notification:v2beta2 gateway:v1alpha1 alerting:v2beta1"
MANIFESTS="application/* cluster/* iam/* network/v1alpha1 quota/* storage/* tenant/* gateway/* alerting/*"
# App Version
APP_VERSION = v3.2.0

View File

@@ -0,0 +1,174 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: (devel)
creationTimestamp: null
name: clusterrulegroups.alerting.kubesphere.io
spec:
group: alerting.kubesphere.io
names:
kind: ClusterRuleGroup
listKind: ClusterRuleGroupList
plural: clusterrulegroups
singular: clusterrulegroup
scope: Cluster
versions:
- name: v2beta1
schema:
openAPIV3Schema:
description: ClusterRuleGroup is the Schema for the ClusterRuleGroup API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ClusterRuleGroupSpec defines the desired state of ClusterRuleGroup
properties:
interval:
type: string
partial_response_strategy:
type: string
rules:
items:
properties:
alert:
type: string
annotations:
additionalProperties:
type: string
type: object
disable:
type: boolean
expr:
anyOf:
- type: integer
- type: string
x-kubernetes-int-or-string: true
exprBuilder:
description: If ExprBuilder is not nil, the configured Expr
will be ignored
properties:
node:
properties:
comparator:
type: string
metricThreshold:
description: Only one of its members may be specified.
properties:
cpu:
description: Only one of its members may be specified.
properties:
load15m:
type: number
load1m:
type: number
load5m:
type: number
utilization:
type: number
type: object
disk:
description: Only one of its members may be specified.
properties:
inodeUtilization:
type: number
iopsRead:
description: The unit is io/s
type: number
iopsWrite:
description: The unit is io/s
type: number
spaceAvailable:
description: The unit is bytes
type: number
spaceUtilization:
type: number
throughputRead:
description: The unit is bytes/s
type: number
throughputWrite:
description: The unit is bytes/s
type: number
type: object
memory:
description: Only one of its members may be specified.
properties:
available:
description: The unit is bytes
type: number
utilization:
type: number
type: object
network:
description: Only one of its members may be specified.
properties:
receivedRate:
description: The unit is bit/s
type: number
transmittedRate:
description: The unit is bit/s
type: number
type: object
pod:
description: Only one of its members may be specified.
properties:
abnormalRatio:
type: number
utilization:
type: number
type: object
type: object
names:
items:
type: string
type: array
required:
- comparator
- metricThreshold
- names
type: object
type: object
for:
description: 'Duration is a valid time unit Supported units:
y, w, d, h, m, s, ms Examples: `30s`, `1m`, `1h20m15s`'
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
labels:
additionalProperties:
type: string
type: object
severity:
type: string
required:
- alert
type: object
type: array
required:
- rules
type: object
status:
description: ClusterRuleGroupStatus defines the observed state of ClusterRuleGroup
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

View File

@@ -0,0 +1,90 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: (devel)
creationTimestamp: null
name: globalrulegroups.alerting.kubesphere.io
spec:
group: alerting.kubesphere.io
names:
kind: GlobalRuleGroup
listKind: GlobalRuleGroupList
plural: globalrulegroups
singular: globalrulegroup
scope: Cluster
versions:
- name: v2beta1
schema:
openAPIV3Schema:
description: GlobalRuleGroup is the Schema for the GlobalRuleGroup API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: GlobalRuleGroupSpec defines the desired state of GlobalRuleGroup
properties:
interval:
type: string
partial_response_strategy:
type: string
rules:
items:
properties:
alert:
type: string
annotations:
additionalProperties:
type: string
type: object
disable:
type: boolean
expr:
anyOf:
- type: integer
- type: string
x-kubernetes-int-or-string: true
for:
description: 'Duration is a valid time unit Supported units:
y, w, d, h, m, s, ms Examples: `30s`, `1m`, `1h20m15s`'
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
labels:
additionalProperties:
type: string
type: object
severity:
type: string
required:
- alert
type: object
type: array
required:
- rules
type: object
status:
description: GlobalRuleGroupStatus defines the observed state of GlobalRuleGroup
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

View File

@@ -0,0 +1,149 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: (devel)
creationTimestamp: null
name: rulegroups.alerting.kubesphere.io
spec:
group: alerting.kubesphere.io
names:
kind: RuleGroup
listKind: RuleGroupList
plural: rulegroups
singular: rulegroup
scope: Namespaced
versions:
- name: v2beta1
schema:
openAPIV3Schema:
description: RuleGroup is the Schema for the RuleGroup API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: RuleGroupSpec defines the desired state of RuleGroup
properties:
interval:
type: string
partial_response_strategy:
type: string
rules:
items:
properties:
alert:
type: string
annotations:
additionalProperties:
type: string
type: object
disable:
type: boolean
expr:
anyOf:
- type: integer
- type: string
x-kubernetes-int-or-string: true
exprBuilder:
description: If ExprBuilder is not nil, the configured Expr
will be ignored
properties:
workload:
properties:
comparator:
type: string
kind:
type: string
metricThreshold:
description: Only one of its members may be specified.
properties:
cpu:
description: Only one of its members may be specified.
properties:
usage:
description: The unit is core
type: number
type: object
memory:
description: Only one of its members may be specified.
properties:
usage:
description: The memory usage contains cache
The unit is bytes
type: number
usageWoCache:
description: The memory usage contains no cache
The unit is bytes
type: number
type: object
network:
description: Only one of its members may be specified.
properties:
receivedRate:
description: The unit is bit/s
type: number
transmittedRate:
description: The unit is bit/s
type: number
type: object
replica:
description: Only one of its members may be specified.
properties:
unavailableRatio:
type: number
type: object
type: object
names:
items:
type: string
type: array
required:
- comparator
- kind
- names
type: object
type: object
for:
description: 'Duration is a valid time unit Supported units:
y, w, d, h, m, s, ms Examples: `30s`, `1m`, `1h20m15s`'
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
labels:
additionalProperties:
type: string
type: object
severity:
type: string
required:
- alert
type: object
type: array
required:
- rules
type: object
status:
description: RuleGroupStatus defines the observed state of RuleGroup
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

View File

@@ -0,0 +1,18 @@
/*
Copyright 2020 The KubeSphere 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.
*/
// Package alerting contains alerting API versions
package alerting

View File

@@ -0,0 +1,20 @@
/*
Copyright 2021 The KubeSphere 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.
*/
// Package v2beta1 contains API Schema definitions for the alerting v2beta1 API group
// +groupName=alerting.kubesphere.io
// +k8s:deepcopy-gen=package,register
package v2beta1

View File

@@ -0,0 +1,55 @@
/*
Copyright 2020 KubeSphere 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.
*/
/*
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.
*/
// Package v2beta1 contains API Schema definitions for the alerting v2beta1 API group
//+kubebuilder:object:generate=true
//+groupName=alerting.kubesphere.io
package v2beta1
import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)
var (
// GroupVersion is group version used to register these objects
SchemeGroupVersion = schema.GroupVersion{Group: "alerting.kubesphere.io", Version: "v2beta1"}
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}

View File

@@ -0,0 +1,506 @@
/*
Copyright 2020 KubeSphere 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.
*/
package v2beta1
import (
"fmt"
"strings"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)
// Duration is a valid time unit
// Supported units: y, w, d, h, m, s, ms Examples: `30s`, `1m`, `1h20m15s`
// +kubebuilder:validation:Pattern:="^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$"
type Duration string
type Comparator string
type Severity string
const (
ComparatorLT Comparator = "<"
ComparatorLE Comparator = "<="
ComparatorGT Comparator = ">"
ComparatorGE Comparator = ">="
SeverityWarning Severity = "warning"
SeverityError Severity = "error"
SeverityCritical Severity = "critical"
)
type Rule struct {
Alert string `json:"alert"`
Expr intstr.IntOrString `json:"expr,omitempty"`
For Duration `json:"for,omitempty"`
Severity Severity `json:"severity,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
Disable bool `json:"disable,omitempty"`
}
type NamespaceRule struct {
Rule `json:",inline"`
// If ExprBuilder is not nil, the configured Expr will be ignored
ExprBuilder *NamespaceRuleExprBuilder `json:"exprBuilder,omitempty"`
}
type ClusterRule struct {
Rule `json:",inline"`
// If ExprBuilder is not nil, the configured Expr will be ignored
ExprBuilder *ClusterRuleExprBuilder `json:"exprBuilder,omitempty"`
}
type GlobalRule struct {
Rule `json:",inline"`
}
type NamespaceRuleExprBuilder struct {
Workload *WorkloadExprBuilder `json:"workload,omitempty"`
}
type ClusterRuleExprBuilder struct {
Node *NodeExprBuilder `json:"node,omitempty"`
}
type WorkloadKind string
const (
WorkloadDeployment WorkloadKind = "deployment"
WorkloadStatefulSet WorkloadKind = "statefulset"
WorkloadDaemonSet WorkloadKind = "daemonset"
)
type WorkloadExprBuilder struct {
WorkloadKind WorkloadKind `json:"kind"`
WorkloadNames []string `json:"names"`
Comparator Comparator `json:"comparator"`
MetricThreshold WorkloadMetricThreshold `json:"metricThreshold,omitempty"`
}
const (
MetricWorkloadCpuUsage = "namespace:workload_cpu_usage:sum"
MetricWorkloadMemoryUsage = "namespace:workload_memory_usage:sum"
MetricWorkloadMemoryUsageWoCache = "namespace:workload_memory_usage_wo_cache:sum"
MetricWorkloadNetworkTransmittedRate = "namespace:workload_net_bytes_transmitted:sum_irate"
MetricWorkloadNetworkReceivedRate = "namespace:workload_net_bytes_received:sum_irate"
MetricWorkloadPodUnavailableRatio = "namespace:%s_unavailable_replicas:ratio" // "%s" must be one of "deployment", "statefulset" and "daemonset"
)
func (b *WorkloadExprBuilder) Build() string {
if b == nil {
return ""
}
if b.WorkloadKind == "" || len(b.WorkloadNames) == 0 || b.Comparator == "" {
return ""
}
var (
threshold float64
metric string
)
switch {
case b.MetricThreshold.Cpu != nil:
var cpu = b.MetricThreshold.Cpu
if cpu.Usage != nil {
metric = MetricWorkloadCpuUsage
threshold = *cpu.Usage
}
case b.MetricThreshold.Memory != nil:
var memory = b.MetricThreshold.Memory
switch {
case memory.Usage != nil:
metric = MetricWorkloadMemoryUsage
threshold = *memory.Usage
case memory.UsageWoCache != nil:
metric = MetricWorkloadMemoryUsageWoCache
threshold = *memory.UsageWoCache
}
case b.MetricThreshold.Network != nil:
var network = b.MetricThreshold.Network
switch {
case network.TransmittedRate != nil:
metric = MetricWorkloadNetworkTransmittedRate
threshold = *network.TransmittedRate
case network.ReceivedRate != nil:
metric = MetricWorkloadNetworkReceivedRate
threshold = *network.ReceivedRate
}
case b.MetricThreshold.Replica != nil:
var replica = b.MetricThreshold.Replica
if replica.UnavailableRatio != nil {
metric = fmt.Sprintf(MetricWorkloadPodUnavailableRatio, strings.ToLower(string(b.WorkloadKind)))
threshold = *replica.UnavailableRatio
}
}
if metric != "" {
var filter string
if len(b.WorkloadNames) == 1 {
filter = fmt.Sprintf(`{workload="%s:%s"}`, b.WorkloadKind, b.WorkloadNames[0])
} else {
filter = fmt.Sprintf(`{workload=~"%s:(%s)"}`, b.WorkloadKind, strings.Join(b.WorkloadNames, "|"))
}
return metric + fmt.Sprintf("%s %s %v", filter, b.Comparator, threshold)
}
return ""
}
// Only one of its members may be specified.
type WorkloadMetricThreshold struct {
Cpu *WorkloadCpuThreshold `json:"cpu,omitempty"`
Memory *WorkloadMemoryThreshold `json:"memory,omitempty"`
Network *WorkloadNetworkThreshold `json:"network,omitempty"`
Replica *WorkloadReplicaThreshold `json:"replica,omitempty"`
}
// Only one of its members may be specified.
type WorkloadCpuThreshold struct {
// The unit is core
Usage *float64 `json:"usage,omitempty"`
}
// Only one of its members may be specified.
type WorkloadMemoryThreshold struct {
// The memory usage contains cache
// The unit is bytes
Usage *float64 `json:"usage,omitempty"`
// The memory usage contains no cache
// The unit is bytes
UsageWoCache *float64 `json:"usageWoCache,omitempty"`
}
// Only one of its members may be specified.
type WorkloadNetworkThreshold struct {
// The unit is bit/s
TransmittedRate *float64 `json:"transmittedRate,omitempty"`
// The unit is bit/s
ReceivedRate *float64 `json:"receivedRate,omitempty"`
}
// Only one of its members may be specified.
type WorkloadReplicaThreshold struct {
UnavailableRatio *float64 `json:"unavailableRatio,omitempty"`
}
type NodeExprBuilder struct {
NodeNames []string `json:"names"`
Comparator Comparator `json:"comparator"`
MetricThreshold NodeMetricThreshold `json:"metricThreshold"`
}
const (
MetricNodeCpuUtilization = "node:node_cpu_utilisation:avg1m"
MetricNodeCpuLoad1m = "node:load1:ratio"
MetricNodeCpuLoad5m = "node:load5:ratio"
MetricNodeCpuLoad15m = "node:load15:ratio"
MetricNodeMemoryUtilization = "node:node_memory_utilisation:"
MetricNodeMemoryAvailable = "node:node_memory_bytes_available:sum"
MetricNodeNetworkTransmittedRate = "node:node_net_bytes_transmitted:sum_irate"
MetricNodeNetwrokReceivedRate = "node:node_net_bytes_received:sum_irate"
MetricNodeDiskSpaceUtilization = "node:disk_space_utilization:ratio"
MetricNodeDiskSpaceAvailable = "node:disk_space_available:"
MetricNodeDiskInodeUtilization = "node:disk_inode_utilization:ratio"
MetricNodeDiskIopsRead = "node:data_volume_iops_reads:sum"
MetricNodeDiskIopsWrite = "node:data_volume_iops_writes:sum"
MetricNodeDiskThroughputRead = "node:data_volume_throughput_bytes_read:sum"
MetricNodeDiskThroughputWrite = "node:data_volume_throughput_bytes_write:sum"
MetricNodePodUtilization = "node:pod_utilization:ratio"
MetricNodePodAbnormalRatio = "node:pod_abnormal:ratio"
)
func (b *NodeExprBuilder) Build() string {
if len(b.NodeNames) == 0 || b.Comparator == "" {
return ""
}
var (
threshold float64
metric string
)
switch {
case b.MetricThreshold.Cpu != nil:
var cpu = b.MetricThreshold.Cpu
switch {
case cpu.Utilization != nil:
metric = MetricNodeCpuUtilization
threshold = *cpu.Utilization
case cpu.Load1m != nil:
metric = MetricNodeCpuLoad1m
threshold = *cpu.Load1m
case cpu.Load5m != nil:
metric = MetricNodeCpuLoad5m
threshold = *cpu.Load5m
case cpu.Load15m != nil:
metric = MetricNodeCpuLoad15m
threshold = *cpu.Load15m
}
case b.MetricThreshold.Memory != nil:
var memory = b.MetricThreshold.Memory
switch {
case memory.Utilization != nil:
metric = MetricNodeMemoryUtilization
threshold = *memory.Utilization
case memory.Available != nil:
metric = MetricNodeMemoryAvailable
threshold = *memory.Available
}
case b.MetricThreshold.Network != nil:
var network = b.MetricThreshold.Network
switch {
case network.TransmittedRate != nil:
metric = MetricNodeNetworkTransmittedRate
threshold = *network.TransmittedRate
case network.ReceivedRate != nil:
metric = MetricNodeNetwrokReceivedRate
threshold = *network.ReceivedRate
}
case b.MetricThreshold.Disk != nil:
var disk = b.MetricThreshold.Disk
switch {
case disk.SpaceUtilization != nil:
metric = MetricNodeDiskSpaceUtilization
threshold = *disk.SpaceUtilization
case disk.SpaceAvailable != nil:
metric = MetricNodeDiskSpaceAvailable
threshold = *disk.SpaceAvailable
case disk.InodeUtilization != nil:
metric = MetricNodeDiskInodeUtilization
threshold = *disk.InodeUtilization
case disk.IopsRead != nil:
metric = MetricNodeDiskIopsRead
threshold = *disk.IopsRead
case disk.IopsWrite != nil:
metric = MetricNodeDiskIopsWrite
threshold = *disk.IopsWrite
case disk.ThroughputRead != nil:
metric = MetricNodeDiskThroughputRead
threshold = *disk.ThroughputRead
case disk.ThroughputWrite != nil:
metric = MetricNodeDiskThroughputWrite
threshold = *disk.ThroughputWrite
}
case b.MetricThreshold.Pod != nil:
var pod = b.MetricThreshold.Pod
switch {
case pod.Utilization != nil:
metric = MetricNodePodUtilization
threshold = *pod.Utilization
case pod.AbnormalRatio != nil:
metric = MetricNodePodAbnormalRatio
threshold = *pod.AbnormalRatio
}
}
if metric != "" {
var filter string
if len(b.NodeNames) == 1 {
filter = fmt.Sprintf(`{node="%s"}`, b.NodeNames[0])
} else {
filter = fmt.Sprintf(`{node=~"(%s)"}`, strings.Join(b.NodeNames, "|"))
}
return metric + fmt.Sprintf("%s %s %v", filter, b.Comparator, threshold)
}
return ""
}
// Only one of its members may be specified.
type NodeMetricThreshold struct {
Cpu *NodeCpuThreshold `json:"cpu,omitempty"`
Memory *NodeMemoryThreshold `json:"memory,omitempty"`
Network *NodeNetworkThreshold `json:"network,omitempty"`
Disk *NodeDiskThreshold `json:"disk,omitempty"`
Pod *NodePodThreshold `json:"pod,omitempty"`
}
// Only one of its members may be specified.
type NodeCpuThreshold struct {
Utilization *float64 `json:"utilization,omitempty"`
Load1m *float64 `json:"load1m,omitempty"`
Load5m *float64 `json:"load5m,omitempty"`
Load15m *float64 `json:"load15m,omitempty"`
}
// Only one of its members may be specified.
type NodeMemoryThreshold struct {
Utilization *float64 `json:"utilization,omitempty"`
// The unit is bytes
Available *float64 `json:"available,omitempty"`
}
// Only one of its members may be specified.
type NodePodThreshold struct {
Utilization *float64 `json:"utilization,omitempty"`
AbnormalRatio *float64 `json:"abnormalRatio,omitempty"`
}
// Only one of its members may be specified.
type NodeDiskThreshold struct {
SpaceUtilization *float64 `json:"spaceUtilization,omitempty"`
// The unit is bytes
SpaceAvailable *float64 `json:"spaceAvailable,omitempty"`
InodeUtilization *float64 `json:"inodeUtilization,omitempty"`
// The unit is io/s
IopsRead *float64 `json:"iopsRead,omitempty"`
// The unit is io/s
IopsWrite *float64 `json:"iopsWrite,omitempty"`
// The unit is bytes/s
ThroughputRead *float64 `json:"throughputRead,omitempty"`
// The unit is bytes/s
ThroughputWrite *float64 `json:"throughputWrite,omitempty"`
}
// Only one of its members may be specified.
type NodeNetworkThreshold struct {
// The unit is bit/s
TransmittedRate *float64 `json:"transmittedRate,omitempty"`
// The unit is bit/s
ReceivedRate *float64 `json:"receivedRate,omitempty"`
}
// RuleGroupSpec defines the desired state of RuleGroup
type RuleGroupSpec struct {
Interval string `json:"interval,omitempty"`
PartialResponseStrategy string `json:"partial_response_strategy,omitempty"`
Rules []NamespaceRule `json:"rules"`
}
// RuleGroupStatus defines the observed state of RuleGroup
type RuleGroupStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
// +genclient
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// RuleGroup is the Schema for the RuleGroup API
type RuleGroup struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec RuleGroupSpec `json:"spec,omitempty"`
Status RuleGroupStatus `json:"status,omitempty"`
}
//+kubebuilder:object:root=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// RuleGroupList contains a list of RuleGroup
type RuleGroupList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []RuleGroup `json:"items"`
}
// ClusterRuleGroupSpec defines the desired state of ClusterRuleGroup
type ClusterRuleGroupSpec struct {
Interval string `json:"interval,omitempty"`
PartialResponseStrategy string `json:"partial_response_strategy,omitempty"`
Rules []ClusterRule `json:"rules"`
}
// ClusterRuleGroupStatus defines the observed state of ClusterRuleGroup
type ClusterRuleGroupStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:resource:scope=Cluster
// ClusterRuleGroup is the Schema for the ClusterRuleGroup API
type ClusterRuleGroup struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ClusterRuleGroupSpec `json:"spec,omitempty"`
Status ClusterRuleGroupStatus `json:"status,omitempty"`
}
//+kubebuilder:object:root=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ClusterRuleGroupList contains a list of ClusterRuleGroup
type ClusterRuleGroupList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ClusterRuleGroup `json:"items"`
}
// GlobalRuleGroupSpec defines the desired state of GlobalRuleGroup
type GlobalRuleGroupSpec struct {
Interval string `json:"interval,omitempty"`
PartialResponseStrategy string `json:"partial_response_strategy,omitempty"`
Rules []GlobalRule `json:"rules"`
}
// GlobalRuleGroupStatus defines the observed state of GlobalRuleGroup
type GlobalRuleGroupStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:resource:scope=Cluster
// GlobalRuleGroup is the Schema for the GlobalRuleGroup API
type GlobalRuleGroup struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec GlobalRuleGroupSpec `json:"spec,omitempty"`
Status GlobalRuleGroupStatus `json:"status,omitempty"`
}
//+kubebuilder:object:root=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// GlobalRuleGroupList contains a list of GlobalRuleGroup
type GlobalRuleGroupList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []GlobalRuleGroup `json:"items"`
}
func init() {
SchemeBuilder.Register(&RuleGroup{}, &RuleGroupList{})
SchemeBuilder.Register(&ClusterRuleGroup{}, &ClusterRuleGroupList{})
SchemeBuilder.Register(&GlobalRuleGroup{}, &GlobalRuleGroupList{})
}

View File

@@ -0,0 +1,839 @@
// +build !ignore_autogenerated
/*
Copyright 2020 The KubeSphere 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.
*/
// Code generated by deepcopy-gen. DO NOT EDIT.
package v2beta1
import (
runtime "k8s.io/apimachinery/pkg/runtime"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterRule) DeepCopyInto(out *ClusterRule) {
*out = *in
in.Rule.DeepCopyInto(&out.Rule)
if in.ExprBuilder != nil {
in, out := &in.ExprBuilder, &out.ExprBuilder
*out = new(ClusterRuleExprBuilder)
(*in).DeepCopyInto(*out)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterRule.
func (in *ClusterRule) DeepCopy() *ClusterRule {
if in == nil {
return nil
}
out := new(ClusterRule)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterRuleExprBuilder) DeepCopyInto(out *ClusterRuleExprBuilder) {
*out = *in
if in.Node != nil {
in, out := &in.Node, &out.Node
*out = new(NodeExprBuilder)
(*in).DeepCopyInto(*out)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterRuleExprBuilder.
func (in *ClusterRuleExprBuilder) DeepCopy() *ClusterRuleExprBuilder {
if in == nil {
return nil
}
out := new(ClusterRuleExprBuilder)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterRuleGroup) DeepCopyInto(out *ClusterRuleGroup) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
out.Status = in.Status
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterRuleGroup.
func (in *ClusterRuleGroup) DeepCopy() *ClusterRuleGroup {
if in == nil {
return nil
}
out := new(ClusterRuleGroup)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ClusterRuleGroup) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterRuleGroupList) DeepCopyInto(out *ClusterRuleGroupList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]ClusterRuleGroup, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterRuleGroupList.
func (in *ClusterRuleGroupList) DeepCopy() *ClusterRuleGroupList {
if in == nil {
return nil
}
out := new(ClusterRuleGroupList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ClusterRuleGroupList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterRuleGroupSpec) DeepCopyInto(out *ClusterRuleGroupSpec) {
*out = *in
if in.Rules != nil {
in, out := &in.Rules, &out.Rules
*out = make([]ClusterRule, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterRuleGroupSpec.
func (in *ClusterRuleGroupSpec) DeepCopy() *ClusterRuleGroupSpec {
if in == nil {
return nil
}
out := new(ClusterRuleGroupSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterRuleGroupStatus) DeepCopyInto(out *ClusterRuleGroupStatus) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterRuleGroupStatus.
func (in *ClusterRuleGroupStatus) DeepCopy() *ClusterRuleGroupStatus {
if in == nil {
return nil
}
out := new(ClusterRuleGroupStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GlobalRule) DeepCopyInto(out *GlobalRule) {
*out = *in
in.Rule.DeepCopyInto(&out.Rule)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GlobalRule.
func (in *GlobalRule) DeepCopy() *GlobalRule {
if in == nil {
return nil
}
out := new(GlobalRule)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GlobalRuleGroup) DeepCopyInto(out *GlobalRuleGroup) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
out.Status = in.Status
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GlobalRuleGroup.
func (in *GlobalRuleGroup) DeepCopy() *GlobalRuleGroup {
if in == nil {
return nil
}
out := new(GlobalRuleGroup)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *GlobalRuleGroup) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GlobalRuleGroupList) DeepCopyInto(out *GlobalRuleGroupList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]GlobalRuleGroup, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GlobalRuleGroupList.
func (in *GlobalRuleGroupList) DeepCopy() *GlobalRuleGroupList {
if in == nil {
return nil
}
out := new(GlobalRuleGroupList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *GlobalRuleGroupList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GlobalRuleGroupSpec) DeepCopyInto(out *GlobalRuleGroupSpec) {
*out = *in
if in.Rules != nil {
in, out := &in.Rules, &out.Rules
*out = make([]GlobalRule, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GlobalRuleGroupSpec.
func (in *GlobalRuleGroupSpec) DeepCopy() *GlobalRuleGroupSpec {
if in == nil {
return nil
}
out := new(GlobalRuleGroupSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GlobalRuleGroupStatus) DeepCopyInto(out *GlobalRuleGroupStatus) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GlobalRuleGroupStatus.
func (in *GlobalRuleGroupStatus) DeepCopy() *GlobalRuleGroupStatus {
if in == nil {
return nil
}
out := new(GlobalRuleGroupStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NamespaceRule) DeepCopyInto(out *NamespaceRule) {
*out = *in
in.Rule.DeepCopyInto(&out.Rule)
if in.ExprBuilder != nil {
in, out := &in.ExprBuilder, &out.ExprBuilder
*out = new(NamespaceRuleExprBuilder)
(*in).DeepCopyInto(*out)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NamespaceRule.
func (in *NamespaceRule) DeepCopy() *NamespaceRule {
if in == nil {
return nil
}
out := new(NamespaceRule)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NamespaceRuleExprBuilder) DeepCopyInto(out *NamespaceRuleExprBuilder) {
*out = *in
if in.Workload != nil {
in, out := &in.Workload, &out.Workload
*out = new(WorkloadExprBuilder)
(*in).DeepCopyInto(*out)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NamespaceRuleExprBuilder.
func (in *NamespaceRuleExprBuilder) DeepCopy() *NamespaceRuleExprBuilder {
if in == nil {
return nil
}
out := new(NamespaceRuleExprBuilder)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NodeCpuThreshold) DeepCopyInto(out *NodeCpuThreshold) {
*out = *in
if in.Utilization != nil {
in, out := &in.Utilization, &out.Utilization
*out = new(float64)
**out = **in
}
if in.Load1m != nil {
in, out := &in.Load1m, &out.Load1m
*out = new(float64)
**out = **in
}
if in.Load5m != nil {
in, out := &in.Load5m, &out.Load5m
*out = new(float64)
**out = **in
}
if in.Load15m != nil {
in, out := &in.Load15m, &out.Load15m
*out = new(float64)
**out = **in
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeCpuThreshold.
func (in *NodeCpuThreshold) DeepCopy() *NodeCpuThreshold {
if in == nil {
return nil
}
out := new(NodeCpuThreshold)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NodeDiskThreshold) DeepCopyInto(out *NodeDiskThreshold) {
*out = *in
if in.SpaceUtilization != nil {
in, out := &in.SpaceUtilization, &out.SpaceUtilization
*out = new(float64)
**out = **in
}
if in.SpaceAvailable != nil {
in, out := &in.SpaceAvailable, &out.SpaceAvailable
*out = new(float64)
**out = **in
}
if in.InodeUtilization != nil {
in, out := &in.InodeUtilization, &out.InodeUtilization
*out = new(float64)
**out = **in
}
if in.IopsRead != nil {
in, out := &in.IopsRead, &out.IopsRead
*out = new(float64)
**out = **in
}
if in.IopsWrite != nil {
in, out := &in.IopsWrite, &out.IopsWrite
*out = new(float64)
**out = **in
}
if in.ThroughputRead != nil {
in, out := &in.ThroughputRead, &out.ThroughputRead
*out = new(float64)
**out = **in
}
if in.ThroughputWrite != nil {
in, out := &in.ThroughputWrite, &out.ThroughputWrite
*out = new(float64)
**out = **in
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeDiskThreshold.
func (in *NodeDiskThreshold) DeepCopy() *NodeDiskThreshold {
if in == nil {
return nil
}
out := new(NodeDiskThreshold)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NodeExprBuilder) DeepCopyInto(out *NodeExprBuilder) {
*out = *in
if in.NodeNames != nil {
in, out := &in.NodeNames, &out.NodeNames
*out = make([]string, len(*in))
copy(*out, *in)
}
in.MetricThreshold.DeepCopyInto(&out.MetricThreshold)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeExprBuilder.
func (in *NodeExprBuilder) DeepCopy() *NodeExprBuilder {
if in == nil {
return nil
}
out := new(NodeExprBuilder)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NodeMemoryThreshold) DeepCopyInto(out *NodeMemoryThreshold) {
*out = *in
if in.Utilization != nil {
in, out := &in.Utilization, &out.Utilization
*out = new(float64)
**out = **in
}
if in.Available != nil {
in, out := &in.Available, &out.Available
*out = new(float64)
**out = **in
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeMemoryThreshold.
func (in *NodeMemoryThreshold) DeepCopy() *NodeMemoryThreshold {
if in == nil {
return nil
}
out := new(NodeMemoryThreshold)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NodeMetricThreshold) DeepCopyInto(out *NodeMetricThreshold) {
*out = *in
if in.Cpu != nil {
in, out := &in.Cpu, &out.Cpu
*out = new(NodeCpuThreshold)
(*in).DeepCopyInto(*out)
}
if in.Memory != nil {
in, out := &in.Memory, &out.Memory
*out = new(NodeMemoryThreshold)
(*in).DeepCopyInto(*out)
}
if in.Network != nil {
in, out := &in.Network, &out.Network
*out = new(NodeNetworkThreshold)
(*in).DeepCopyInto(*out)
}
if in.Disk != nil {
in, out := &in.Disk, &out.Disk
*out = new(NodeDiskThreshold)
(*in).DeepCopyInto(*out)
}
if in.Pod != nil {
in, out := &in.Pod, &out.Pod
*out = new(NodePodThreshold)
(*in).DeepCopyInto(*out)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeMetricThreshold.
func (in *NodeMetricThreshold) DeepCopy() *NodeMetricThreshold {
if in == nil {
return nil
}
out := new(NodeMetricThreshold)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NodeNetworkThreshold) DeepCopyInto(out *NodeNetworkThreshold) {
*out = *in
if in.TransmittedRate != nil {
in, out := &in.TransmittedRate, &out.TransmittedRate
*out = new(float64)
**out = **in
}
if in.ReceivedRate != nil {
in, out := &in.ReceivedRate, &out.ReceivedRate
*out = new(float64)
**out = **in
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeNetworkThreshold.
func (in *NodeNetworkThreshold) DeepCopy() *NodeNetworkThreshold {
if in == nil {
return nil
}
out := new(NodeNetworkThreshold)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NodePodThreshold) DeepCopyInto(out *NodePodThreshold) {
*out = *in
if in.Utilization != nil {
in, out := &in.Utilization, &out.Utilization
*out = new(float64)
**out = **in
}
if in.AbnormalRatio != nil {
in, out := &in.AbnormalRatio, &out.AbnormalRatio
*out = new(float64)
**out = **in
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodePodThreshold.
func (in *NodePodThreshold) DeepCopy() *NodePodThreshold {
if in == nil {
return nil
}
out := new(NodePodThreshold)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Rule) DeepCopyInto(out *Rule) {
*out = *in
out.Expr = in.Expr
if in.Labels != nil {
in, out := &in.Labels, &out.Labels
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
if in.Annotations != nil {
in, out := &in.Annotations, &out.Annotations
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Rule.
func (in *Rule) DeepCopy() *Rule {
if in == nil {
return nil
}
out := new(Rule)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RuleGroup) DeepCopyInto(out *RuleGroup) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
out.Status = in.Status
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RuleGroup.
func (in *RuleGroup) DeepCopy() *RuleGroup {
if in == nil {
return nil
}
out := new(RuleGroup)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *RuleGroup) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RuleGroupList) DeepCopyInto(out *RuleGroupList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]RuleGroup, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RuleGroupList.
func (in *RuleGroupList) DeepCopy() *RuleGroupList {
if in == nil {
return nil
}
out := new(RuleGroupList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *RuleGroupList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RuleGroupSpec) DeepCopyInto(out *RuleGroupSpec) {
*out = *in
if in.Rules != nil {
in, out := &in.Rules, &out.Rules
*out = make([]NamespaceRule, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RuleGroupSpec.
func (in *RuleGroupSpec) DeepCopy() *RuleGroupSpec {
if in == nil {
return nil
}
out := new(RuleGroupSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RuleGroupStatus) DeepCopyInto(out *RuleGroupStatus) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RuleGroupStatus.
func (in *RuleGroupStatus) DeepCopy() *RuleGroupStatus {
if in == nil {
return nil
}
out := new(RuleGroupStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *WorkloadCpuThreshold) DeepCopyInto(out *WorkloadCpuThreshold) {
*out = *in
if in.Usage != nil {
in, out := &in.Usage, &out.Usage
*out = new(float64)
**out = **in
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkloadCpuThreshold.
func (in *WorkloadCpuThreshold) DeepCopy() *WorkloadCpuThreshold {
if in == nil {
return nil
}
out := new(WorkloadCpuThreshold)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *WorkloadExprBuilder) DeepCopyInto(out *WorkloadExprBuilder) {
*out = *in
if in.WorkloadNames != nil {
in, out := &in.WorkloadNames, &out.WorkloadNames
*out = make([]string, len(*in))
copy(*out, *in)
}
in.MetricThreshold.DeepCopyInto(&out.MetricThreshold)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkloadExprBuilder.
func (in *WorkloadExprBuilder) DeepCopy() *WorkloadExprBuilder {
if in == nil {
return nil
}
out := new(WorkloadExprBuilder)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *WorkloadMemoryThreshold) DeepCopyInto(out *WorkloadMemoryThreshold) {
*out = *in
if in.Usage != nil {
in, out := &in.Usage, &out.Usage
*out = new(float64)
**out = **in
}
if in.UsageWoCache != nil {
in, out := &in.UsageWoCache, &out.UsageWoCache
*out = new(float64)
**out = **in
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkloadMemoryThreshold.
func (in *WorkloadMemoryThreshold) DeepCopy() *WorkloadMemoryThreshold {
if in == nil {
return nil
}
out := new(WorkloadMemoryThreshold)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *WorkloadMetricThreshold) DeepCopyInto(out *WorkloadMetricThreshold) {
*out = *in
if in.Cpu != nil {
in, out := &in.Cpu, &out.Cpu
*out = new(WorkloadCpuThreshold)
(*in).DeepCopyInto(*out)
}
if in.Memory != nil {
in, out := &in.Memory, &out.Memory
*out = new(WorkloadMemoryThreshold)
(*in).DeepCopyInto(*out)
}
if in.Network != nil {
in, out := &in.Network, &out.Network
*out = new(WorkloadNetworkThreshold)
(*in).DeepCopyInto(*out)
}
if in.Replica != nil {
in, out := &in.Replica, &out.Replica
*out = new(WorkloadReplicaThreshold)
(*in).DeepCopyInto(*out)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkloadMetricThreshold.
func (in *WorkloadMetricThreshold) DeepCopy() *WorkloadMetricThreshold {
if in == nil {
return nil
}
out := new(WorkloadMetricThreshold)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *WorkloadNetworkThreshold) DeepCopyInto(out *WorkloadNetworkThreshold) {
*out = *in
if in.TransmittedRate != nil {
in, out := &in.TransmittedRate, &out.TransmittedRate
*out = new(float64)
**out = **in
}
if in.ReceivedRate != nil {
in, out := &in.ReceivedRate, &out.ReceivedRate
*out = new(float64)
**out = **in
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkloadNetworkThreshold.
func (in *WorkloadNetworkThreshold) DeepCopy() *WorkloadNetworkThreshold {
if in == nil {
return nil
}
out := new(WorkloadNetworkThreshold)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *WorkloadReplicaThreshold) DeepCopyInto(out *WorkloadReplicaThreshold) {
*out = *in
if in.UnavailableRatio != nil {
in, out := &in.UnavailableRatio, &out.UnavailableRatio
*out = new(float64)
**out = **in
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkloadReplicaThreshold.
func (in *WorkloadReplicaThreshold) DeepCopy() *WorkloadReplicaThreshold {
if in == nil {
return nil
}
out := new(WorkloadReplicaThreshold)
in.DeepCopyInto(out)
return out
}

1
vendor/modules.txt vendored
View File

@@ -1986,6 +1986,7 @@ k8s.io/utils/strings
k8s.io/utils/trace
# kubesphere.io/api v0.0.0 => ./staging/src/kubesphere.io/api
## explicit
kubesphere.io/api/alerting/v2beta1
kubesphere.io/api/application/crdinstall
kubesphere.io/api/application/v1alpha1
kubesphere.io/api/auditing/v1alpha1