Skip to content

Commit

Permalink
UPSTREAM: <carry>: Add pkg/features/openshift_features.go
Browse files Browse the repository at this point in the history
- injects openshift specific feature gates to kube binaries

Signed-off-by: Swarup Ghosh <swghosh@redhat.com>
  • Loading branch information
swghosh committed Feb 28, 2024
1 parent 5060f50 commit 25c48be
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
13 changes: 0 additions & 13 deletions cmd/kube-apiserver/app/server.go
Expand Up @@ -28,8 +28,6 @@ import (
"os"
"time"

configv1 "github.com/openshift/api/config/v1"
openshiftfeatures "github.com/openshift/library-go/pkg/features"
"k8s.io/kubernetes/openshift-kube-apiserver/admission/admissionenablement"
"k8s.io/kubernetes/openshift-kube-apiserver/enablement"
"k8s.io/kubernetes/openshift-kube-apiserver/openshiftkubeapiserver"
Expand Down Expand Up @@ -84,12 +82,6 @@ import (
"k8s.io/kubernetes/pkg/serviceaccount"
)

// OpenShiftKubeAPIServerFeatureGates contains list of feature gates that
// will be honored by openshift-kube-apiserver
var OpenShiftKubeAPIServerFeatureGates []configv1.FeatureGateName = []configv1.FeatureGateName{
configv1.FeatureGateRouteExternalCertificate,
}

func init() {
utilruntime.Must(logsapi.AddFeatureGates(utilfeature.DefaultMutableFeatureGate))
}
Expand Down Expand Up @@ -178,11 +170,6 @@ cluster's shared state through which all other components interact.`,

// openshift feature gates need to be mandatorily initialized before flag set is used
// feature gates
if err := openshiftfeatures.InitializeFeatureGates(utilfeature.DefaultMutableFeatureGate,
OpenShiftKubeAPIServerFeatureGates...,
); err != nil {
klog.Fatal(err)
}

fs := cmd.Flags()
namedFlagSets := s.Flags()
Expand Down
31 changes: 31 additions & 0 deletions pkg/features/openshift_features.go
@@ -0,0 +1,31 @@
package features

import (
"k8s.io/apimachinery/pkg/util/runtime"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/component-base/featuregate"

configv1 "github.com/openshift/api/config/v1"
)

var OpenshiftFeatureGates = []configv1.FeatureGateName{
configv1.FeatureGateRouteExternalCertificate,
}

func init() {
registerOpenshiftFeatures()
}

func registerOpenshiftFeatures() {
osKubeFeatureGates := map[featuregate.Feature]featuregate.FeatureSpec{}

for _, featureGateName := range OpenshiftFeatureGates {
osFeature := featuregate.Feature(featureGateName)

osKubeFeatureGates[osFeature] = featuregate.FeatureSpec{
Default: false, PreRelease: featuregate.Alpha,
}
}

runtime.Must(utilfeature.DefaultMutableFeatureGate.Add(osKubeFeatureGates))
}

0 comments on commit 25c48be

Please sign in to comment.