controllers

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2020 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Overview

Copyright 2019 yametech Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	// FailedCreatePodReason is added in an event and in a replica set condition
	// when a pod for a replica set is failed to be created.
	FailedCreatePodReason = "FailedCreate"
	// SuccessfulCreatePodReason is added in an event when a pod for a replica set
	// is successfully created.
	SuccessfulCreatePodReason = "SuccessfulCreate"
	// FailedDeletePodReason is added in an event and in a replica set condition
	// when a pod for a replica set is failed to be deleted.
	FailedDeletePodReason = "FailedDelete"
	// SuccessfulDeletePodReason is added in an event when a pod for a replica set
	// is successfully deleted.
	SuccessfulDeletePodReason = "SuccessfulDelete"
)

Reasons for pod events

Variables

This section is empty.

Functions

func ApplyRevision

func ApplyRevision(set *nuwav1.StatefulSet, revision *apps.ControllerRevision) (*nuwav1.StatefulSet, error)

ApplyRevision returns a new StatefulSet constructed by restoring the state in revision to set. If the returned error is nil, the returned StatefulSet is valid.

func GetPodFromTemplate

func GetPodFromTemplate(template *corev1.PodTemplateSpec, parentObject runtime.Object, controllerRef *metav1.OwnerReference) (*corev1.Pod, error)

func GetStatefulsetConditition

func GetStatefulsetConditition(status nuwav1.StatefulSetStatus, condType apps.StatefulSetConditionType) *apps.StatefulSetCondition

GetStatefulsetConditition returns the condition with the provided type.

func Match

func Match(ss *nuwav1.StatefulSet, history *apps.ControllerRevision) (bool, error)

Match check if the given StatefulSet's template matches the template stored in the given history.

func NewStatefulsetCondition

func NewStatefulsetCondition(conditionType apps.StatefulSetConditionType, conditionStatus v1.ConditionStatus, reason, message string) apps.StatefulSetCondition

NewStatefulsetCondition creates a new statefulset condition.

func SetStatefulsetCondition

func SetStatefulsetCondition(status *nuwav1.StatefulSetStatus, condition apps.StatefulSetCondition)

SetStatefulsetCondition updates the statefulset to include the provided condition. If the condition that

Types

type ControlInterface

type ControlInterface interface {
	// UpdateStatefulSet implements the control logic for Pod creation, update, and deletion, and
	// persistent volume creation, update, and deletion.
	// If an implementation returns a non-nil error, the invocation will be retried using a rate-limited strategy.
	// Implementors should sink any errors that they do not wish to trigger a retry, and they may feel free to
	// exit exceptionally at any point provided they wish the update to be re-run at a later point in time.
	UpdateStatefulSet(set *nuwav1.StatefulSet, pods []*v1.Pod) error
	// ListRevisions returns a array of the ControllerRevisions that represent the revisions of set. If the returned
	// error is nil, the returns slice of ControllerRevisions is valid.
	ListRevisions(set *nuwav1.StatefulSet) ([]*apps.ControllerRevision, error)
	// AdoptOrphanRevisions adopts any orphaned ControllerRevisions that match set's Selector. If all adoptions are
	// successful the returned error is nil.
	AdoptOrphanRevisions(set *nuwav1.StatefulSet, revisions []*apps.ControllerRevision) error
}

ControlInterface implements the control logic for updating StatefulSets and their children Pods. It is implemented as an interface to allow for extensions that provide different semantics. Currently, there is only one implementation.

func NewDefaultStatefulSetControl

func NewDefaultStatefulSetControl(
	client client.Client,
	podControl StatefulPodControlInterface,
	statusUpdater StatusUpdaterInterface,
	controllerHistory history.Interface,
	recorder record.EventRecorder,
	log logr.Logger,
) ControlInterface

NewDefaultStatefulSetControl returns a new instance of the default implementation ControlInterface that implements the documented semantics for StatefulSets. podControl is the PodControlInterface used to create, update, and delete Pods and to create PersistentVolumeClaims. statusUpdater is the StatusUpdaterInterface used to update the status of StatefulSets. You should use an instance returned from NewRealStatefulPodControl() for any scenario other than testing.

