Skip to content

Commit 042842b

Browse files
committed
show how flags could be bound to featuresets
1 parent 5894804 commit 042842b

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

pkg/controlplane/apiserver/options/options.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package options
1919

2020
import (
2121
"fmt"
22+
"k8s.io/kubernetes/pkg/features"
2223
"net"
2324
"os"
2425
"strings"
@@ -98,7 +99,7 @@ type CompletedOptions struct {
9899
// NewOptions creates a new ServerRunOptions object with default parameters
99100
func NewOptions() *Options {
100101
s := Options{
101-
GenericServerRunOptions: genericoptions.NewServerRunOptions(),
102+
GenericServerRunOptions: genericoptions.NewServerRunOptions(features.KubernetesFeatureSet()),
102103
Etcd: genericoptions.NewEtcdOptions(storagebackend.NewDefaultConfig(kubeoptions.DefaultEtcdPathPrefix, nil)),
103104
SecureServing: kubeoptions.NewSecureServingOptions(),
104105
Audit: genericoptions.NewAuditOptions(),

staging/src/k8s.io/apiserver/pkg/server/options/server_run_options.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,16 @@ package options
1818

1919
import (
2020
"fmt"
21+
"k8s.io/utils/featuregates"
2122
"net"
2223
"regexp"
2324
"strings"
2425
"time"
2526

27+
"github.com/spf13/pflag"
2628
"k8s.io/apimachinery/pkg/runtime/serializer"
2729
"k8s.io/apimachinery/pkg/util/errors"
2830
"k8s.io/apiserver/pkg/server"
29-
utilfeature "k8s.io/apiserver/pkg/util/feature"
30-
31-
"github.com/spf13/pflag"
3231
)
3332

3433
const (
@@ -89,9 +88,11 @@ type ServerRunOptions struct {
8988
// This grace period is orthogonal to other grace periods, and
9089
// it is not overridden by any other grace period.
9190
ShutdownWatchTerminationGracePeriod time.Duration
91+
92+
FeatureSetOptions *featuregates.FeatureSetOptions
9293
}
9394

94-
func NewServerRunOptions() *ServerRunOptions {
95+
func NewServerRunOptions(featureSet featuregates.FeatureSet) *ServerRunOptions {
9596
defaults := server.NewConfig(serializer.CodecFactory{})
9697
return &ServerRunOptions{
9798
MaxRequestsInFlight: defaults.MaxRequestsInFlight,
@@ -104,6 +105,7 @@ func NewServerRunOptions() *ServerRunOptions {
104105
JSONPatchMaxCopyBytes: defaults.JSONPatchMaxCopyBytes,
105106
MaxRequestBodyBytes: defaults.MaxRequestBodyBytes,
106107
ShutdownSendRetryAfter: false,
108+
FeatureSetOptions: featuregates.NewFeatureSetOptions(featureSet),
107109
}
108110
}
109111

@@ -337,5 +339,5 @@ func (s *ServerRunOptions) AddUniversalFlags(fs *pflag.FlagSet) {
337339
"This option, if set, represents the maximum amount of grace period the apiserver will wait "+
338340
"for active watch request(s) to drain during the graceful server shutdown window.")
339341

340-
utilfeature.DefaultMutableFeatureGate.AddFlag(fs)
342+
s.FeatureSetOptions.AddFlags(fs)
341343
}

staging/src/k8s.io/kube-aggregator/pkg/cmd/server/start.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"errors"
2121
"fmt"
2222
"io"
23+
"k8s.io/kube-aggregator/pkg/features"
2324

2425
"github.com/spf13/cobra"
2526
"github.com/spf13/pflag"
@@ -90,7 +91,7 @@ func (o *AggregatorOptions) AddFlags(fs *pflag.FlagSet) {
9091
// NewDefaultOptions builds a "normal" set of options. You wouldn't normally expose this, but hyperkube isn't cobra compatible
9192
func NewDefaultOptions(out, err io.Writer) *AggregatorOptions {
9293
o := &AggregatorOptions{
93-
ServerRunOptions: genericoptions.NewServerRunOptions(),
94+
ServerRunOptions: genericoptions.NewServerRunOptions(features.LibraryFeatureSet()),
9495
RecommendedOptions: genericoptions.NewRecommendedOptions(
9596
defaultEtcdPathPrefix,
9697
aggregatorscheme.Codecs.LegacyCodec(v1beta1.SchemeGroupVersion),

0 commit comments

Comments
 (0)