k8s

package
v1.17.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: Apache-2.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultMutationHelper

type DefaultMutationHelper struct {
	Expected client.Object
}

DefaultMutationHelper provides specific pre and post mutation operations on a Secret object. Important, suppose that hash computation is done on Secret's "Data" field. However "StringData" can be used as usual to store string information.

func (*DefaultMutationHelper) GetObject

func (r *DefaultMutationHelper) GetObject() client.Object

GetObject return the (K8S) resource Object (i.e. Meta + Runtime part) for used by the MutationHelper

func (*DefaultMutationHelper) GetObjectSpec

func (r *DefaultMutationHelper) GetObjectSpec() interface{}

GetSpec provide a "virtual" Spec for this object that can be used to compute hashable Ref. Pre/PostMutate() methods, here, should be built in respect to this choice

func (*DefaultMutationHelper) PostMutate

func (r *DefaultMutationHelper) PostMutate() error

PostMutate xx

func (*DefaultMutationHelper) PreMutate

func (r *DefaultMutationHelper) PreMutate() error

PreMutate xx

type HashableRefHelper

type HashableRefHelper struct {
	client.Object

	oktres.MutationHelper
	// contains filtered or unexported fields
}

HashableRefHelper xx

func (*HashableRefHelper) AddMetaAnnotations

func (hr *HashableRefHelper) AddMetaAnnotations()

AddMetaAnnotations Add all annotations (except the hash itself!!!) to the reference for hash computation

func (*HashableRefHelper) AddMetaAnnotationsValues

func (hr *HashableRefHelper) AddMetaAnnotationsValues(keys ...string)

AddMetaAnnotationsValues xx

func (*HashableRefHelper) AddMetaLabelValues

func (hr *HashableRefHelper) AddMetaLabelValues(keys ...string)

AddMetaLabelValues xx

func (*HashableRefHelper) AddMetaLabels

func (hr *HashableRefHelper) AddMetaLabels()

AddMetaLabels xx

func (*HashableRefHelper) AddMetaMainFields

func (hr *HashableRefHelper) AddMetaMainFields()

AddMetaMainFields Shortcut to add main Meta fields to the reference for hash computation (Labels, Annotations, ownerReferences).

func (*HashableRefHelper) AddSpec

func (hr *HashableRefHelper) AddSpec() error

AddSpec If the MutationHelper defines what is the Spec of the resource Object, this method adds it to the Hashable Ref. If the MutationHelper do not defines a Spec object, this method does nothing but return an error (of type implementation)

func (*HashableRefHelper) AddUserData

func (hr *HashableRefHelper) AddUserData(ref interface{})

AddUserData xx

func (*HashableRefHelper) AddWholeObject

func (hr *HashableRefHelper) AddWholeObject()

AddWholeObject The whole object will be compared. Not recommended, this option is prone to discrepancies due to some fields managed by the Cluster

func (*HashableRefHelper) GetRef

func (hr *HashableRefHelper) GetRef() interface{}

GetRef returns the hashable reference (interface{}) used in Hash computation and comparaison to detect an object's modification during a reconciliation

func (*HashableRefHelper) Init

func (hr *HashableRefHelper) Init(mutationHelper oktres.MutationHelper)

Init Initialize a HashableRef helper

type MutableResourceObject

type MutableResourceObject struct {
	ResourceObject // OKT K8S resource
	// contains filtered or unexported fields
}

MutableResourceObject implements an ObjectResource with mutation facilities

func (*MutableResourceObject) LastSyncState

func (r *MutableResourceObject) LastSyncState() bool

LastSyncState Tells if call to UpdateSyncStatus() detected a modification on the resource regarding its cluster version Can differ from NeedResync as this last stays TRUE for ever once triggered.

func (*MutableResourceObject) NeedResync

func (r *MutableResourceObject) NeedResync() bool

NeedResync Tells if the expected object has been modified regarding its cluster version.

func (*MutableResourceObject) UpdatePeer

func (r *MutableResourceObject) UpdatePeer() error

UpdatePeer Update peer object. Can NOT succeed if the resource has been marked as "to be created" at OKT's registration time. Reset NeedResync flag to false in case of success.

func (*MutableResourceObject) UpdateSyncStatus

func (r *MutableResourceObject) UpdateSyncStatus(ref okthash.HashableRef) error

UpdateSyncStatus Apply an annotation fingerprint to the object which permits to follows object modifications. Update status telling if yes or no the expected value is Synched with the Cluster Resource When it is an object creation, no existing hash value exists, thus the needResync property will be TRUE!

type ResourceObject

type ResourceObject struct {
	//context.Context
	oktclients.Kube // Kube implements the OKT Client interface for a Kubernetes object

	// True by default, tell if yes or a call to SetOwnerReference modify Metadata with the owner or not
	EnableOwnerReference bool
	// contains filtered or unexported fields
}

ResourceObject An OKT resource for K8S types which implements the OKT Resource (not Mutable) interface. Thus it can not be instancied as is but, instead, is dedicated to either be implemented as a new Mutable type provinding the Mutations (with Default and with CR) functions, or as a not mutable K8S resource (Read-Only for example).

func (*ResourceObject) CheckExpectedKey

func (or *ResourceObject) CheckExpectedKey() error

