Skip to content

Commit

Permalink
Merge pull request #45 from yue9944882/feat/opt-out-etcd-healthcheck
Browse files Browse the repository at this point in the history
Feat: Opt out from etcd healthcheck so that apiserver can run completely w/o etcd
  • Loading branch information
k8s-ci-robot committed Apr 14, 2021
2 parents 93ac998 + 032406c commit bc58d3a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
6 changes: 5 additions & 1 deletion internal/sample-apiserver/pkg/cmd/server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ func (o *WardleServerOptions) Config() (*apiserver.Config, error) {
return nil, fmt.Errorf("error creating self-signed certificates: %v", err)
}

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

// change: apiserver-runtime
// ExtraAdmissionInitializers set through ApplyServerOptionsFns by appending to ServerOptionsFns
Expand Down
8 changes: 8 additions & 0 deletions pkg/builder/builder_misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,11 @@ func (a *Server) ExposeLoopbackAuthorizer() *Server {
return s
})
}

// WithoutEtcd removes etcd related settings from apiserver.
func (a *Server) WithoutEtcd() *Server {
return a.WithOptionsFns(func(o *ServerOptions) *ServerOptions {
o.RecommendedOptions.Etcd = nil
return o
})
}
13 changes: 11 additions & 2 deletions pkg/experimental/storage/filepath/jsonfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ package filepath

import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/registry/rest"
"k8s.io/apiserver/pkg/server/storage"
"k8s.io/apiserver/pkg/storage/storagebackend"
"sigs.k8s.io/apiserver-runtime/pkg/builder/resource"
builderrest "sigs.k8s.io/apiserver-runtime/pkg/builder/rest"
)
Expand Down Expand Up @@ -36,11 +39,17 @@ import (
func NewJSONFilepathStorageProvider(obj resource.Object, rootPath string) builderrest.ResourceHandlerProvider {
return func(scheme *runtime.Scheme, getter generic.RESTOptionsGetter) (rest.Storage, error) {
gr := obj.GetGroupVersionResource().GroupResource()
opt, err := getter.GetRESTOptions(gr)
codec, _, err := storage.NewStorageCodec(storage.StorageCodecConfig{
StorageMediaType: runtime.ContentTypeJSON,
StorageSerializer: serializer.NewCodecFactory(scheme),
StorageVersion: scheme.PrioritizedVersionsForGroup(obj.GetGroupVersionResource().Group)[0],
MemoryVersion: scheme.PrioritizedVersionsForGroup(obj.GetGroupVersionResource().Group)[0],
Config: storagebackend.Config{}, // useless fields..
})
if err != nil {
return nil, err
}
codec := opt.StorageConfig.Codec

return NewFilepathREST(
gr,
codec,
Expand Down

0 comments on commit bc58d3a

Please sign in to comment.