offlinemanager

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2022 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Wait a little bit before closing watches so they are not immediately retried by Kubelet
	KubeletWatchTimeout  = time.Second * 30
	XRoutingBlockHeader  = "X-Routing-Block"
	XForwardedHostHeader = "X-Forwarded-Host"
	XOriginHostHeader    = "X-Origin-Host"
)
View Source
const (
	NoWatchPollInterval = time.Minute * 5

	BackoffStart = time.Second * 1
	BackoffMax   = time.Minute * 5
)
View Source
const (
	FormatVersion        = "1"
	FileComplete         = "cache.current"
	FilePartial          = "cache.partial"
	CacheSaveInterval    = time.Second * 30
	InformerResyncPeriod = 0 // Don't resync
)

Variables

View Source
var SupportedResources []ResourceInfo = []ResourceInfo{
	{
		Name:            "pods",
		Kind:            "Pod",
		Namespaced:      true,
		GetAttr:         UnstructuredGetAttr("Pod"),
		GetDependencies: GetUnstructuredPodDeps,
	},
	{
		Name:       "nodes",
		Kind:       "Node",
		Namespaced: false,
		GetAttr:    UnstructuredGetAttr("Node"),
	},
	{
		Name:       "configmaps",
		Kind:       "ConfigMap",
		Namespaced: true,
		GetAttr:    UnstructuredGetAttr("ConfigMap"),
	},
	{
		Name:       "secrets",
		Kind:       "Secret",
		Namespaced: true,
		GetAttr:    UnstructuredGetAttr("Secret"),
	},
	{
		Name:            "persistentvolumeclaims",
		Kind:            "PersistentVolumeClaim",
		Namespaced:      true,
		WatchNotAllowed: true,
		GetAttr:         UnstructuredGetAttr("PersistentVolumeClaim"),
		GetDependencies: GetUnstructuredPVCDeps,
	},
	{
		Name:            "persistentvolumes",
		Kind:            "PersistentVolume",
		Namespaced:      false,
		WatchNotAllowed: true,
		GetAttr:         UnstructuredGetAttr("PersistentVolume"),
	},
	{
		Name:       "services",
		Kind:       "Service",
		Namespaced: true,
		GetAttr:    UnstructuredGetAttr("Service"),
		Disabled:   true,
	},
	{
		Name:       "endpoints",
		Kind:       "Endpoints",
		Namespaced: true,
		GetAttr:    UnstructuredGetAttr("Endpoints"),
		Disabled:   true,
	},
	{
		Name:       "namespaces",
		Kind:       "Namespace",
		Namespaced: false,
		GetAttr:    UnstructuredGetAttr("Namespace"),
	},
	{
		Name:       "networkpolicies",
		Kind:       "NetworkPolicy",
		Group:      "networking.k8s.io",
		Namespaced: false,
		GetAttr:    UnstructuredGetAttr("NetworkPolicy"),
	},
}

Functions

func InterfaceToUnstructuredSlice

func InterfaceToUnstructuredSlice(slice []interface{}) []unstructured.Unstructured

func ListImageTags

func ListImageTags(nodeName string, localCache LocalCache) ([]string, error)

func NewListWatcher

func NewListWatcher(ctx context.Context, client dynamic.Interface, resourceInfo ResourceInfo, fieldSelector fields.Selector) *cache.ListWatch

Create a new ListWatch for a reflector or other code to use

To maximize compatiblity with authorizers this has the following behavior: - The request is always performed in the given namespace when possible.

		For example when listing configmaps this is used
   	api/v1/namespaces/default/configmaps?fieldSelector=metadata.name%3Dmy-cm%2Cmetadata.namespace%3Ddefault

		rather than
   	api/v1/configmaps?fieldSelector=metadata.name%3Dmy-cm%2Cmetadata.namespace%3Ddefault

		Even though these requests select the same elements, the node authorizer in the api server
		rejects the latter due to insufficient node premissions.

- If a single item is being requested a Get is used rather than a List

For example when listing persistentvolumeclaims this is used
	api/v1/namespaces/default/persistentvolumeclaims/my-pvc

rather than
	api/v1/namespaces/default/persistentvolumeclaims?fieldSelector=metadata.name%3Dmy-pvc

Even though these requests select the get elements, the node authorizer in the api server
rejects the latter due to insufficient node premissions.

Node permissions can be found in 'plugin/pkg/auth/authorizer/node/node_authorizer.go'.

func NewLocalCache

func NewLocalCache(ctx context.Context, storeDir string, resources []ResourceInfo, dynamicClientset dynamic.Interface) (*localCache, error)

Call with SupportedResources

func SelectorUniquelyIdentifiesObject

func SelectorUniquelyIdentifiesObject(selector storage.SelectionPredicate, namespacedResource bool) bool

Return true if there is at most one object that can be matched by this selector

func SetContainsSelection

func SetContainsSelection(set fields.Set, sp storage.SelectionPredicate) bool

Return true if the given SelectionPredicate is a subset of the list formed by the field set

func SleepWithContext

func SleepWithContext(ctx context.Context, d time.Duration) bool

func UnstructuredGetAttr

func UnstructuredGetAttr(resourceKind string) storage.AttrFunc

Types

type CachingServer

type CachingServer struct {
	// contains filtered or unexported fields
}

func NewCachingServer

func NewCachingServer(ctx context.Context, node string, storeDir string, config *rest.Config) (*CachingServer, error)

func (*CachingServer) LocalCache

func (c *CachingServer) LocalCache() LocalCache

func (*CachingServer) Serve

func (c *CachingServer) Serve(listener net.Listener) error

type Dependencies

type Dependencies map[string]*depEntry

func (*Dependencies) Add

func (d *Dependencies) Add(group Subset)

func (*Dependencies) Count

func (d *Dependencies) Count(group Subset) uint32

func (*Dependencies) GetAll

func (d *Dependencies) GetAll() []Subset

func (*Dependencies) Has

func (d *Dependencies) Has(group Subset) bool

func (*Dependencies) Remove

func (d *Dependencies) Remove(group Subset) bool

type DependenciesFunc

type DependenciesFunc func(obj runtime.Object) ([]Subset, error)

type LocalCache

type LocalCache interface {
	Get(resource string, namespace string, name string, opts metav1.GetOptions) (runtime.Object, error)
	List(resource string, namespace string, opts metav1.ListOptions) (*unstructured.UnstructuredList, error)
}

type ResourceInfo

type ResourceInfo struct {
	// Resource "NAME" as returned by 'kubectl api-resources'.
	// Example: pods
	Name string
	// Resource "KIND" as returned by 'kubectl api-resources'.Same as 'kind' used in yaml files.
	// Example: Pod
	Kind string
	// Api group
	// Example: networking.k8s.io
	Group      string
	Namespaced bool
	// Mark this resource as disabled, for example, if the apiserver does not support it
	// or we simply wish to never fetch it
	Disabled        bool
	WatchNotAllowed bool
	GetAttr         storage.AttrFunc
	GetDependencies DependenciesFunc
}

type Subset

type Subset struct {
	Name string
	Set  fields.Set
}

func GetUnstructuredPVCDeps

func GetUnstructuredPVCDeps(obj runtime.Object) ([]Subset, error)

func GetUnstructuredPodDeps

func GetUnstructuredPodDeps(obj runtime.Object) ([]Subset, error)

func (Subset) String

func (d Subset) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL