Skip to content

Commit

Permalink
Merge pull request #23509 from XiaoningDing/ube-apiserver
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue

duplicate kube-apiserver to federated-apiserver

duplicate the kube-apiserver source code to ube-apiserver and update references
cluster specific api objects will be in separate PRs

#19313,  #21190
#21190 (comment)
@nikhiljindal
  • Loading branch information
k8s-merge-robot committed Apr 2, 2016
2 parents b43ccd6 + ca72bba commit b3eef93
Show file tree
Hide file tree
Showing 7 changed files with 1,276 additions and 0 deletions.
5 changes: 5 additions & 0 deletions federation/cmd/federated-apiserver/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
assignees:
- lavalamp
- smarterclayton
- nikhiljindal
- krousey
54 changes: 54 additions & 0 deletions federation/cmd/federated-apiserver/apiserver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
Copyright 2014 The Kubernetes Authors All rights reserved.
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.
*/

// apiserver is the main api server and master for the cluster.
// it is responsible for serving the cluster management API.
package main

import (
"fmt"
"math/rand"
"os"
"runtime"
"time"

"k8s.io/kubernetes/federation/cmd/federated-apiserver/app"
"k8s.io/kubernetes/federation/cmd/federated-apiserver/app/options"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/flag"
"k8s.io/kubernetes/pkg/version/verflag"

"github.com/spf13/pflag"
)

func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
rand.Seed(time.Now().UTC().UnixNano())

s := options.NewAPIServer()
s.AddFlags(pflag.CommandLine)

flag.InitFlags()
util.InitLogs()
defer util.FlushLogs()

verflag.PrintAndExitIfRequested()

if err := app.Run(s); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
}
269 changes: 269 additions & 0 deletions federation/cmd/federated-apiserver/app/options/options.go

Large diffs are not rendered by default.

99 changes: 99 additions & 0 deletions federation/cmd/federated-apiserver/app/options/options_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
Copyright 2014 The Kubernetes Authors All rights reserved.
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 (
"reflect"
"testing"

"github.com/spf13/pflag"

"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/autoscaling"
"k8s.io/kubernetes/pkg/apis/extensions"
)

func TestGenerateStorageVersionMap(t *testing.T) {
testCases := []struct {
legacyVersion string
storageVersions string
defaultVersions string
expectedMap map[string]string
}{
{
legacyVersion: "v1",
storageVersions: "v1,extensions/v1beta1",
expectedMap: map[string]string{
api.GroupName: "v1",
extensions.GroupName: "extensions/v1beta1",
},
},
{
legacyVersion: "",
storageVersions: "extensions/v1beta1,v1",
expectedMap: map[string]string{
api.GroupName: "v1",
extensions.GroupName: "extensions/v1beta1",
},
},
{
legacyVersion: "",
storageVersions: "autoscaling=extensions/v1beta1,v1",
defaultVersions: "extensions/v1beta1,v1,autoscaling/v1",
expectedMap: map[string]string{
api.GroupName: "v1",
autoscaling.GroupName: "extensions/v1beta1",
extensions.GroupName: "extensions/v1beta1",
},
},
{
legacyVersion: "",
storageVersions: "",
expectedMap: map[string]string{},
},
}
for i, test := range testCases {
s := APIServer{
DeprecatedStorageVersion: test.legacyVersion,
StorageVersions: test.storageVersions,
DefaultStorageVersions: test.defaultVersions,
}
output := s.StorageGroupsToGroupVersions()
if !reflect.DeepEqual(test.expectedMap, output) {
t.Errorf("%v: unexpected error. expect: %v, got: %v", i, test.expectedMap, output)
}
}
}

func TestAddFlagsFlag(t *testing.T) {
// TODO: This only tests the enable-swagger-ui flag for now.
// Expand the test to include other flags as well.
f := pflag.NewFlagSet("addflagstest", pflag.ContinueOnError)
s := NewAPIServer()
s.AddFlags(f)
if s.EnableSwaggerUI {
t.Errorf("Expected s.EnableSwaggerUI to be false by default")
}

args := []string{
"--enable-swagger-ui=true",
}
f.Parse(args)
if !s.EnableSwaggerUI {
t.Errorf("Expected s.EnableSwaggerUI to be true")
}
}
40 changes: 40 additions & 0 deletions federation/cmd/federated-apiserver/app/plugins.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
Copyright 2014 The Kubernetes Authors All rights reserved.
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

// This file exists to force the desired plugin implementations to be linked.
// This should probably be part of some configuration fed into the build for a
// given binary target.
import (
// Cloud providers
_ "k8s.io/kubernetes/pkg/cloudprovider/providers"

// Admission policies
_ "k8s.io/kubernetes/plugin/pkg/admission/admit"
_ "k8s.io/kubernetes/plugin/pkg/admission/alwayspullimages"
_ "k8s.io/kubernetes/plugin/pkg/admission/deny"
_ "k8s.io/kubernetes/plugin/pkg/admission/exec"
_ "k8s.io/kubernetes/plugin/pkg/admission/initialresources"
_ "k8s.io/kubernetes/plugin/pkg/admission/limitranger"
_ "k8s.io/kubernetes/plugin/pkg/admission/namespace/autoprovision"
_ "k8s.io/kubernetes/plugin/pkg/admission/namespace/exists"
_ "k8s.io/kubernetes/plugin/pkg/admission/namespace/lifecycle"
_ "k8s.io/kubernetes/plugin/pkg/admission/persistentvolume/label"
_ "k8s.io/kubernetes/plugin/pkg/admission/resourcequota"
_ "k8s.io/kubernetes/plugin/pkg/admission/securitycontext/scdeny"
_ "k8s.io/kubernetes/plugin/pkg/admission/serviceaccount"
)
Loading

1 comment on commit b3eef93

@k8s-teamcity-mesosphere

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity OSS :: Kubernetes Mesos :: 4 - Smoke Tests Build 20446 outcome was SUCCESS
Summary: Tests passed: 1, ignored: 267 Build time: 00:08:14

Please sign in to comment.