diff --git a/staging/src/k8s.io/apiextensions-apiserver/artifacts/simple-image/Dockerfile b/staging/src/k8s.io/apiextensions-apiserver/artifacts/simple-image/Dockerfile new file mode 100644 index 00000000000..31e8da5cf64 --- /dev/null +++ b/staging/src/k8s.io/apiextensions-apiserver/artifacts/simple-image/Dockerfile @@ -0,0 +1,17 @@ +# Copyright 2020 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. + +FROM gcr.io/distroless/base:latest +ADD apiextensions-apiserver / +ENTRYPOINT ["/apiextensions-apiserver"] diff --git a/staging/src/k8s.io/apiextensions-apiserver/hack/build-image.sh b/staging/src/k8s.io/apiextensions-apiserver/hack/build-image.sh new file mode 100755 index 00000000000..8b7ef99c4f3 --- /dev/null +++ b/staging/src/k8s.io/apiextensions-apiserver/hack/build-image.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +# Copyright 2014 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. + +set -o errexit +set -o nounset +set -o pipefail + +KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../../../../.. +source "${KUBE_ROOT}/hack/lib/util.sh" + +# Register function to be called on EXIT to remove generated binary. +function cleanup { + rm "${KUBE_ROOT}/vendor/k8s.io/apiextensions-apiserver/artifacts/simple-image/apiextensions-apiserver" +} +trap cleanup EXIT + +pushd "${KUBE_ROOT}/vendor/k8s.io/apiextensions-apiserver" +cp -v ../../../../_output/local/bin/linux/amd64/apiextensions-apiserver ./artifacts/simple-image/apiextensions-apiserver +docker build -t apiextensions-apiserver:latest ./artifacts/simple-image +popd diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/cmd/server/options/options.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/cmd/server/options/options.go index 895a8ebfe6e..dd6d94b48b6 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/cmd/server/options/options.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/cmd/server/options/options.go @@ -31,6 +31,7 @@ import ( utilerrors "k8s.io/apimachinery/pkg/util/errors" genericregistry "k8s.io/apiserver/pkg/registry/generic" genericapiserver "k8s.io/apiserver/pkg/server" + "k8s.io/apiserver/pkg/server/options" genericoptions "k8s.io/apiserver/pkg/server/options" "k8s.io/apiserver/pkg/util/proxy" "k8s.io/apiserver/pkg/util/webhook" @@ -41,6 +42,7 @@ const defaultEtcdPathPrefix = "/registry/apiextensions.kubernetes.io" // CustomResourceDefinitionsServerOptions describes the runtime options of an apiextensions-apiserver. type CustomResourceDefinitionsServerOptions struct { + ServerRunOptions *options.ServerRunOptions RecommendedOptions *genericoptions.RecommendedOptions APIEnablement *genericoptions.APIEnablementOptions @@ -51,6 +53,7 @@ type CustomResourceDefinitionsServerOptions struct { // NewCustomResourceDefinitionsServerOptions creates default options of an apiextensions-apiserver. func NewCustomResourceDefinitionsServerOptions(out, errOut io.Writer) *CustomResourceDefinitionsServerOptions { o := &CustomResourceDefinitionsServerOptions{ + ServerRunOptions: options.NewServerRunOptions(), RecommendedOptions: genericoptions.NewRecommendedOptions( defaultEtcdPathPrefix, apiserver.Codecs.LegacyCodec(v1beta1.SchemeGroupVersion, v1.SchemeGroupVersion), @@ -66,6 +69,7 @@ func NewCustomResourceDefinitionsServerOptions(out, errOut io.Writer) *CustomRes // AddFlags adds the apiextensions-apiserver flags to the flagset. func (o CustomResourceDefinitionsServerOptions) AddFlags(fs *pflag.FlagSet) { + o.ServerRunOptions.AddUniversalFlags(fs) o.RecommendedOptions.AddFlags(fs) o.APIEnablement.AddFlags(fs) } @@ -73,6 +77,7 @@ func (o CustomResourceDefinitionsServerOptions) AddFlags(fs *pflag.FlagSet) { // Validate validates the apiextensions-apiserver options. func (o CustomResourceDefinitionsServerOptions) Validate() error { errors := []error{} + errors = append(errors, o.ServerRunOptions.Validate()...) errors = append(errors, o.RecommendedOptions.Validate()...) errors = append(errors, o.APIEnablement.Validate(apiserver.Scheme)...) return utilerrors.NewAggregate(errors) @@ -91,6 +96,9 @@ func (o CustomResourceDefinitionsServerOptions) Config() (*apiserver.Config, err } serverConfig := genericapiserver.NewRecommendedConfig(apiserver.Codecs) + if err := o.ServerRunOptions.ApplyTo(&serverConfig.Config); err != nil { + return nil, err + } if err := o.RecommendedOptions.ApplyTo(serverConfig); err != nil { return nil, err }