Documentation ¶
Overview ¶
Package storage contains the plumbing to setup the etcd storage of the apiserver.
Index ¶
- Constants
- func NewStorageCodec(opts StorageCodecConfig) (runtime.Codec, runtime.GroupVersioner, error)
- type APIResourceConfigSource
- type Backend
- type DefaultResourceEncodingConfig
- func (o *DefaultResourceEncodingConfig) InMemoryEncodingFor(resource schema.GroupResource) (schema.GroupVersion, error)
- func (o *DefaultResourceEncodingConfig) SetResourceEncoding(resourceBeingStored schema.GroupResource, ...)
- func (o *DefaultResourceEncodingConfig) StorageEncodingFor(resource schema.GroupResource) (schema.GroupVersion, error)
- type DefaultStorageFactory
- func (s *DefaultStorageFactory) AddCohabitatingResources(groupResources ...schema.GroupResource)
- func (s *DefaultStorageFactory) AddSerializationChains(encoderDecoratorFn func(runtime.Encoder) runtime.Encoder, ...)
- func (s *DefaultStorageFactory) Backends() []Backend
- func (s *DefaultStorageFactory) NewConfig(groupResource schema.GroupResource) (*storagebackend.ConfigForResource, error)
- func (s *DefaultStorageFactory) ResourcePrefix(groupResource schema.GroupResource) string
- func (s *DefaultStorageFactory) SetDisableAPIListChunking(groupResource schema.GroupResource)
- func (s *DefaultStorageFactory) SetEtcdLocation(groupResource schema.GroupResource, location []string)
- func (s *DefaultStorageFactory) SetEtcdPrefix(groupResource schema.GroupResource, prefix string)
- func (s *DefaultStorageFactory) SetResourceEtcdPrefix(groupResource schema.GroupResource, prefix string)
- func (s *DefaultStorageFactory) SetSerializer(groupResource schema.GroupResource, mediaType string, ...)
- func (s *DefaultStorageFactory) SetTransformer(groupResource schema.GroupResource, transformer value.Transformer)
- type OverridingResourceEncoding
- type ResourceConfig
- func (o *ResourceConfig) AnyResourceForGroupEnabled(group string) bool
- func (o *ResourceConfig) DisableMatchingVersions(matcher func(gv schema.GroupVersion) bool)
- func (o *ResourceConfig) DisableResources(resources ...schema.GroupVersionResource)
- func (o *ResourceConfig) DisableVersions(versions ...schema.GroupVersion)
- func (o *ResourceConfig) EnableMatchingVersions(matcher func(gv schema.GroupVersion) bool)
- func (o *ResourceConfig) EnableResources(resources ...schema.GroupVersionResource)
- func (o *ResourceConfig) EnableVersions(versions ...schema.GroupVersion)
- func (o *ResourceConfig) RemoveMatchingResourcePreferences(matcher func(gvr schema.GroupVersionResource) bool)
- func (o *ResourceConfig) ResourceEnabled(resource schema.GroupVersionResource) bool
- func (o *ResourceConfig) VersionEnabled(version schema.GroupVersion) bool
- type ResourceEncodingConfig
- type StorageCodecConfig
- type StorageFactory
Constants ¶
const AllResources = "*"
Variables ¶
This section is empty.
Functions ¶
func NewStorageCodec ¶
func NewStorageCodec(opts StorageCodecConfig) (runtime.Codec, runtime.GroupVersioner, error)
NewStorageCodec assembles a storage codec for the provided storage media type, the provided serializer, and the requested storage and memory versions.
Types ¶
type APIResourceConfigSource ¶
type APIResourceConfigSource interface { VersionEnabled(version schema.GroupVersion) bool ResourceEnabled(resource schema.GroupVersionResource) bool AnyResourceForGroupEnabled(group string) bool }
APIResourceConfigSource is the interface to determine which groups and versions are enabled
type Backend ¶
type Backend struct { // the url of storage backend like: https://etcd.domain:2379 Server string // the required tls config TLSConfig *tls.Config }
Backend describes the storage servers, the information here should be enough for health validations.
type DefaultResourceEncodingConfig ¶
type DefaultResourceEncodingConfig struct {
// contains filtered or unexported fields
}
func NewDefaultResourceEncodingConfig ¶
func NewDefaultResourceEncodingConfig(scheme *runtime.Scheme) *DefaultResourceEncodingConfig
func (*DefaultResourceEncodingConfig) InMemoryEncodingFor ¶
func (o *DefaultResourceEncodingConfig) InMemoryEncodingFor(resource schema.GroupResource) (schema.GroupVersion, error)
func (*DefaultResourceEncodingConfig) SetResourceEncoding ¶
func (o *DefaultResourceEncodingConfig) SetResourceEncoding(resourceBeingStored schema.GroupResource, externalEncodingVersion, internalVersion schema.GroupVersion)
func (*DefaultResourceEncodingConfig) StorageEncodingFor ¶
func (o *DefaultResourceEncodingConfig) StorageEncodingFor(resource schema.GroupResource) (schema.GroupVersion, error)
type DefaultStorageFactory ¶
type DefaultStorageFactory struct { // StorageConfig describes how to create a storage backend in general. // Its authentication information will be used for every storage.Interface returned. StorageConfig storagebackend.Config Overrides map[schema.GroupResource]groupResourceOverrides DefaultResourcePrefixes map[schema.GroupResource]string // DefaultMediaType is the media type used to store resources. If it is not set, "application/json" is used. DefaultMediaType string // DefaultSerializer is used to create encoders and decoders for the storage.Interface. DefaultSerializer runtime.StorageSerializer // ResourceEncodingConfig describes how to encode a particular GroupVersionResource ResourceEncodingConfig ResourceEncodingConfig // APIResourceConfigSource indicates whether the *storage* is enabled, NOT the API // This is discrete from resource enablement because those are separate concerns. How this source is configured // is left to the caller. APIResourceConfigSource APIResourceConfigSource // contains filtered or unexported fields }
DefaultStorageFactory takes a GroupResource and returns back its storage interface. This result includes: 1. Merged etcd config, including: auth, server locations, prefixes 2. Resource encodings for storage: group,version,kind to store as 3. Cohabitating default: some resources like hpa are exposed through multiple APIs. They must agree on 1 and 2
func NewDefaultStorageFactory ¶
func NewDefaultStorageFactory( config storagebackend.Config, defaultMediaType string, defaultSerializer runtime.StorageSerializer, resourceEncodingConfig ResourceEncodingConfig, resourceConfig APIResourceConfigSource, specialDefaultResourcePrefixes map[schema.GroupResource]string, ) *DefaultStorageFactory
func (*DefaultStorageFactory) AddCohabitatingResources ¶
func (s *DefaultStorageFactory) AddCohabitatingResources(groupResources ...schema.GroupResource)
AddCohabitatingResources links resources together the order of the slice matters! its the priority order of lookup for finding a storage location
func (*DefaultStorageFactory) AddSerializationChains ¶
func (*DefaultStorageFactory) Backends ¶
func (s *DefaultStorageFactory) Backends() []Backend
Backends returns all backends for all registered storage destinations. Used for getting all instances for health validations.
func (*DefaultStorageFactory) NewConfig ¶
func (s *DefaultStorageFactory) NewConfig(groupResource schema.GroupResource) (*storagebackend.ConfigForResource, error)
New finds the storage destination for the given group and resource. It will return an error if the group has no storage destination configured.
func (*DefaultStorageFactory) ResourcePrefix ¶
func (s *DefaultStorageFactory) ResourcePrefix(groupResource schema.GroupResource) string
func (*DefaultStorageFactory) SetDisableAPIListChunking ¶
func (s *DefaultStorageFactory) SetDisableAPIListChunking(groupResource schema.GroupResource)
SetDisableAPIListChunking allows a specific resource to disable paging at the storage layer, to prevent exposure of key names in continuations. This may be overridden by feature gates.
func (*DefaultStorageFactory) SetEtcdLocation ¶
func (s *DefaultStorageFactory) SetEtcdLocation(groupResource schema.GroupResource, location []string)
func (*DefaultStorageFactory) SetEtcdPrefix ¶
func (s *DefaultStorageFactory) SetEtcdPrefix(groupResource schema.GroupResource, prefix string)
func (*DefaultStorageFactory) SetResourceEtcdPrefix ¶
func (s *DefaultStorageFactory) SetResourceEtcdPrefix(groupResource schema.GroupResource, prefix string)
SetResourceEtcdPrefix sets the prefix for a resource, but not the base-dir. You'll end up in `etcdPrefix/resourceEtcdPrefix`.
func (*DefaultStorageFactory) SetSerializer ¶
func (s *DefaultStorageFactory) SetSerializer(groupResource schema.GroupResource, mediaType string, serializer runtime.StorageSerializer)
func (*DefaultStorageFactory) SetTransformer ¶
func (s *DefaultStorageFactory) SetTransformer(groupResource schema.GroupResource, transformer value.Transformer)
type OverridingResourceEncoding ¶
type OverridingResourceEncoding struct { ExternalResourceEncoding schema.GroupVersion InternalResourceEncoding schema.GroupVersion }
type ResourceConfig ¶
type ResourceConfig struct { GroupVersionConfigs map[schema.GroupVersion]bool ResourceConfigs map[schema.GroupVersionResource]bool }
func NewResourceConfig ¶
func NewResourceConfig() *ResourceConfig
func (*ResourceConfig) AnyResourceForGroupEnabled ¶ added in v0.24.0
func (o *ResourceConfig) AnyResourceForGroupEnabled(group string) bool
func (*ResourceConfig) DisableMatchingVersions ¶ added in v0.17.0
func (o *ResourceConfig) DisableMatchingVersions(matcher func(gv schema.GroupVersion) bool)
DisableMatchingVersions disables all group/versions for which the matcher function returns true. It does not modify individual resource enablement/disablement.
func (*ResourceConfig) DisableResources ¶
func (o *ResourceConfig) DisableResources(resources ...schema.GroupVersionResource)
func (*ResourceConfig) DisableVersions ¶
func (o *ResourceConfig) DisableVersions(versions ...schema.GroupVersion)
DisableVersions disables the versions entirely.
func (*ResourceConfig) EnableMatchingVersions ¶ added in v0.17.0
func (o *ResourceConfig) EnableMatchingVersions(matcher func(gv schema.GroupVersion) bool)
EnableMatchingVersions enables all group/versions for which the matcher function returns true. It does not modify individual resource enablement/disablement.
func (*ResourceConfig) EnableResources ¶
func (o *ResourceConfig) EnableResources(resources ...schema.GroupVersionResource)
func (*ResourceConfig) EnableVersions ¶
func (o *ResourceConfig) EnableVersions(versions ...schema.GroupVersion)
func (*ResourceConfig) RemoveMatchingResourcePreferences ¶
func (o *ResourceConfig) RemoveMatchingResourcePreferences(matcher func(gvr schema.GroupVersionResource) bool)
RemoveMatchingResourcePreferences removes individual resource preferences that match. This is useful when an override of a version or level enablement should override the previously individual preferences.
func (*ResourceConfig) ResourceEnabled ¶
func (o *ResourceConfig) ResourceEnabled(resource schema.GroupVersionResource) bool
func (*ResourceConfig) VersionEnabled ¶
func (o *ResourceConfig) VersionEnabled(version schema.GroupVersion) bool
TODO this must be removed and we enable/disable individual resources.
type ResourceEncodingConfig ¶
type ResourceEncodingConfig interface { // StorageEncoding returns the serialization format for the resource. // TODO this should actually return a GroupVersionKind since you can logically have multiple "matching" Kinds // For now, it returns just the GroupVersion for consistency with old behavior StorageEncodingFor(schema.GroupResource) (schema.GroupVersion, error) // InMemoryEncodingFor returns the groupVersion for the in memory representation the storage should convert to. InMemoryEncodingFor(schema.GroupResource) (schema.GroupVersion, error) }
type StorageCodecConfig ¶
type StorageCodecConfig struct { StorageMediaType string StorageSerializer runtime.StorageSerializer StorageVersion schema.GroupVersion MemoryVersion schema.GroupVersion Config storagebackend.Config EncoderDecoratorFn func(runtime.Encoder) runtime.Encoder DecoderDecoratorFn func([]runtime.Decoder) []runtime.Decoder }
StorageCodecConfig are the arguments passed to newStorageCodecFn
type StorageFactory ¶
type StorageFactory interface { // New finds the storage destination for the given group and resource. It will // return an error if the group has no storage destination configured. NewConfig(groupResource schema.GroupResource) (*storagebackend.ConfigForResource, error) // ResourcePrefix returns the overridden resource prefix for the GroupResource // This allows for cohabitation of resources with different native types and provides // centralized control over the shape of etcd directories ResourcePrefix(groupResource schema.GroupResource) string // Backends gets all backends for all registered storage destinations. // Used for getting all instances for health validations. Backends() []Backend }
StorageFactory is the interface to locate the storage for a given GroupResource