type CoordinateErr

type CoordinateErr error
var ErrNeedAtLeastZone CoordinateErr = fmt.Errorf("%s", "coordinate need to specify at least zone")

type InPlaceUpdateSpec

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

InPlaceUpdateSpec records the images of containers which need to in-place update.

type InjectorReconciler

type InjectorReconciler struct {
	client.Client
	Log    logr.Logger
	Scheme *runtime.Scheme
}

InjectorReconciler reconciles a Injector object

func (*InjectorReconciler) Reconcile

func (r *InjectorReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error)

+kubebuilder:rbac:groups=nuwa.nip.io,resources=stones,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=nuwa.nip.io,resources=stones/status,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=nuwa.nip.io,resources=waters,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=nuwa.nip.io,resources=waters/status,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=nuwa.nip.io,resources=injectors,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=nuwa.nip.io,resources=injectors/status,verbs=get;update;patch

func (*InjectorReconciler) SetupWithManager

func (r *InjectorReconciler) SetupWithManager(mgr ctrl.Manager) error

type RealPodControl

type RealPodControl struct {
	client.Client
	Recorder record.EventRecorder
}

RealPodControl is the default implementation of PodControlInterface.

func (RealPodControl) CreatePods

func (r RealPodControl) CreatePods(namespace string, template *corev1.PodTemplateSpec, object runtime.Object) error

func (RealPodControl) CreatePodsOnNode

func (r RealPodControl) CreatePodsOnNode(nodeName, namespace string, template *corev1.PodTemplateSpec, object runtime.Object, controllerRef *metav1.OwnerReference) error

func (RealPodControl) CreatePodsWithControllerRef

func (r RealPodControl) CreatePodsWithControllerRef(namespace string, template *corev1.PodTemplateSpec, controllerObject runtime.Object, controllerRef *metav1.OwnerReference) error

func (RealPodControl) DeletePod

func (r RealPodControl) DeletePod(namespace string, podID string, object runtime.Object) error

func (RealPodControl) PatchPod

func (r RealPodControl) PatchPod(namespace, name string, data []byte) error

type StatefulPodControlInterface

type StatefulPodControlInterface interface {
	// CreateStatefulPod create a Pod in a StatefulSet. Any PVCs necessary for the Pod are created prior to creating
	// the Pod. If the returned error is nil the Pod and its PVCs have been created.
	CreateStatefulPod(set *nuwav1.StatefulSet, pod *v1.Pod) error
	// UpdateStatefulPod Updates a Pod in a StatefulSet. If the Pod already has the correct identity and stable
	// storage this method is a no-op. If the Pod must be mutated to conform to the Set, it is mutated and updated.
	// pod is an in-out parameter, and any updates made to the pod are reflected as mutations to this parameter. If
	// the create is successful, the returned error is nil.
	UpdateStatefulPod(set *nuwav1.StatefulSet, pod *v1.Pod) error
	// InPlaceUpdateStatefulPod in-place updates a Pod in a StatefulSet. It cloud only update image of containers.
	InPlaceUpdateStatefulPod(set *nuwav1.StatefulSet, pod *v1.Pod, spec *InPlaceUpdateSpec) error
	// UpdateStatefulPodCondition update condition in pod.Status.
	UpdateStatefulPodCondition(set *nuwav1.StatefulSet, pod *v1.Pod, condition v1.PodCondition) error
	// DeleteStatefulPod deletes a Pod in a StatefulSet. The pods PVCs are not deleted. If the delete is successful,
	// the returned error is nil.
	DeleteStatefulPod(set *nuwav1.StatefulSet, pod *v1.Pod) error
}

StatefulPodControlInterface defines the interface that StatefulSetController uses to create, update, and delete Pods, and to update the Status of a StatefulSet. It follows the design paradigms used for PodControl, but its implementation provides for PVC creation, ordered Pod creation, ordered Pod termination, and Pod identity enforcement. Like controller.PodControlInterface, it is implemented as an interface to provide for testing fakes.

