kubernetes

package
v0.0.0-...-162ddea Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CRDStrategyName          = "crd"
	DefaultUpgradeNamespace  = "default"
	OwnershipAnnotationKey   = "app.kubernetes.io/managed-by"
	ScopeAnnotationKey       = "instancemgr.keikoproj.io/upgrade-scope"
	OwnershipAnnotationValue = "instance-manager"
)
View Source
const (
	SpotRecommendationReason  = "SpotRecommendationGiven"
	SpotRecommendationVersion = "v1alpha1"
)
View Source
const (
	RollingUpdateStrategyName = "rollingupdate"
)

Variables

View Source
var (
	// InvolvedObjectKind is the default kind of involved objects
	InvolvedObjectKind = "InstanceGroup"
	// EventName is the default name for service events
	EventControllerName = "instance-manager"
	// EventLevelNormal is the level of a normal event
	EventLevelNormal = "Normal"
	// EventLevelWarning is the level of a warning event
	EventLevelWarning = "Warning"

	InstanceGroupCreatedEvent       EventKind = "InstanceGroupCreated"
	InstanceGroupDeletedEvent       EventKind = "InstanceGroupDeleted"
	NodesReadyEvent                 EventKind = "InstanceGroupNodesReady"
	NodesNotReadyEvent              EventKind = "InstanceGroupNodesNotReady"
	InstanceGroupUpgradeFailedEvent EventKind = "InstanceGroupUpgradeFailed"

	EventLevels = map[EventKind]string{
		InstanceGroupCreatedEvent:       EventLevelNormal,
		InstanceGroupDeletedEvent:       EventLevelNormal,
		NodesNotReadyEvent:              EventLevelWarning,
		NodesReadyEvent:                 EventLevelNormal,
		InstanceGroupUpgradeFailedEvent: EventLevelWarning,
	}

	EventMessages = map[EventKind]string{
		InstanceGroupCreatedEvent:       "instance group has been successfully created",
		InstanceGroupDeletedEvent:       "instance group has been successfully deleted",
		InstanceGroupUpgradeFailedEvent: "instance group has failed upgrading",
		NodesNotReadyEvent:              "instance group nodes are not ready",
		NodesReadyEvent:                 "instance group nodes are ready",
	}
)

Functions

func AddAnnotation

func AddAnnotation(u *unstructured.Unstructured, key, value string)

func CRDExists

func CRDExists(kubeClient dynamic.Interface, name string) bool

func CRDFullName

func CRDFullName(resource, group string) string

func ConfigmapHash

func ConfigmapHash(cm *corev1.ConfigMap) string

func GetGVR

func GetGVR(customResource *unstructured.Unstructured, CRDName string) schema.GroupVersionResource

func GetKubernetesClient

func GetKubernetesClient() (kubernetes.Interface, error)

func GetKubernetesConfig

func GetKubernetesConfig() (*rest.Config, error)

func GetKubernetesDynamicClient

func GetKubernetesDynamicClient() (dynamic.Interface, error)

func GetKubernetesLocalConfig

func GetKubernetesLocalConfig() (*rest.Config, error)

func GetReadyNodesByInstance

func GetReadyNodesByInstance(instanceIds []string, nodes *corev1.NodeList) []string

func GetUnstructuredInstanceGroup

func GetUnstructuredInstanceGroup(instanceGroup *v1alpha1.InstanceGroup) (*unstructured.Unstructured, error)

func GetUnstructuredPath

func GetUnstructuredPath(u *unstructured.Unstructured, jsonPath string) (string, error)

func HasAnnotation

func HasAnnotation(annotations map[string]string, key string) bool

func HasAnnotationWithValue

func HasAnnotationWithValue(annotations map[string]string, key, value string) bool

func IsDesiredNodesReady

func IsDesiredNodesReady(nodes *corev1.NodeList, instanceIds []string, desiredCount int) (bool, error)

func IsMinNodesReady

func IsMinNodesReady(nodes *corev1.NodeList, instanceIds []string, minCount int) (bool, error)

func IsNodeReady

func IsNodeReady(n corev1.Node) bool

func IsPathValue

func IsPathValue(resource unstructured.Unstructured, path, value string) bool

func IsResourceActive

func IsResourceActive(kube dynamic.Interface, instanceGroup *v1alpha1.InstanceGroup) bool

func IsStorageError

func IsStorageError(err error) bool

func MergePatch

func MergePatch(obj v1alpha1.InstanceGroup) client.Patch

func NormalizeName

func NormalizeName(customResource *unstructured.Unstructured, id string)

func ParseCustomResourceYaml

func ParseCustomResourceYaml(raw string) (*unstructured.Unstructured, error)

func ProcessCRDStrategy

func ProcessCRDStrategy(kube dynamic.Interface, instanceGroup *v1alpha1.InstanceGroup, configName string) (bool, error)

func ProcessRollingUpgradeStrategy

func ProcessRollingUpgradeStrategy(req *RollingUpdateRequest) (bool, error)

func RenderCustomResource

func RenderCustomResource(tpl string, params interface{}) (string, error)

func ResourceGVR

func ResourceGVR(kube dynamic.Interface, instanceGroup *v1alpha1.InstanceGroup) (schema.GroupVersionResource, error)

Types

type EventKind

type EventKind string

EventKind defines the kind of an event

type EventLevel

type EventLevel string

EventLevel defines the level of an event

type EventPublisher

type EventPublisher struct {
	Client          kubernetes.Interface
	Name            string
	Namespace       string
	UID             types.UID
	ResourceVersion string
}

func (*EventPublisher) Publish

func (e *EventPublisher) Publish(kind EventKind, keysAndValues ...interface{})

type KubernetesClientSet

type KubernetesClientSet struct {
	Kubernetes  kubernetes.Interface
	KubeDynamic dynamic.Interface
}

type RollingUpdateRequest

type RollingUpdateRequest struct {
	AwsWorker        awsprovider.AwsWorker
	ClusterNodes     *corev1.NodeList
	ScalingGroupName string
	MaxUnavailable   int
	DesiredCapacity  int
	AllInstances     []string
	UpdateTargets    []string
}

type SpotReccomendationList

type SpotReccomendationList []SpotRecommendation

func (SpotReccomendationList) Len

func (p SpotReccomendationList) Len() int

func (SpotReccomendationList) Less

func (p SpotReccomendationList) Less(i, j int) bool

func (SpotReccomendationList) Swap

func (p SpotReccomendationList) Swap(i, j int)

type SpotRecommendation

type SpotRecommendation struct {
	APIVersion string `yaml:"apiVersion"`
	SpotPrice  string `yaml:"spotPrice"`
	UseSpot    bool   `yaml:"useSpot"`
	EventTime  time.Time
}

func GetSpotRecommendation

func GetSpotRecommendation(kube kubernetes.Interface, identifier string) (SpotRecommendation, error)

Jump to

Keyboard shortcuts

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