status

package
v0.0.0-...-bb2f907 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PreInstallHookLabel string = "emco/preinstallHook"

Functions

func AddResourceLabels

func AddResourceLabels(unstruct *unstructured.Unstructured, labels map[string]string)

AddResourceLabels adds label to resource

func AddServiceLabelsPodsIfPresent

func AddServiceLabelsPodsIfPresent(unstruct *unstructured.Unstructured, labels map[string]string)

AddServiceLabelsPodsIfPresent finds the TemplateSpec from any workload object that contains it and changes the spec to include the service labels

func AddServicesLabels

func AddServicesLabels(res []byte, services []string) ([]byte, error)

AddServicesLabels adds the service labels to resource

func EqualIgnoreHash

func EqualIgnoreHash(template1, template2 *v1.PodTemplateSpec) bool

EqualIgnoreHash returns true if two given podTemplateSpec are equal, ignoring the diff in value of Labels[pod-template-hash] We ignore pod-template-hash because:

  1. The hash result would be different upon podTemplateSpec API changes (e.g. the addition of a new field will cause the hash code to change)
  2. The deployment template won't have hash labels

func FindNewReplicaSet

func FindNewReplicaSet(deployment *apps.Deployment, rsList []*apps.ReplicaSet) *apps.ReplicaSet

FindNewReplicaSet returns the new RS this given deployment targets (the one with the same pod template).

func GetNewReplicaSet

func GetNewReplicaSet(ctx context.Context, deployment *apps.Deployment, c appsclient.AppsV1Interface) (*apps.ReplicaSet, error)

GetNewReplicaSet returns a replica set that matches the intent of the given deployment; get ReplicaSetList from client interface. Returns nil if the new replica set doesn't exist yet.

func GetStatusCR

func GetStatusCR(label string, extraLabel string, namespace string) ([]byte, error)

GetStatusCR returns a status monitoring customer resource

func HandleResourcesStatus

func HandleResourcesStatus(ctx context.Context, acID, app, cluster string, rbData *rb.ResourceBundleState)

Update status for the App ready on a cluster and check if app ready on all clusters

func IsRollingUpdate

func IsRollingUpdate(deployment *apps.Deployment) bool

IsRollingUpdate returns true if the strategy type is a rolling update.

func ListReplicaSets

func ListReplicaSets(ctx context.Context, deployment *apps.Deployment, getRSList RsListFunc) ([]*apps.ReplicaSet, error)

ListReplicaSets returns a slice of RSes the given deployment targets. Note that this does NOT attempt to reconcile ControllerRef (adopt/orphan), because only the controller itself should do that. However, it does filter out anything whose ControllerRef doesn't match.

func MaxUnavailable

func MaxUnavailable(deployment apps.Deployment) int32

MaxUnavailable returns the maximum unavailable pods a rolling deployment can take.

func ResolveFenceposts

func ResolveFenceposts(maxSurge, maxUnavailable *intstrutil.IntOrString, desired int32) (int32, int32, error)

ResolveFenceposts resolves both maxSurge and maxUnavailable. This needs to happen in one step. For example:

2 desired, max unavailable 1%, surge 0% - should scale old(-1), then new(+1), then old(-1), then new(+1) 1 desired, max unavailable 1%, surge 0% - should scale old(-1), then new(+1) 2 desired, max unavailable 25%, surge 1% - should scale new(+1), then old(-1), then new(+1), then old(-1) 1 desired, max unavailable 25%, surge 1% - should scale new(+1), then old(-1) 2 desired, max unavailable 0%, surge 1% - should scale new(+1), then old(-1), then new(+1), then old(-1) 1 desired, max unavailable 0%, surge 1% - should scale new(+1), then old(-1)

func TagPodsIfPresent

func TagPodsIfPresent(unstruct *unstructured.Unstructured, label map[string]string)

TagPodsIfPresent finds the TemplateSpec from any workload object that contains it and changes the spec to include the tag label

func TagResource

func TagResource(res []byte, label map[string]string) ([]byte, error)

TagResource with label

func UpdateAppReadyStatus

func UpdateAppReadyStatus(ctx context.Context, acID, app string, cluster string, rbData *rb.ResourceBundleState) bool

Types

type ReadyChecker

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

ReadyChecker is a type that can check core Kubernetes types for readiness.

func NewReadyChecker

func NewReadyChecker(opts ...ReadyCheckerOption) ReadyChecker

NewReadyChecker creates a new checker. Passed ReadyCheckerOptions can be used to override defaults.

func (*ReadyChecker) DaemonSetReady

func (c *ReadyChecker) DaemonSetReady(ds *appsv1.DaemonSet) bool

func (*ReadyChecker) DeploymentReady

func (c *ReadyChecker) DeploymentReady(dep *appsv1.Deployment) bool

func (*ReadyChecker) JobReady

func (c *ReadyChecker) JobReady(job *batchv1.Job) bool

func (*ReadyChecker) JobSuccess

func (c *ReadyChecker) JobSuccess(job *batchv1.Job) bool

func (*ReadyChecker) PodReady

func (c *ReadyChecker) PodReady(pod *corev1.Pod) bool

PodReady returns true if a pod is ready; false otherwise.

func (*ReadyChecker) PodSuccess

func (c *ReadyChecker) PodSuccess(pod *corev1.Pod) bool

These methods are mainly for hook implementations.

For most kinds, the checks to see if the resource is marked as Added or Modified by the Kubernetes event stream is enough. For some kinds, more is required:

  • Jobs: A job is marked "Ready" when it has successfully completed. This is ascertained by watching the Status fields in a job's output.
  • Pods: A pod is marked "Ready" when it has successfully completed. This is ascertained by watching the status.phase field in a pod's output.

func (*ReadyChecker) ServiceReady

func (c *ReadyChecker) ServiceReady(s *corev1.Service) bool

func (*ReadyChecker) StatefulSetReady

func (c *ReadyChecker) StatefulSetReady(sts *appsv1.StatefulSet) bool

func (*ReadyChecker) VolumeReady

func (c *ReadyChecker) VolumeReady(v *corev1.PersistentVolumeClaim) bool

type ReadyCheckerOption

type ReadyCheckerOption func(*ReadyChecker)

ReadyCheckerOption is a function that configures a ReadyChecker.

func CheckJobs

func CheckJobs(checkJobs bool) ReadyCheckerOption

CheckJobs returns a ReadyCheckerOption that configures a ReadyChecker to consider readiness of Job resources.

func PausedAsReady

func PausedAsReady(pausedAsReady bool) ReadyCheckerOption

PausedAsReady returns a ReadyCheckerOption that configures a ReadyChecker to consider paused resources to be ready. For example a Deployment with spec.paused equal to true would be considered ready.

type ReplicaSetsByCreationTimestamp

type ReplicaSetsByCreationTimestamp []*apps.ReplicaSet

ReplicaSetsByCreationTimestamp sorts a list of ReplicaSet by creation timestamp, using their names as a tie breaker.

func (ReplicaSetsByCreationTimestamp) Len

func (ReplicaSetsByCreationTimestamp) Less

func (ReplicaSetsByCreationTimestamp) Swap

func (o ReplicaSetsByCreationTimestamp) Swap(i, j int)

type RsListFunc

type RsListFunc func(context.Context, string, metav1.ListOptions) ([]*apps.ReplicaSet, error)

RsListFunc returns the ReplicaSet from the ReplicaSet namespace and the List metav1.ListOptions.

func RsListFromClient

func RsListFromClient(c appsclient.AppsV1Interface) RsListFunc

RsListFromClient returns an rsListFunc that wraps the given client.

Jump to

Keyboard shortcuts

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