Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
f9c4b52a
Commit
f9c4b52a
authored
Feb 22, 2018
by
Karol Wychowaniec
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce External Metrics API
parent
e267f46c
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
415 additions
and
0 deletions
+415
-0
BUILD
staging/BUILD
+1
-0
BUILD
staging/src/k8s.io/metrics/pkg/apis/external_metrics/BUILD
+40
-0
doc.go
staging/src/k8s.io/metrics/pkg/apis/external_metrics/doc.go
+19
-0
BUILD
...rc/k8s.io/metrics/pkg/apis/external_metrics/install/BUILD
+32
-0
install.go
...s.io/metrics/pkg/apis/external_metrics/install/install.go
+43
-0
register.go
.../src/k8s.io/metrics/pkg/apis/external_metrics/register.go
+51
-0
types.go
...ing/src/k8s.io/metrics/pkg/apis/external_metrics/types.go
+60
-0
BUILD
...rc/k8s.io/metrics/pkg/apis/external_metrics/v1beta1/BUILD
+39
-0
doc.go
...c/k8s.io/metrics/pkg/apis/external_metrics/v1beta1/doc.go
+21
-0
register.go
....io/metrics/pkg/apis/external_metrics/v1beta1/register.go
+49
-0
types.go
...k8s.io/metrics/pkg/apis/external_metrics/v1beta1/types.go
+60
-0
No files found.
staging/BUILD
View file @
f9c4b52a
...
...
@@ -217,6 +217,7 @@ filegroup(
"//staging/src/k8s.io/code-generator/third_party/forked/golang/reflect:all-srcs",
"//staging/src/k8s.io/kube-aggregator:all-srcs",
"//staging/src/k8s.io/metrics/pkg/apis/custom_metrics:all-srcs",
"//staging/src/k8s.io/metrics/pkg/apis/external_metrics:all-srcs",
"//staging/src/k8s.io/metrics/pkg/apis/metrics:all-srcs",
"//staging/src/k8s.io/metrics/pkg/client/clientset_generated/clientset:all-srcs",
"//staging/src/k8s.io/metrics/pkg/client/custom_metrics:all-srcs",
...
...
staging/src/k8s.io/metrics/pkg/apis/external_metrics/BUILD
0 → 100644
View file @
f9c4b52a
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"doc.go",
"register.go",
"types.go",
"zz_generated.deepcopy.go",
],
importpath = "k8s.io/metrics/pkg/apis/external_metrics",
deps = [
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//staging/src/k8s.io/metrics/pkg/apis/external_metrics/install:all-srcs",
"//staging/src/k8s.io/metrics/pkg/apis/external_metrics/v1beta1:all-srcs",
],
tags = ["automanaged"],
)
staging/src/k8s.io/metrics/pkg/apis/external_metrics/doc.go
0 → 100644
View file @
f9c4b52a
/*
Copyright 2018 The Kubernetes 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.
*/
// +k8s:deepcopy-gen=package
// +groupName=external.metrics.k8s.io
package
external_metrics
staging/src/k8s.io/metrics/pkg/apis/external_metrics/install/BUILD
0 → 100644
View file @
f9c4b52a
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["install.go"],
importpath = "k8s.io/metrics/pkg/apis/external_metrics/install",
deps = [
"//vendor/k8s.io/apimachinery/pkg/apimachinery/announced:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apimachinery/registered:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/metrics/pkg/apis/external_metrics:go_default_library",
"//vendor/k8s.io/metrics/pkg/apis/external_metrics/v1beta1:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)
staging/src/k8s.io/metrics/pkg/apis/external_metrics/install/install.go
0 → 100644
View file @
f9c4b52a
/*
Copyright 2018 The Kubernetes 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 install installs the experimental API group, making it available as
// an option to all of the API encoding/decoding machinery.
package
install
import
(
"k8s.io/apimachinery/pkg/apimachinery/announced"
"k8s.io/apimachinery/pkg/apimachinery/registered"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/metrics/pkg/apis/external_metrics"
"k8s.io/metrics/pkg/apis/external_metrics/v1beta1"
)
// Install registers the API group and adds types to a scheme
func
Install
(
groupFactoryRegistry
announced
.
APIGroupFactoryRegistry
,
registry
*
registered
.
APIRegistrationManager
,
scheme
*
runtime
.
Scheme
)
{
if
err
:=
announced
.
NewGroupMetaFactory
(
&
announced
.
GroupMetaFactoryArgs
{
GroupName
:
external_metrics
.
GroupName
,
VersionPreferenceOrder
:
[]
string
{
v1beta1
.
SchemeGroupVersion
.
Version
},
AddInternalObjectsToScheme
:
external_metrics
.
AddToScheme
,
},
announced
.
VersionToSchemeFunc
{
v1beta1
.
SchemeGroupVersion
.
Version
:
v1beta1
.
AddToScheme
,
},
)
.
Announce
(
groupFactoryRegistry
)
.
RegisterAndEnable
(
registry
,
scheme
);
err
!=
nil
{
panic
(
err
)
}
}
staging/src/k8s.io/metrics/pkg/apis/external_metrics/register.go
0 → 100644
View file @
f9c4b52a
/*
Copyright 2018 The Kubernetes 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
external_metrics
import
(
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// GroupName is the group name use in this package
const
GroupName
=
"external.metrics.k8s.io"
// SchemeGroupVersion is group version used to register these objects
var
SchemeGroupVersion
=
schema
.
GroupVersion
{
Group
:
GroupName
,
Version
:
runtime
.
APIVersionInternal
}
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
func
Kind
(
kind
string
)
schema
.
GroupKind
{
return
SchemeGroupVersion
.
WithKind
(
kind
)
.
GroupKind
()
}
// Resource takes an unqualified resource and returns back a Group qualified GroupResource
func
Resource
(
resource
string
)
schema
.
GroupResource
{
return
SchemeGroupVersion
.
WithResource
(
resource
)
.
GroupResource
()
}
var
(
SchemeBuilder
=
runtime
.
NewSchemeBuilder
(
addKnownTypes
)
AddToScheme
=
SchemeBuilder
.
AddToScheme
)
func
addKnownTypes
(
scheme
*
runtime
.
Scheme
)
error
{
scheme
.
AddKnownTypes
(
SchemeGroupVersion
,
&
ExternalMetricValue
{},
&
ExternalMetricValueList
{},
)
return
nil
}
staging/src/k8s.io/metrics/pkg/apis/external_metrics/types.go
0 → 100644
View file @
f9c4b52a
/*
Copyright 2018 The Kubernetes 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
external_metrics
import
(
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// a list of values for a given metric for some set labels
type
ExternalMetricValueList
struct
{
metav1
.
TypeMeta
`json:",inline"`
metav1
.
ListMeta
`json:"metadata,omitempty"`
// value of the metric matching a given set of labels
Items
[]
ExternalMetricValue
`json:"items"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// a metric value for external metric
// A single metric value is identified by metric name and a set of string labels.
// For one metric there can be multiple values with different sets of labels.
type
ExternalMetricValue
struct
{
metav1
.
TypeMeta
`json:",inline"`
// the name of the metric
MetricName
string
`json:"metricName"`
// a set of labels that identify a single time series for the metric
MetricLabels
map
[
string
]
string
`json:"metricLabels"`
// indicates the time at which the metrics were produced
Timestamp
metav1
.
Time
`json:"timestamp"`
// indicates the window ([Timestamp-Window, Timestamp]) from
// which these metrics were calculated, when returning rate
// metrics calculated from cumulative metrics (or zero for
// non-calculated instantaneous metrics).
WindowSeconds
*
int64
`json:"window,omitempty"`
// the value of the metric
Value
resource
.
Quantity
`json:"value"`
}
staging/src/k8s.io/metrics/pkg/apis/external_metrics/v1beta1/BUILD
0 → 100644
View file @
f9c4b52a
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"doc.go",
"register.go",
"types.go",
"zz_generated.conversion.go",
"zz_generated.deepcopy.go",
],
importpath = "k8s.io/metrics/pkg/apis/external_metrics/v1beta1",
deps = [
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/metrics/pkg/apis/external_metrics:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)
staging/src/k8s.io/metrics/pkg/apis/external_metrics/v1beta1/doc.go
0 → 100644
View file @
f9c4b52a
/*
Copyright 2018 The Kubernetes 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.
*/
// +k8s:deepcopy-gen=package
// +k8s:conversion-gen=k8s.io/metrics/pkg/apis/external_metrics
// +k8s:openapi-gen=true
package
v1beta1
staging/src/k8s.io/metrics/pkg/apis/external_metrics/v1beta1/register.go
0 → 100644
View file @
f9c4b52a
/*
Copyright 2018 The Kubernetes 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
v1beta1
import
(
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// GroupName is the group name use in this package
const
GroupName
=
"external.metrics.k8s.io"
// SchemeGroupVersion is group version used to register these objects
var
SchemeGroupVersion
=
schema
.
GroupVersion
{
Group
:
GroupName
,
Version
:
"v1beta1"
}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func
Resource
(
resource
string
)
schema
.
GroupResource
{
return
SchemeGroupVersion
.
WithResource
(
resource
)
.
GroupResource
()
}
var
(
SchemeBuilder
=
runtime
.
NewSchemeBuilder
(
addKnownTypes
)
localSchemeBuilder
=
&
SchemeBuilder
AddToScheme
=
localSchemeBuilder
.
AddToScheme
)
func
addKnownTypes
(
scheme
*
runtime
.
Scheme
)
error
{
scheme
.
AddKnownTypes
(
SchemeGroupVersion
,
&
ExternalMetricValue
{},
&
ExternalMetricValueList
{},
)
metav1
.
AddToGroupVersion
(
scheme
,
SchemeGroupVersion
)
return
nil
}
staging/src/k8s.io/metrics/pkg/apis/external_metrics/v1beta1/types.go
0 → 100644
View file @
f9c4b52a
/*
Copyright 2018 The Kubernetes 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
v1beta1
import
(
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// a list of values for a given metric for some set labels
type
ExternalMetricValueList
struct
{
metav1
.
TypeMeta
`json:",inline"`
metav1
.
ListMeta
`json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// value of the metric matching a given set of labels
Items
[]
ExternalMetricValue
`json:"items" protobuf:"bytes,2,rep,name=items"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// a metric value for external metric
// A single metric value is identified by metric name and a set of string labels.
// For one metric there can be multiple values with different sets of labels.
type
ExternalMetricValue
struct
{
metav1
.
TypeMeta
`json:",inline"`
// the name of the metric
MetricName
string
`json:"metricName" protobuf:"bytes,1,name=metricName"`
// a set of labels that identify a single time series for the metric
MetricLabels
map
[
string
]
string
`json:"metricLabels" protobuf:"bytes,2,rep,name=metricLabels"`
// indicates the time at which the metrics were produced
Timestamp
metav1
.
Time
`json:"timestamp" protobuf:"bytes,3,name=timestamp"`
// indicates the window ([Timestamp-Window, Timestamp]) from
// which these metrics were calculated, when returning rate
// metrics calculated from cumulative metrics (or zero for
// non-calculated instantaneous metrics).
WindowSeconds
*
int64
`json:"window,omitempty" protobuf:"bytes,4,opt,name=window"`
// the value of the metric
Value
resource
.
Quantity
`json:"value" protobuf:"bytes,5,name=value"`
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment