Documentation ¶
Overview ¶
Package k8sutil for Kubernetes helpers.
Package k8sutil for Kubernetes helpers.
Package k8sutil for Kubernetes helpers.
Package k8sutil for Kubernetes helpers.
Package k8sutil for Kubernetes helpers.
Package k8sutil for Kubernetes helpers.
Package k8sutil for Kubernetes helpers.
Index ¶
- Constants
- Variables
- func AddLabelToDeployement(key, value string, d *v1.Deployment)
- func AddLabelToJob(key, value string, b *batchv1.Job)
- func AddLabelToPod(key, value string, p *corev1.PodTemplateSpec)
- func AddNodeAffinity(nodeAffinity string) (*v1.NodeAffinity, error)
- func AddRookVersionLabelToDaemonSet(d *v1.DaemonSet)
- func AddRookVersionLabelToDeployment(d *v1.Deployment)
- func AddRookVersionLabelToJob(j *v1.Job)
- func AddRookVersionLabelToObjectMeta(meta *metav1.ObjectMeta)
- func ApplyMultus(net rookalpha.NetworkSpec, objectMeta *metav1.ObjectMeta) error
- func BaseKubernetesDeleteOptions() *metav1.DeleteOptions
- func BinariesMountInfo() (v1.EnvVar, v1.Volume, v1.VolumeMount)
- func ClusterDaemonEnvVars(image string) []v1.EnvVar
- func ConfigDirEnvVar(dataDir string) v1.EnvVar
- func ConfigOverrideEnvVar() v1.EnvVar
- func ConfigOverrideMount() v1.VolumeMount
- func ConfigOverrideVolume() v1.Volume
- func CreateDaemonSet(name, namespace string, clientset kubernetes.Interface, ds *apps.DaemonSet) error
- func CreateDeployment(name, namespace string, clientset kubernetes.Interface, dep *apps.Deployment) error
- func CreateOrUpdatePrometheusRule(prometheusRule *monitoringv1.PrometheusRule) (*monitoringv1.PrometheusRule, error)
- func CreateOrUpdateService(clientset kubernetes.Interface, namespace string, ...) (*v1.Service, error)
- func CreateOrUpdateServiceMonitor(serviceMonitorDefinition *monitoringv1.ServiceMonitor) (*monitoringv1.ServiceMonitor, error)
- func CreateService(name, namespace string, clientset kubernetes.Interface, svc *corev1.Service) error
- func CreateStatefulSet(name, namespace string, clientset kubernetes.Interface, ss *apps.StatefulSet) error
- func DeleteBatchJob(clientset kubernetes.Interface, namespace, name string, wait bool) error
- func DeleteConfigMap(clientset kubernetes.Interface, cmName, namespace string, opts *DeleteOptions) error
- func DeleteDaemonset(clientset kubernetes.Interface, namespace, name string) error
- func DeleteDeployment(clientset kubernetes.Interface, namespace, name string) error
- func DeleteReplicaSet(clientset kubernetes.Interface, namespace, name string) error
- func DeleteResource(delete func() error, verify func() error, resource string, opts *DeleteOptions, ...) error
- func GetContainerImage(pod *v1.Pod, name string) (string, error)
- func GetDaemonsets(clientset kubernetes.Interface, namespace, labelSelector string) (*apps.DaemonSetList, error)
- func GetDeploymentImage(clientset kubernetes.Interface, namespace, name, container string) (string, error)
- func GetDeploymentSpecImage(clientset kubernetes.Interface, d apps.Deployment, container string, ...) (string, error)
- func GetDeployments(clientset kubernetes.Interface, namespace, labelSelector string) (*apps.DeploymentList, error)
- func GetK8SVersion(clientset kubernetes.Interface) (*version.Version, error)
- func GetKubernetesNodesMatchingRookNodes(rookNodes []rookalpha.Node, clientset kubernetes.Interface) ([]v1.Node, error)
- func GetMatchingContainer(containers []v1.Container, name string) (v1.Container, error)
- func GetMultusIfName(selector string) (string, error)
- func GetNodeHostNames(clientset kubernetes.Interface) (map[string]string, error)
- func GetNodeNameFromHostname(clientset kubernetes.Interface, hostName string) (string, error)
- func GetNodeSchedulable(node v1.Node) bool
- func GetPodLog(clientset kubernetes.Interface, namespace string, labelSelector string) (string, error)
- func GetPodPhaseMap(pods *v1.PodList) map[v1.PodPhase][]string
- func GetPrometheusRule(ruleFilePath string) (*monitoringv1.PrometheusRule, error)
- func GetRunningPod(clientset kubernetes.Interface) (*v1.Pod, error)
- func GetServiceMonitor(filePath string) (*monitoringv1.ServiceMonitor, error)
- func GetSpecContainerImage(spec v1.PodSpec, name string, initContainer bool) (string, error)
- func GetValidNodes(rookStorage rookalpha.StorageScopeSpec, clientset kubernetes.Interface, ...) []rookalpha.Node
- func Hash(s string) string
- func IndexToName(index int) string
- func MakeRookImage(version string) string
- func MergeResourceRequirements(first, second v1.ResourceRequirements) v1.ResourceRequirements
- func NameEnvVar() v1.EnvVar
- func NameToIndex(name string) (int, error)
- func NamespaceEnvVar() v1.EnvVar
- func NodeConfigURI() (string, error)
- func NodeEnvVar() v1.EnvVar
- func NodeIsInRookNodeList(targetNodeName string, rookNodes []rookalpha.Node) bool
- func NodeIsReady(node v1.Node) bool
- func NodeIsTolerable(node v1.Node, tolerations []v1.Toleration, ignoreWellKnownTaints bool) bool
- func NodeMeetsAffinityTerms(node v1.Node, affinity *v1.NodeAffinity) (bool, error)
- func NodeMeetsPlacementTerms(node v1.Node, placement rookalpha.Placement, ignoreWellKnownTaints bool) (bool, error)
- func ParseServiceType(serviceString string) v1.ServiceType
- func PathToVolumeName(path string) string
- func PodIPEnvVar(property string) v1.EnvVar
- func PodsRunningWithLabel(clientset kubernetes.Interface, namespace, label string) (int, error)
- func RookNodesMatchingKubernetesNodes(rookStorage rookalpha.StorageScopeSpec, kubernetesNodes []v1.Node) []rookalpha.Node
- func RunReplaceableJob(clientset kubernetes.Interface, job *batch.Job, deleteIfFound bool) error
- func SetOwnerRef(object *metav1.ObjectMeta, ownerRef *metav1.OwnerReference)
- func SetOwnerRefs(object *metav1.ObjectMeta, ownerRefs []metav1.OwnerReference)
- func TaintIsWellKnown(t v1.Taint) bool
- func TruncateNodeName(format, nodeName string) string
- func UpdateDeploymentAndWait(context *clusterd.Context, deployment *apps.Deployment, namespace string, ...) (*v1.Deployment, error)
- func UpdateService(clientset kubernetes.Interface, namespace string, ...) (*v1.Service, error)
- func ValidNode(node v1.Node, placement rookalpha.Placement) (bool, error)
- func ValidNodeNoSched(node v1.Node, placement rookalpha.Placement) (bool, error)
- func WaitForDeploymentImage(clientset kubernetes.Interface, namespace, label, container string, ...) error
- func WaitForJobCompletion(clientset kubernetes.Interface, job *batch.Job, timeout time.Duration) error
- func YamlToTolerations(raw string) ([]v1.Toleration, error)
- type ConfigMapKVStore
- func (kv *ConfigMapKVStore) ClearStore(storeName string) error
- func (kv *ConfigMapKVStore) GetStore(storeName string) (map[string]string, error)
- func (kv *ConfigMapKVStore) GetValue(storeName, key string) (string, error)
- func (kv *ConfigMapKVStore) SetValue(storeName, key, value string) error
- func (kv *ConfigMapKVStore) SetValueWithLabels(storeName, key, value string, labels map[string]string) error
- type DeleteOptions
- type WaitOptions
Constants ¶
const ( // Namespace for rook Namespace = "rook" // DefaultNamespace for the cluster DefaultNamespace = "default" // DataDirVolume data dir volume DataDirVolume = "rook-data" // DataDir folder DataDir = "/var/lib/rook" // RookType for the CRD RookType = "kubernetes.io/rook" // PodNameEnvVar is the env variable for getting the pod name via downward api PodNameEnvVar = "POD_NAME" // PodNamespaceEnvVar is the env variable for getting the pod namespace via downward api PodNamespaceEnvVar = "POD_NAMESPACE" // NodeNameEnvVar is the env variable for getting the node via downward api NodeNameEnvVar = "NODE_NAME" // RookVersionLabelKey is the key used for reporting the Rook version which last created or // modified a resource. RookVersionLabelKey = "rook-version" )
const ( // AppAttr app label AppAttr = "app" // ClusterAttr cluster label ClusterAttr = "rook_cluster" // PublicIPEnvVar public IP env var PublicIPEnvVar = "ROOK_PUBLIC_IP" // PrivateIPEnvVar pod IP env var PrivateIPEnvVar = "ROOK_PRIVATE_IP" // DefaultRepoPrefix repo prefix DefaultRepoPrefix = "rook" // ConfigOverrideName config override name ConfigOverrideName = "rook-config-override" // ConfigOverrideVal config override value ConfigOverrideVal = "config" )
const (
BinariesMountPath = "/rook"
)
Variables ¶
var WellKnownTaints = []string{ scheduler.TaintNodeNotReady, scheduler.TaintNodeUnreachable, scheduler.TaintNodeUnschedulable, scheduler.TaintNodeMemoryPressure, scheduler.TaintNodeDiskPressure, scheduler.TaintNodeNetworkUnavailable, scheduler.TaintNodePIDPressure, scheduler.TaintExternalCloudProvider, scheduler.TaintNodeShutdown, }
WellKnownTaints is a list of well-known taint keys in the Kubernetes code base. Kubernetes may automatically apply these taints to nodes during runtime. Most will be added with the `NoSchedule` affect, but some are created with `NoExecute`. Rook may wish to ignore these taints when decided whether to modify resources it creates based on whether taints are likely to have been added by Kubernetes or by the user. see: https://github.com/kubernetes/kubernetes/blob/master/pkg/scheduler/api/well_known_labels.go and: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/#taint-based-evictions
Functions ¶
func AddLabelToDeployement ¶ added in v1.1.0
func AddLabelToDeployement(key, value string, d *v1.Deployment)
func AddLabelToJob ¶ added in v1.1.0
func AddLabelToPod ¶ added in v1.1.0
func AddLabelToPod(key, value string, p *corev1.PodTemplateSpec)
func AddNodeAffinity ¶ added in v1.1.0
func AddNodeAffinity(nodeAffinity string) (*v1.NodeAffinity, error)
AddNodeAffinity will return v1.NodeAffinity or error
func AddRookVersionLabelToDaemonSet ¶ added in v1.0.0
AddRookVersionLabelToDaemonSet adds or updates a label reporting the Rook version which last modified a DaemonSet.
func AddRookVersionLabelToDeployment ¶ added in v1.0.0
func AddRookVersionLabelToDeployment(d *v1.Deployment)
AddRookVersionLabelToDeployment adds or updates a label reporting the Rook version which last modified a deployment.
func AddRookVersionLabelToJob ¶ added in v1.0.0
AddRookVersionLabelToJob adds or updates a label reporting the Rook version which last modified a Job.
func AddRookVersionLabelToObjectMeta ¶ added in v1.1.0
func AddRookVersionLabelToObjectMeta(meta *metav1.ObjectMeta)
func ApplyMultus ¶ added in v1.1.0
func ApplyMultus(net rookalpha.NetworkSpec, objectMeta *metav1.ObjectMeta) error
ApplyMultus apply multus selector to Pods Multus supports short and json syntax, use only one kind at a time.
func BaseKubernetesDeleteOptions ¶ added in v1.1.0
func BaseKubernetesDeleteOptions() *metav1.DeleteOptions
BaseKubernetesDeleteOptions returns the base set of Kubernetes delete options which most delete operations should use.
func BinariesMountInfo ¶ added in v1.0.0
func ClusterDaemonEnvVars ¶ added in v0.9.0
ClusterDaemonEnvVars Environment variables used by storage cluster daemon
func ConfigDirEnvVar ¶ added in v0.4.0
ConfigDirEnvVar config dir env var
func ConfigOverrideEnvVar ¶ added in v0.5.0
ConfigOverrideEnvVar config override env var
func ConfigOverrideMount ¶ added in v0.5.0
func ConfigOverrideMount() v1.VolumeMount
ConfigOverrideMount is an override mount
func ConfigOverrideVolume ¶ added in v0.5.0
ConfigOverrideVolume is an override volume
func CreateDaemonSet ¶ added in v1.0.0
func CreateDaemonSet(name, namespace string, clientset kubernetes.Interface, ds *apps.DaemonSet) error
CreateDaemonSet creates
func CreateDeployment ¶ added in v1.1.0
func CreateDeployment(name, namespace string, clientset kubernetes.Interface, dep *apps.Deployment) error
func CreateOrUpdatePrometheusRule ¶ added in v1.1.0
func CreateOrUpdatePrometheusRule(prometheusRule *monitoringv1.PrometheusRule) (*monitoringv1.PrometheusRule, error)
CreateOrUpdatePrometheusRule creates a prometheusRule object or an error
func CreateOrUpdateService ¶ added in v1.0.0
func CreateOrUpdateService( clientset kubernetes.Interface, namespace string, serviceDefinition *v1.Service, ) (*v1.Service, error)
CreateOrUpdateService creates a service or updates the service declaratively if it already exists.
func CreateOrUpdateServiceMonitor ¶ added in v1.1.0
func CreateOrUpdateServiceMonitor(serviceMonitorDefinition *monitoringv1.ServiceMonitor) (*monitoringv1.ServiceMonitor, error)
CreateOrUpdateServiceMonitor creates serviceMonitor object or an error
func CreateService ¶ added in v1.1.0
func CreateService(name, namespace string, clientset kubernetes.Interface, svc *corev1.Service) error
make a headless svc for statefulset
func CreateStatefulSet ¶ added in v1.0.0
func CreateStatefulSet(name, namespace string, clientset kubernetes.Interface, ss *apps.StatefulSet) error
create a apps.statefulset
func DeleteBatchJob ¶ added in v0.9.0
func DeleteBatchJob(clientset kubernetes.Interface, namespace, name string, wait bool) error
DeleteBatchJob deletes a Kubernetes job.
func DeleteConfigMap ¶ added in v1.1.0
func DeleteConfigMap(clientset kubernetes.Interface, cmName, namespace string, opts *DeleteOptions) error
DeleteConfigMap deletes a ConfigMap.
func DeleteDaemonset ¶ added in v0.6.0
func DeleteDaemonset(clientset kubernetes.Interface, namespace, name string) error
DeleteDaemonset makes a best effort at deleting a daemonset and its pods, then waits for them to be deleted
func DeleteDeployment ¶ added in v0.6.0
func DeleteDeployment(clientset kubernetes.Interface, namespace, name string) error
DeleteDeployment makes a best effort at deleting a deployment and its pods, then waits for them to be deleted
func DeleteReplicaSet ¶ added in v0.9.0
func DeleteReplicaSet(clientset kubernetes.Interface, namespace, name string) error
DeleteReplicaSet makes a best effort at deleting a deployment and its pods, then waits for them to be deleted
func DeleteResource ¶ added in v1.1.0
func DeleteResource( delete func() error, verify func() error, resource string, opts *DeleteOptions, defaultWaitOptions *WaitOptions, ) error
DeleteResource implements the DeleteOptions logic around deletion of a Kubernetes resource.
The delete and verify functions used as parameters should implement and return the error from the Kubernetes `Delete` and `Get` commands respectively.
The resource string will be used to report the resource in log and error messages. A good pattern would be to set this string to the resource type (e.g., Deployment) and the name of the resource (e.g., my-deployment).
The default wait options should specify sane defaults for retry count and retry interval for deletion of the specific resource type. Only retry count and interval will be used from this parameter.
func GetContainerImage ¶ added in v0.7.0
GetContainerImage returns the container image matching the given name for a pod. If the pod only has a single container, the name argument is ignored.
func GetDaemonsets ¶ added in v1.0.3
func GetDaemonsets(clientset kubernetes.Interface, namespace, labelSelector string) (*apps.DaemonSetList, error)
GetDaemonsets returns a list of daemonsets names labels matching a given selector example of a label selector might be "app=rook-ceph-mon, mon!=b" more: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
func GetDeploymentImage ¶ added in v0.9.0
func GetDeploymentImage(clientset kubernetes.Interface, namespace, name, container string) (string, error)
GetDeploymentImage returns the version of the image running in the pod spec for the desired container
func GetDeploymentSpecImage ¶ added in v0.9.0
func GetDeploymentSpecImage(clientset kubernetes.Interface, d apps.Deployment, container string, initContainer bool) (string, error)
GetDeploymentSpecImage returns the image name from the spec
func GetDeployments ¶ added in v0.9.0
func GetDeployments(clientset kubernetes.Interface, namespace, labelSelector string) (*apps.DeploymentList, error)
GetDeployments returns a list of deployment names labels matching a given selector example of a label selector might be "app=rook-ceph-mon, mon!=b" more: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
func GetK8SVersion ¶ added in v0.6.0
func GetK8SVersion(clientset kubernetes.Interface) (*version.Version, error)
GetK8SVersion gets the version of the running K8S cluster
func GetKubernetesNodesMatchingRookNodes ¶ added in v1.0.0
func GetKubernetesNodesMatchingRookNodes(rookNodes []rookalpha.Node, clientset kubernetes.Interface) ([]v1.Node, error)
GetKubernetesNodesMatchingRookNodes lists all the nodes in Kubernetes and returns all the Kubernetes nodes that have a corresponding match in the list of Rook nodes.
func GetMatchingContainer ¶ added in v0.8.0
GetMatchingContainer takes a list of containers and a name, and returns the first container in the list matching the name. If the list contains a single container it is always returned, even if the name does not match.
func GetMultusIfName ¶ added in v1.1.0
GetMultusIfName return a network interface name that multus will assign when connected to the multus network.
func GetNodeHostNames ¶ added in v0.8.3
func GetNodeHostNames(clientset kubernetes.Interface) (map[string]string, error)
GetNodeHostNames returns the name of the node resource mapped to their hostname label. Typically these will be the same name, but sometimes they are not such as when nodes have a longer dns name, but the hostname is short.
func GetNodeNameFromHostname ¶ added in v0.8.3
func GetNodeNameFromHostname(clientset kubernetes.Interface, hostName string) (string, error)
GetNodeNameFromHostname returns the name of the node resource looked up by the hostname label Typically these will be the same name, but sometimes they are not such as when nodes have a longer dns name, but the hostname is short.
func GetNodeSchedulable ¶ added in v1.0.0
GetNodeSchedulable returns a boolean if the node is tainted as Schedulable or not true -> Node is schedulable false -> Node is unschedulable
func GetPodLog ¶ added in v0.9.0
func GetPodLog(clientset kubernetes.Interface, namespace string, labelSelector string) (string, error)
GetJobLog gets the logs for the pod. If there is more than one pod with the label selector, the logs from the first pod will be returned.
func GetPodPhaseMap ¶ added in v0.8.0
GetPodPhaseMap takes a list of pods and returns a map of pod phases to the names of pods that are in that phase
func GetPrometheusRule ¶ added in v1.1.0
func GetPrometheusRule(ruleFilePath string) (*monitoringv1.PrometheusRule, error)
GetPrometheusRule returns provided prometheus rules or an error
func GetRunningPod ¶ added in v0.8.0
func GetRunningPod(clientset kubernetes.Interface) (*v1.Pod, error)
GetRunningPod reads the name and namespace of a pod from the environment, and returns the pod (if it exists).
func GetServiceMonitor ¶ added in v1.1.0
func GetServiceMonitor(filePath string) (*monitoringv1.ServiceMonitor, error)
GetServiceMonitor returns servicemonitor or an error
func GetSpecContainerImage ¶ added in v0.8.1
GetSpecContainerImage returns the container image for a podspec, given a container name. The name is ignored if the podspec has a single container, in which case the image for that container is returned.
func GetValidNodes ¶ added in v0.8.1
func GetValidNodes(rookStorage rookalpha.StorageScopeSpec, clientset kubernetes.Interface, placement rookalpha.Placement) []rookalpha.Node
GetValidNodes returns all nodes that (1) are not cordoned, (2) meet Rook's placement terms, and (3) are ready.
func IndexToName ¶ added in v0.9.0
IndexToName converts an index to a daemon name based on as few letters of the alphabet as possible. For example:
0 -> a 1 -> b 25 -> z 26 -> aa
func MakeRookImage ¶
MakeRookImage formats the container name
func MergeResourceRequirements ¶ added in v0.7.0
func MergeResourceRequirements(first, second v1.ResourceRequirements) v1.ResourceRequirements
func NameToIndex ¶ added in v0.9.0
NameToIndex converts a daemon name to an index, which is the inverse of IndexToName For example:
a -> 0 b -> 1
func NodeConfigURI ¶ added in v0.6.0
NodeConfigURI returns the node config URI path for this node
func NodeIsInRookNodeList ¶ added in v1.0.0
NodeIsInRookNodeList will return true if the target node is found in a given list of Rook nodes.
func NodeIsReady ¶ added in v1.0.0
NodeIsReady returns true if the node is ready. It returns false if the node is not ready.
func NodeIsTolerable ¶ added in v1.0.0
NodeIsTolerable returns true if the node's taints are all tolerated by the given tolerations. There is the option to ignore well known taints defined in WellKnownTaints. See WellKnownTaints for more information.
func NodeMeetsAffinityTerms ¶ added in v1.0.0
NodeMeetsAffinityTerms returns true if the node meets the terms of the node affinity. `PreferredDuringSchedulingIgnoredDuringExecution` terms are ignored and not used to judge a node's usability.
func NodeMeetsPlacementTerms ¶ added in v1.0.0
func NodeMeetsPlacementTerms(node v1.Node, placement rookalpha.Placement, ignoreWellKnownTaints bool) (bool, error)
NodeMeetsPlacementTerms returns true if the Rook placement allows the node to have resources scheduled on it. A node is placeable if it (1) meets any affinity terms that may be set in the placement, and (2) its taints are tolerated by the placements tolerations. There is the option to ignore well known taints defined in WellKnownTaints. See WellKnownTaints for more information.
func ParseServiceType ¶ added in v1.1.0
func ParseServiceType(serviceString string) v1.ServiceType
ParseServiceType parses a string and returns a*v1.ServiceType. If the ServiceType is invalid, this should be considered an error.
func PathToVolumeName ¶ added in v0.4.0
PathToVolumeName converts a path to a valid volume name
func PodIPEnvVar ¶
PodIPEnvVar returns an env var such that the pod's ip will be mapped to the given property (env var) name within the container.
func PodsRunningWithLabel ¶ added in v0.9.0
func PodsRunningWithLabel(clientset kubernetes.Interface, namespace, label string) (int, error)
PodsRunningWithLabel returns the number of running pods with the given label
func RookNodesMatchingKubernetesNodes ¶ added in v1.0.0
func RookNodesMatchingKubernetesNodes(rookStorage rookalpha.StorageScopeSpec, kubernetesNodes []v1.Node) []rookalpha.Node
RookNodesMatchingKubernetesNodes returns only the given Rook nodes which have a corresponding match in the list of Kubernetes nodes.
func RunReplaceableJob ¶ added in v0.9.0
RunReplaceableJob runs a Kubernetes job with the intention that the job can be replaced by another call to this function with the same job name. For example, if a storage operator is restarted/updated before the job can complete, the operator's next run of the job should replace the previous job if deleteIfFound is set to true.
func SetOwnerRef ¶ added in v0.8.0
func SetOwnerRef(object *metav1.ObjectMeta, ownerRef *metav1.OwnerReference)
func SetOwnerRefs ¶ added in v0.8.0
func SetOwnerRefs(object *metav1.ObjectMeta, ownerRefs []metav1.OwnerReference)
func TaintIsWellKnown ¶ added in v1.0.0
TaintIsWellKnown returns true if the taint's key is in the WellKnownTaints list. False otherwise. See WellKnownTaints for more information.
func TruncateNodeName ¶ added in v0.8.1
TruncateNodeName hashes the nodeName in case it would case the name to be longer than 63 characters WARNING If your format and nodeName as a hash, are longer than 63 chars it won't be truncated! Your format alone should only be 31 chars at max because of MD5 hash being 32 chars. For more information, see the following resources: https://stackoverflow.com/a/50451893 https://stackoverflow.com/a/32294443
func UpdateDeploymentAndWait ¶ added in v0.8.1
func UpdateDeploymentAndWait(context *clusterd.Context, deployment *apps.Deployment, namespace string, verifyCallback func(action string) error) (*v1.Deployment, error)
UpdateDeploymentAndWait updates a deployment and waits until it is running to return. It will error if the deployment does not exist to be updated or if it takes too long. This method has a generic callback function that each backend can rely on It serves two purposes:
- verify that a resource can be stopped
- verify that we can continue the update procedure
Basically, we go one resource by one and check if we can stop and then if the resource has been successfully updated we check if we can go ahead and move to the next one.
func UpdateService ¶ added in v1.0.0
func UpdateService( clientset kubernetes.Interface, namespace string, serviceDefinition *v1.Service, ) (*v1.Service, error)
UpdateService updates a service declaratively. If the service does not exist this is considered an error condition.
func ValidNode ¶ added in v0.8.1
ValidNode returns true if the node (1) is schedulable, (2) meets Rook's placement terms, and (3) is ready. False otherwise.
func ValidNodeNoSched ¶ added in v1.1.0
ValidNodeNoSched returns true if the node (1) meets Rook's placement terms, and (2) is ready. Unlike ValidNode, this method will ignore the Node.Spec.Unschedulable flag. False otherwise.
func WaitForDeploymentImage ¶ added in v0.9.0
func WaitForDeploymentImage(clientset kubernetes.Interface, namespace, label, container string, initContainer bool, desiredImage string) error
WaitForDeploymentImage waits for all deployments with the given labels are running. WARNING:This is currently only useful for testing!
func WaitForJobCompletion ¶ added in v0.9.0
func WaitForJobCompletion(clientset kubernetes.Interface, job *batch.Job, timeout time.Duration) error
WaitForJobCompletion waits for a job to reach the completed state. Assumes that only one pod needs to complete.
func YamlToTolerations ¶ added in v1.1.0
func YamlToTolerations(raw string) ([]v1.Toleration, error)
This function takes raw YAML string and converts it to Kubernetes Tolerations array
Types ¶
type ConfigMapKVStore ¶ added in v0.6.0
type ConfigMapKVStore struct {
// contains filtered or unexported fields
}
func NewConfigMapKVStore ¶ added in v0.6.0
func NewConfigMapKVStore(namespace string, clientset kubernetes.Interface, ownerRef metav1.OwnerReference) *ConfigMapKVStore
func (*ConfigMapKVStore) ClearStore ¶ added in v0.6.0
func (kv *ConfigMapKVStore) ClearStore(storeName string) error
func (*ConfigMapKVStore) GetStore ¶ added in v0.6.0
func (kv *ConfigMapKVStore) GetStore(storeName string) (map[string]string, error)
func (*ConfigMapKVStore) GetValue ¶ added in v0.6.0
func (kv *ConfigMapKVStore) GetValue(storeName, key string) (string, error)
func (*ConfigMapKVStore) SetValue ¶ added in v0.6.0
func (kv *ConfigMapKVStore) SetValue(storeName, key, value string) error
func (*ConfigMapKVStore) SetValueWithLabels ¶ added in v0.8.0
func (kv *ConfigMapKVStore) SetValueWithLabels(storeName, key, value string, labels map[string]string) error
type DeleteOptions ¶ added in v1.1.0
type DeleteOptions struct { // MustDelete controls the idempotency of the delete operation. If MustDelete is true and the // resource being deleted does not exist, the delete operation is considered a failure. If // MustDelete is false and the resource being deleted does not exist, the delete operation is // considered a success. MustDelete bool // DeleteOptions is a superset of WaitOptions. WaitOptions }
DeleteOptions are a common set of options controlling the behavior of k8sutil delete operations. DeleteOptions is a superset of WaitOptions.
type WaitOptions ¶ added in v1.1.0
type WaitOptions struct { // Wait defines whether the operation should wait in a loop and verify that the operation was // successful before returning. Wait bool // RetryCount defines how many times the operation should retry verification in the wait loop // before giving up. If RetryCount is zero, the operation should default to a sane value based // on the operation. RetryCount uint // RetryInterval defines the time the operation will wait before retrying verification. If // RetryInterval is zero, the operation should default to a sane value based on the operation. RetryInterval time.Duration // ErrorOnTimeout defines whether the operation should time out with an error. If ErrorOnTimeout // is true and the operation times out, the operation is considered a failure. If ErrorOnTimeout // is false and the operation times out, the operation should log a warning but not not report // failure. ErrorOnTimeout bool }
WaitOptions are a common set of options controlling the behavior of k8sutil operations. If WaitOptions are specified, the operation should wait in a loop and verify that the operation being performed was successful.