Skip to content

Commit bc58d3a

Browse files
authoredApr 14, 2021
Merge pull request #45 from yue9944882/feat/opt-out-etcd-healthcheck
Feat: Opt out from etcd healthcheck so that apiserver can run completely w/o etcd
2 parents 93ac998 + 032406c commit bc58d3a

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed
 

‎internal/sample-apiserver/pkg/cmd/server/start.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ func (o *WardleServerOptions) Config() (*apiserver.Config, error) {
115115
return nil, fmt.Errorf("error creating self-signed certificates: %v", err)
116116
}
117117

118-
o.RecommendedOptions.Etcd.StorageConfig.Paging = utilfeature.DefaultFeatureGate.Enabled(features.APIListChunking)
118+
// change: allow etcd options to be nil
119+
// TODO: this should be reverted after rebasing sample-apiserver onto https://github.com/kubernetes/kubernetes/pull/101106
120+
if o.RecommendedOptions.Etcd != nil {
121+
o.RecommendedOptions.Etcd.StorageConfig.Paging = utilfeature.DefaultFeatureGate.Enabled(features.APIListChunking)
122+
}
119123

120124
// change: apiserver-runtime
121125
// ExtraAdmissionInitializers set through ApplyServerOptionsFns by appending to ServerOptionsFns

‎pkg/builder/builder_misc.go

+8
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,11 @@ func (a *Server) ExposeLoopbackAuthorizer() *Server {
5555
return s
5656
})
5757
}
58+
59+
// WithoutEtcd removes etcd related settings from apiserver.
60+
func (a *Server) WithoutEtcd() *Server {
61+
return a.WithOptionsFns(func(o *ServerOptions) *ServerOptions {
62+
o.RecommendedOptions.Etcd = nil
63+
return o
64+
})
65+
}

‎pkg/experimental/storage/filepath/jsonfile.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ package filepath
33

44
import (
55
"k8s.io/apimachinery/pkg/runtime"
6+
"k8s.io/apimachinery/pkg/runtime/serializer"
67
"k8s.io/apiserver/pkg/registry/generic"
78
"k8s.io/apiserver/pkg/registry/rest"
9+
"k8s.io/apiserver/pkg/server/storage"
10+
"k8s.io/apiserver/pkg/storage/storagebackend"
811
"sigs.k8s.io/apiserver-runtime/pkg/builder/resource"
912
builderrest "sigs.k8s.io/apiserver-runtime/pkg/builder/rest"
1013
)
@@ -36,11 +39,17 @@ import (
3639
func NewJSONFilepathStorageProvider(obj resource.Object, rootPath string) builderrest.ResourceHandlerProvider {
3740
return func(scheme *runtime.Scheme, getter generic.RESTOptionsGetter) (rest.Storage, error) {
3841
gr := obj.GetGroupVersionResource().GroupResource()
39-
opt, err := getter.GetRESTOptions(gr)
42+
codec, _, err := storage.NewStorageCodec(storage.StorageCodecConfig{
43+
StorageMediaType: runtime.ContentTypeJSON,
44+
StorageSerializer: serializer.NewCodecFactory(scheme),
45+
StorageVersion: scheme.PrioritizedVersionsForGroup(obj.GetGroupVersionResource().Group)[0],
46+
MemoryVersion: scheme.PrioritizedVersionsForGroup(obj.GetGroupVersionResource().Group)[0],
47+
Config: storagebackend.Config{}, // useless fields..
48+
})
4049
if err != nil {
4150
return nil, err
4251
}
43-
codec := opt.StorageConfig.Codec
52+
4453
return NewFilepathREST(
4554
gr,
4655
codec,

0 commit comments

Comments
 (0)
Please sign in to comment.