Documentation ¶
Index ¶
- Constants
- Variables
- func EnsureCRDCreated(client apiextensionsclient.Interface) (created bool, err error)
- func GetPodCondition(status *corev1.PodStatus, conditionType corev1.PodConditionType) (int, *corev1.PodCondition)
- func SetDeletePodAfterAppFinish(value bool)
- type ApiServerInstanceClient
- func (p *ApiServerInstanceClient) Create(ins *Instance) error
- func (p *ApiServerInstanceClient) Delete(ins *Instance, options *metav1.DeleteOptions) error
- func (p *ApiServerInstanceClient) Get(ins *Instance) (*Instance, bool, error)
- func (p *ApiServerInstanceClient) Update(current *Instance, expected *Instance) error
- type Controller
- type FakeKubeClient
- type Instance
- type InstanceClient
- type InstanceHealthChecker
- type InstanceSyncer
- type NameIdentityMapper
- type PodAction
Constants ¶
const ( // Time to sleep before polling to see if the pod cache has synced. PodStoreSyncedPollPeriod = 100 * time.Millisecond NodeUnreachablePodReason = "NodeLost" )
const ( // InPlaceUpdateStateKey records whether instance is in inPlace-updating. InPlaceUpdateStateKey string = "tkestack.io/inplace-update-state" // InPlaceUpdateStateValue records the value of InPlaceUpdateStateKey in pod annotations . InPlaceUpdateStateValue string = "true" )
Variables ¶
var CRD = &extensionsobj.CustomResourceDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: "tapps." + tappcontroller.GroupName, }, TypeMeta: metav1.TypeMeta{ Kind: "CustomResourceDefinition", APIVersion: "apiextensions.k8s.io/v1beta1", }, Spec: extensionsobj.CustomResourceDefinitionSpec{ Group: tappcontroller.GroupName, Version: "v1", Scope: extensionsobj.ResourceScope("Namespaced"), Names: extensionsobj.CustomResourceDefinitionNames{ Plural: "tapps", Singular: "tapp", Kind: "TApp", ListKind: "TAppList", }, Subresources: &extensionsobj.CustomResourceSubresources{ Status: &extensionsobj.CustomResourceSubresourceStatus{}, Scale: &extensionsobj.CustomResourceSubresourceScale{ SpecReplicasPath: ".spec.replicas", StatusReplicasPath: ".status.replicas", LabelSelectorPath: &scaleLabelSelector, }, }, }, }
Functions ¶
func EnsureCRDCreated ¶
func EnsureCRDCreated(client apiextensionsclient.Interface) (created bool, err error)
EnsureCRDCreated tries to create/update CRD, returns (true, nil) if succeeding, otherwise returns (false, nil). 'err' should always be nil, because it is used by wait.PollUntil(), and it will exit if it is not nil.
func GetPodCondition ¶
func GetPodCondition(status *corev1.PodStatus, conditionType corev1.PodConditionType) (int, *corev1.PodCondition)
GetPodCondition extracts the provided condition from the given status and returns that. Returns nil and -1 if the condition is not present, and the index of the located condition.
func SetDeletePodAfterAppFinish ¶
func SetDeletePodAfterAppFinish(value bool)
Types ¶
type ApiServerInstanceClient ¶
type ApiServerInstanceClient struct { KubeClient kubernetes.Interface Recorder record.EventRecorder InstanceHealthChecker // contains filtered or unexported fields }
ApiServerInstanceClient is a instance aware Kubernetes client.
func (*ApiServerInstanceClient) Create ¶
func (p *ApiServerInstanceClient) Create(ins *Instance) error
func (*ApiServerInstanceClient) Delete ¶
func (p *ApiServerInstanceClient) Delete(ins *Instance, options *metav1.DeleteOptions) error
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller is the controller implementation for TApp resources
func NewController ¶
func NewController( kubeclientset kubernetes.Interface, tappclientset clientset.Interface, kubeInformerFactory kubeinformers.SharedInformerFactory, tappInformerFactory informers.SharedInformerFactory) *Controller
NewController returns a new tapp controller
func (*Controller) GetEventRecorder ¶
func (c *Controller) GetEventRecorder() record.EventRecorder
func (*Controller) Run ¶
func (c *Controller) Run(threadiness int, stopCh <-chan struct{}) error
Run will set up the event handlers for types we are interested in, as well as syncing informer caches and starting workers. It will block until stopCh is closed, at which point it will shutdown the workqueue and wait for workers to finish processing their current work items.
type FakeKubeClient ¶
type FakeKubeClient struct {
// contains filtered or unexported fields
}
func (*FakeKubeClient) Apps ¶
func (client *FakeKubeClient) Apps()
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
instance is the control block used to transmit all updates about a single instance. It serves as the manifest for a single instance. Users must populate the pod and parent fields to pass it around safely.
type InstanceClient ¶
type InstanceClient interface { InstanceHealthChecker Delete(*Instance, *metav1.DeleteOptions) error Get(*Instance) (*Instance, bool, error) Create(*Instance) error Update(*Instance, *Instance) error }
InstanceClient is a client for managing instances.
type InstanceHealthChecker ¶
type InstanceHealthChecker interface {
// contains filtered or unexported methods
}
InstanceHealthChecker is an interface to check instance health. It makes a boolean decision based on the given pod.
type InstanceSyncer ¶
type InstanceSyncer struct {
InstanceClient
}
func (*InstanceSyncer) SyncInstances ¶
func (syncer *InstanceSyncer) SyncInstances(add, del, forceDel, update []*Instance)
type NameIdentityMapper ¶
type NameIdentityMapper struct {
// contains filtered or unexported fields
}
NameIdentityMapper assigns names to instances. It also puts the instance in the same namespace as the parent.
func (*NameIdentityMapper) Identity ¶
func (n *NameIdentityMapper) Identity(instance *corev1.Pod) string
Identity returns the name identity of the instance.
func (*NameIdentityMapper) SetIdentity ¶
func (n *NameIdentityMapper) SetIdentity(id string, pod *corev1.Pod)
SetIdentity sets the instance namespace, name, hostname and subdomain.