func NewRealStatefulPodControl

func NewRealStatefulPodControl(
	client client.Client,
	recorder record.EventRecorder,
) StatefulPodControlInterface

NewRealStatefulPodControl returns a new realStatefulPodControl

type StatefulSetReconciler

type StatefulSetReconciler struct {
	client.Client
	Log    logr.Logger
	Scheme *runtime.Scheme
	// contains filtered or unexported fields
}

StatefulSetReconciler reconciles a StatefulSet object

func (*StatefulSetReconciler) Reconcile

func (ssc *StatefulSetReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error)

Reconcile reads that state of the cluster for a StatefulSet object and makes changes based on the state read and what is in the StatefulSet.Spec Automatically generate RBAC rules to allow the Controller to read and write Pods +kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=core,resources=pods/status,verbs=get;update;patch +kubebuilder:rbac:groups=core,resources=events,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=core,resources=persistentvolumeclaims,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=apps,resources=controllerrevisions,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=nuwa.nip.io,resources=statefulsets,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=nuwa.nip.io,resources=statefulsets/status,verbs=get;update;patch

func (*StatefulSetReconciler) SetupWithManager

func (ssc *StatefulSetReconciler) SetupWithManager(mgr ctrl.Manager) error

type StatusUpdaterInterface

type StatusUpdaterInterface interface {
	// UpdateStatefulSetStatus sets the set's Status to status. Implementations are required to retry on conflicts,
	// but fail on other errors. If the returned error is nil set's Status has been successfully set to status.
	UpdateStatefulSetStatus(set *nuwav1.StatefulSet, status *nuwav1.StatefulSetStatus) error
}

StatusUpdaterInterface is an interface used to update the StatefulSetStatus associated with a StatefulSet. For any use other than testing, clients should create an instance using NewRealStatefulSetStatusUpdater.

func NewRealStatefulSetStatusUpdater

func NewRealStatefulSetStatusUpdater(client client.Client) StatusUpdaterInterface

NewRealStatefulSetStatusUpdater returns a StatusUpdaterInterface that updates the Status of a StatefulSet, using the supplied client and setLister.

type StoneReconciler

type StoneReconciler struct {
	client.Client
	Log    logr.Logger
	Scheme *runtime.Scheme
}

StoneReconciler reconciles a Stone object

func (*StoneReconciler) Reconcile

func (r *StoneReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error)

+kubebuilder:rbac:groups=nuwa.nip.io,resources=statefulsets,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=nuwa.nip.io,resources=statefulsets/status,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=nuwa.nip.io,resources=stones,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=nuwa.nip.io,resources=stones/status,verbs=get;update;patch

func (*StoneReconciler) SetupWithManager

func (r *StoneReconciler) SetupWithManager(mgr ctrl.Manager) error

type UpdateExpectations

type UpdateExpectations interface {
	ExpectUpdated(controllerKey, revision string, obj metav1.Object)
	ObserveUpdated(controllerKey, revision string, obj metav1.Object)
	SatisfiedExpectations(controllerKey, revision string) (bool, []string)
	DeleteExpectations(controllerKey string)
}

UpdateExpectations is an interface that allows users to set and wait on expectations of pods update.

func NewUpdateExpectations

func NewUpdateExpectations(getRevision func(metav1.Object) string) UpdateExpectations

NewUpdateExpectations returns a common UpdateExpectations.

type WaterReconciler

type WaterReconciler struct {
	client.Client
	Log    logr.Logger
	Scheme *runtime.Scheme
}

WaterReconciler reconciles a Water object

func (*WaterReconciler) Reconcile

func (r *WaterReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error)

+kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=apps,resources=deployments/status,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=nuwa.nip.io,resources=waters,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=nuwa.nip.io,resources=waters/status,verbs=get;update;patch

func (*WaterReconciler) SetupWithManager

func (r *WaterReconciler) SetupWithManager(mgr ctrl.Manager) error

Jump to

Keyboard shortcuts

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