Skip to content

Commit 6ccdb15

Browse files
authored
Merge pull request kubernetes#91541 from bjrara/standalone-apiextension
Enhance apiextensions-apiserver in the standalone mode
2 parents dc6b7f8 + 87e775e commit 6ccdb15

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2020 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
FROM gcr.io/distroless/base:latest
16+
ADD apiextensions-apiserver /
17+
ENTRYPOINT ["/apiextensions-apiserver"]
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2014 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../../../../..
22+
source "${KUBE_ROOT}/hack/lib/util.sh"
23+
24+
# Register function to be called on EXIT to remove generated binary.
25+
function cleanup {
26+
rm "${KUBE_ROOT}/vendor/k8s.io/apiextensions-apiserver/artifacts/simple-image/apiextensions-apiserver"
27+
}
28+
trap cleanup EXIT
29+
30+
pushd "${KUBE_ROOT}/vendor/k8s.io/apiextensions-apiserver"
31+
cp -v ../../../../_output/local/bin/linux/amd64/apiextensions-apiserver ./artifacts/simple-image/apiextensions-apiserver
32+
docker build -t apiextensions-apiserver:latest ./artifacts/simple-image
33+
popd

staging/src/k8s.io/apiextensions-apiserver/pkg/cmd/server/options/options.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
utilerrors "k8s.io/apimachinery/pkg/util/errors"
3232
genericregistry "k8s.io/apiserver/pkg/registry/generic"
3333
genericapiserver "k8s.io/apiserver/pkg/server"
34+
"k8s.io/apiserver/pkg/server/options"
3435
genericoptions "k8s.io/apiserver/pkg/server/options"
3536
"k8s.io/apiserver/pkg/util/proxy"
3637
"k8s.io/apiserver/pkg/util/webhook"
@@ -41,6 +42,7 @@ const defaultEtcdPathPrefix = "/registry/apiextensions.kubernetes.io"
4142

4243
// CustomResourceDefinitionsServerOptions describes the runtime options of an apiextensions-apiserver.
4344
type CustomResourceDefinitionsServerOptions struct {
45+
ServerRunOptions *options.ServerRunOptions
4446
RecommendedOptions *genericoptions.RecommendedOptions
4547
APIEnablement *genericoptions.APIEnablementOptions
4648

@@ -51,6 +53,7 @@ type CustomResourceDefinitionsServerOptions struct {
5153
// NewCustomResourceDefinitionsServerOptions creates default options of an apiextensions-apiserver.
5254
func NewCustomResourceDefinitionsServerOptions(out, errOut io.Writer) *CustomResourceDefinitionsServerOptions {
5355
o := &CustomResourceDefinitionsServerOptions{
56+
ServerRunOptions: options.NewServerRunOptions(),
5457
RecommendedOptions: genericoptions.NewRecommendedOptions(
5558
defaultEtcdPathPrefix,
5659
apiserver.Codecs.LegacyCodec(v1beta1.SchemeGroupVersion, v1.SchemeGroupVersion),
@@ -66,13 +69,15 @@ func NewCustomResourceDefinitionsServerOptions(out, errOut io.Writer) *CustomRes
6669

6770
// AddFlags adds the apiextensions-apiserver flags to the flagset.
6871
func (o CustomResourceDefinitionsServerOptions) AddFlags(fs *pflag.FlagSet) {
72+
o.ServerRunOptions.AddUniversalFlags(fs)
6973
o.RecommendedOptions.AddFlags(fs)
7074
o.APIEnablement.AddFlags(fs)
7175
}
7276

7377
// Validate validates the apiextensions-apiserver options.
7478
func (o CustomResourceDefinitionsServerOptions) Validate() error {
7579
errors := []error{}
80+
errors = append(errors, o.ServerRunOptions.Validate()...)
7681
errors = append(errors, o.RecommendedOptions.Validate()...)
7782
errors = append(errors, o.APIEnablement.Validate(apiserver.Scheme)...)
7883
return utilerrors.NewAggregate(errors)
@@ -91,6 +96,9 @@ func (o CustomResourceDefinitionsServerOptions) Config() (*apiserver.Config, err
9196
}
9297

9398
serverConfig := genericapiserver.NewRecommendedConfig(apiserver.Codecs)
99+
if err := o.ServerRunOptions.ApplyTo(&serverConfig.Config); err != nil {
100+
return nil, err
101+
}
94102
if err := o.RecommendedOptions.ApplyTo(serverConfig); err != nil {
95103
return nil, err
96104
}

0 commit comments

Comments
 (0)