-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Setup NodeMetric API Signed-off-by: Jason Liu <jasonliu747@gmail.com> * implement Watches for SetupWithManager Signed-off-by: Jason Liu <jasonliu747@gmail.com> * add test for nodemetric controller Signed-off-by: Jason Liu <jasonliu747@gmail.com>
- Loading branch information
1 parent
ac0d789
commit a3f4a11
Showing
29 changed files
with
1,402 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Copyright 2022 The Koordinator 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 v1alpha1 contains API Schema definitions for the slo v1alpha1 API group | ||
//+kubebuilder:object:generate=true | ||
//+groupName=slo.koordinator.sh | ||
package v1alpha1 | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"sigs.k8s.io/controller-runtime/pkg/scheme" | ||
) | ||
|
||
var ( | ||
// GroupVersion is group version used to register these objects | ||
GroupVersion = schema.GroupVersion{Group: "slo.koordinator.sh", Version: "v1alpha1"} | ||
|
||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme | ||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} | ||
|
||
// AddToScheme adds the types in this group-version to the given scheme. | ||
AddToScheme = SchemeBuilder.AddToScheme | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
Copyright 2022 The Koordinator 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 v1alpha1 | ||
|
||
import ( | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! | ||
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. | ||
|
||
type NodeMetricInfo struct { | ||
NodeUsage ResourceMap `json:"nodeUsage,omitempty"` | ||
} | ||
|
||
type PodMetricInfo struct { | ||
Name string `json:"name,omitempty"` | ||
Namespace string `json:"namespace,omitempty"` | ||
PodUsage ResourceMap `json:"podUsage,omitempty"` | ||
} | ||
|
||
type ResourceMap struct { | ||
corev1.ResourceList `json:"resources,omitempty"` | ||
} | ||
|
||
// NodeMetricSpec defines the desired state of NodeMetric | ||
type NodeMetricSpec struct{} | ||
|
||
// NodeMetricStatus defines the observed state of NodeMetric | ||
type NodeMetricStatus struct { | ||
// UpdateTime is the last time this NodeMetric was updated. | ||
UpdateTime *metav1.Time `json:"updateTime,omitempty"` | ||
|
||
// NodeMetric contains the metrics for this node. | ||
NodeMetric *NodeMetricInfo `json:"nodeMetric,omitempty"` | ||
|
||
// PodsMetric contains the metrics for pods belong to this node. | ||
PodsMetric []*PodMetricInfo `json:"podsMetric,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
// +kubebuilder:resource:scope=Cluster | ||
|
||
// NodeMetric is the Schema for the nodemetrics API | ||
type NodeMetric struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec NodeMetricSpec `json:"spec,omitempty"` | ||
Status NodeMetricStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// NodeMetricList contains a list of NodeMetric | ||
type NodeMetricList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []NodeMetric `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&NodeMetric{}, &NodeMetricList{}) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
Copyright 2022 The Koordinator 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 options | ||
|
||
import ( | ||
"flag" | ||
"time" | ||
) | ||
|
||
var ( | ||
PromAddr = flag.String("prom-addr", ":9316", "Port of prometheus server") | ||
LogFlushFreq = flag.Duration("log-flush-freq", 5*time.Second, "Maximum duration between log flushes") | ||
) |
Oops, something went wrong.