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
9546ba9b
Commit
9546ba9b
authored
Nov 27, 2016
by
Irfan Ur Rehman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Federation] Register autoscaling apis to federation api server
parent
8d5227bb
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
86 additions
and
0 deletions
+86
-0
BUILD
federation/cmd/federation-apiserver/app/BUILD
+4
-0
autoscaling.go
federation/cmd/federation-apiserver/app/autoscaling.go
+51
-0
server.go
federation/cmd/federation-apiserver/app/server.go
+1
-0
BUILD
test/integration/federation/BUILD
+1
-0
server_test.go
test/integration/federation/server_test.go
+29
-0
No files found.
federation/cmd/federation-apiserver/app/BUILD
View file @
9546ba9b
...
...
@@ -10,6 +10,7 @@ load(
go_library(
name = "go_default_library",
srcs = [
"autoscaling.go",
"batch.go",
"core.go",
"extensions.go",
...
...
@@ -28,6 +29,8 @@ go_library(
"//federation/registry/cluster/etcd:go_default_library",
"//pkg/api:go_default_library",
"//pkg/api/install:go_default_library",
"//pkg/apis/autoscaling:go_default_library",
"//pkg/apis/autoscaling/install:go_default_library",
"//pkg/apis/batch:go_default_library",
"//pkg/apis/batch/install:go_default_library",
"//pkg/apis/extensions:go_default_library",
...
...
@@ -43,6 +46,7 @@ go_library(
"//pkg/genericapiserver/server/filters:go_default_library",
"//pkg/kubeapiserver:go_default_library",
"//pkg/kubeapiserver/admission:go_default_library",
"//pkg/registry/autoscaling/horizontalpodautoscaler/storage:go_default_library",
"//pkg/registry/batch/job/storage:go_default_library",
"//pkg/registry/cachesize:go_default_library",
"//pkg/registry/core/configmap/storage:go_default_library",
...
...
federation/cmd/federation-apiserver/app/autoscaling.go
0 → 100644
View file @
9546ba9b
/*
Copyright 2016 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
app
import
(
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/autoscaling"
_
"k8s.io/kubernetes/pkg/apis/autoscaling/install"
"k8s.io/kubernetes/pkg/genericapiserver/registry/generic"
"k8s.io/kubernetes/pkg/genericapiserver/registry/rest"
genericapiserver
"k8s.io/kubernetes/pkg/genericapiserver/server"
hpastorage
"k8s.io/kubernetes/pkg/registry/autoscaling/horizontalpodautoscaler/storage"
)
func
installAutoscalingAPIs
(
g
*
genericapiserver
.
GenericAPIServer
,
optsGetter
generic
.
RESTOptionsGetter
)
{
hpaStorage
,
hpaStatusStorage
:=
hpastorage
.
NewREST
(
optsGetter
)
autoscalingResources
:=
map
[
string
]
rest
.
Storage
{
"horizontalpodautoscalers"
:
hpaStorage
,
"horizontalpodautoscalers/status"
:
hpaStatusStorage
,
}
autoscalingGroupMeta
:=
api
.
Registry
.
GroupOrDie
(
autoscaling
.
GroupName
)
apiGroupInfo
:=
genericapiserver
.
APIGroupInfo
{
GroupMeta
:
*
autoscalingGroupMeta
,
VersionedResourcesStorageMap
:
map
[
string
]
map
[
string
]
rest
.
Storage
{
"v1"
:
autoscalingResources
,
},
OptionsExternalVersion
:
&
api
.
Registry
.
GroupOrDie
(
api
.
GroupName
)
.
GroupVersion
,
Scheme
:
api
.
Scheme
,
ParameterCodec
:
api
.
ParameterCodec
,
NegotiatedSerializer
:
api
.
Codecs
,
}
if
err
:=
g
.
InstallAPIGroup
(
&
apiGroupInfo
);
err
!=
nil
{
glog
.
Fatalf
(
"Error in registering group versions: %v"
,
err
)
}
}
federation/cmd/federation-apiserver/app/server.go
View file @
9546ba9b
...
...
@@ -213,6 +213,7 @@ func Run(s *options.ServerRunOptions) error {
installCoreAPIs
(
s
,
m
,
restOptionsFactory
)
installExtensionsAPIs
(
m
,
restOptionsFactory
)
installBatchAPIs
(
m
,
restOptionsFactory
)
installAutoscalingAPIs
(
m
,
restOptionsFactory
)
sharedInformers
.
Start
(
wait
.
NeverStop
)
m
.
PrepareRun
()
.
Run
(
wait
.
NeverStop
)
...
...
test/integration/federation/BUILD
View file @
9546ba9b
...
...
@@ -16,6 +16,7 @@ go_test(
"//federation/cmd/federation-apiserver/app:go_default_library",
"//federation/cmd/federation-apiserver/app/options:go_default_library",
"//pkg/api/v1:go_default_library",
"//pkg/apis/autoscaling/v1:go_default_library",
"//pkg/apis/batch/v1:go_default_library",
"//pkg/apis/extensions/v1beta1:go_default_library",
"//vendor:github.com/stretchr/testify/assert",
...
...
test/integration/federation/server_test.go
View file @
9546ba9b
...
...
@@ -33,6 +33,7 @@ import (
"k8s.io/kubernetes/federation/cmd/federation-apiserver/app"
"k8s.io/kubernetes/federation/cmd/federation-apiserver/app/options"
"k8s.io/kubernetes/pkg/api/v1"
autoscaling_v1
"k8s.io/kubernetes/pkg/apis/autoscaling/v1"
batch_v1
"k8s.io/kubernetes/pkg/apis/batch/v1"
ext_v1b1
"k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
)
...
...
@@ -44,6 +45,7 @@ var groupVersions = []schema.GroupVersion{
fed_v1b1
.
SchemeGroupVersion
,
ext_v1b1
.
SchemeGroupVersion
,
batch_v1
.
SchemeGroupVersion
,
autoscaling_v1
.
SchemeGroupVersion
,
}
func
TestRun
(
t
*
testing
.
T
)
{
...
...
@@ -214,6 +216,7 @@ func testAPIResourceList(t *testing.T) {
testCoreResourceList
(
t
)
testExtensionsResourceList
(
t
)
testBatchResourceList
(
t
)
testAutoscalingResourceList
(
t
)
}
func
testFederationResourceList
(
t
*
testing
.
T
)
{
...
...
@@ -373,3 +376,29 @@ func testBatchResourceList(t *testing.T) {
assert
.
NotNil
(
t
,
found
)
assert
.
True
(
t
,
found
.
Namespaced
)
}
func
testAutoscalingResourceList
(
t
*
testing
.
T
)
{
serverURL
:=
serverIP
+
"/apis/"
+
autoscaling_v1
.
SchemeGroupVersion
.
String
()
contents
,
err
:=
readResponse
(
serverURL
)
if
err
!=
nil
{
t
.
Fatalf
(
"%v"
,
err
)
}
var
apiResourceList
metav1
.
APIResourceList
err
=
json
.
Unmarshal
(
contents
,
&
apiResourceList
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error in unmarshalling response from server %s: %v"
,
serverURL
,
err
)
}
// empty APIVersion for extensions group
assert
.
Equal
(
t
,
"v1"
,
apiResourceList
.
APIVersion
)
assert
.
Equal
(
t
,
autoscaling_v1
.
SchemeGroupVersion
.
String
(),
apiResourceList
.
GroupVersion
)
// Assert that there are exactly this number of resources.
assert
.
Equal
(
t
,
2
,
len
(
apiResourceList
.
APIResources
))
// Verify hpa
found
:=
findResource
(
apiResourceList
.
APIResources
,
"horizontalpodautoscalers"
)
assert
.
NotNil
(
t
,
found
)
assert
.
True
(
t
,
found
.
Namespaced
)
found
=
findResource
(
apiResourceList
.
APIResources
,
"horizontalpodautoscalers/status"
)
assert
.
NotNil
(
t
,
found
)
assert
.
True
(
t
,
found
.
Namespaced
)
}
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