CheckExpectedKey Compare NamespacedName before and after mutation. They Must be equals. TODO: Take note that the resource type is not compared (but should it be ?)

func (*ResourceObject) CopyGOStruct

func (or *ResourceObject) CopyGOStruct(src interface{}) error

ApplyGOStruct is a way to copy a source object into a destination object different than the src.DeepCopyInto(dst). It Apply the src GO data structure to a resource object preserving all other existing fields in the destination not present in the source struct.

Here dst object is the resource to update. and the src is the GO struct provided for the update.

func (*ResourceObject) CopyTpl

func (or *ResourceObject) CopyTpl(yaml string, tplValues interface{}) error

CopyTpl Apply a yaml manifest to the current Object which can be a template that is executed with the tplValues (if this last is not nil). The yaml string can also be used to pass a JSON data string, howver in this case, the tplValues are totaly useless and must be nil. Meta are initialised in respect to the OKT principles. See InitResource for details.

func (*ResourceObject) CreatePeer

func (or *ResourceObject) CreatePeer() error

CreatePeer Creates a resource peer on the Cluster site (at the image of the resource in memory)

func (*ResourceObject) GetData

func (or *ResourceObject) GetData() map[string]string

GetData Set parameters data

func (*ResourceObject) GetObject

func (or *ResourceObject) GetObject() runtime.Object

GetObject xx

func (*ResourceObject) Index

func (or *ResourceObject) Index() string

Index Return entry a key index (NGVK, aka GroupVersion Kind and Name) string

func (*ResourceObject) Init

func (or *ResourceObject) Init(client k8sclient.Client, objtyp k8sclient.Object, namespace, name string) error

Init Initialize this resource with its Client (K8S) and a runtime object for the Namespace and Name provided

func (*ResourceObject) IsCreation

func (or *ResourceObject) IsCreation() bool

IsCreation Tell if yes or no this entry designate an object to create on the Cluster

func (*ResourceObject) KindName

func (or *ResourceObject) KindName() string

KindName Return Kind/Name string for this resource

func (*ResourceObject) NamespacedName

func (or *ResourceObject) NamespacedName() types.NamespacedName

NamespacedName return NamespacedName type of the registered object

func (*ResourceObject) SetData

func (or *ResourceObject) SetData(params map[string]string)

SetData Set parameters data

func (*ResourceObject) SetOwnerReference

func (or *ResourceObject) SetOwnerReference(owner runtime.Object, scheme *runtime.Scheme) error

SetOwnerReference Set a the owner reference on a controlled object (in metadata.OwnerReferences field). Warning: This method do nothing if this object has the EnableOwnerReference value set to False! By this way the deletion of the owner (the Custom Resource) will automatically delete the controlled object. Only one controller can be indicated as owner to a controlled object.

func (*ResourceObject) SyncFromPeer

func (or *ResourceObject) SyncFromPeer() error

SyncFromPeer Try to get peer object which determines if it is a creation or not The caller (typically the Reconciler) is in 3 possibles states regarding the resource:

  • It dont know if the resource exists on the cluster
  • It has already got an existing resource on the cluster and need a refresh
  • It is already informed that the resource doest not exists but ask again => NOTHING WILL BE DONE HERE

type SecretMutationHelper

type SecretMutationHelper struct {
	Expected *v1.Secret
}

SecretMutationHelper provides specific pre and post mutation operations on a Secret object. Important, suppose that hash computation is done on Secret's "Data" field. However "StringData" can be used as usual to store string information.

func (*SecretMutationHelper) GetObject

func (r *SecretMutationHelper) GetObject() client.Object

GetObject return the (K8S) resource Object (i.e. Meta + Runtime part) for used by the MutationHelper

func (*SecretMutationHelper) GetObjectSpec

func (r *SecretMutationHelper) GetObjectSpec() interface{}

GetSpec provide a "virtual" Spec for this object that can be used to compute hashable Ref. Pre/PostMutate() methods, here, are built in respect to this choice

func (*SecretMutationHelper) PostMutate

func (r *SecretMutationHelper) PostMutate() error

PostMutate xx

func (*SecretMutationHelper) PreMutate

func (r *SecretMutationHelper) PreMutate() error

PreMutate xx

type StatefulSetHelper

type StatefulSetHelper struct {
	StatefulSetStub
}

StatefulSetHelper an OKT extended Statefulset resource

func (*StatefulSetHelper) GetReadyPodsCount

func (r *StatefulSetHelper) GetReadyPodsCount() (ready, remaining int32)

GetReadyPodsCount Returns ready pods count and remaining count with regard to the total count deployed. Note that if the StatefulSet is not yet deployed on Cluster, the remaining count is always 0

func (*StatefulSetHelper) GetRunningPodsCount

func (r *StatefulSetHelper) GetRunningPodsCount() (running, remaining int32, err error)

GetRunningPodsCount Returns running pods count and remaining count with regard to the total count deployed. Note that if the StatefulSet is not yet deployed on Cluster, the remaining count is always 0

type StatefulSetStub

type StatefulSetStub interface {
	GetResourceObject() *ResourceObject
	GetExpected() *k8sapp.StatefulSet
}

Jump to

Keyboard shortcuts

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