Documentation ¶
Overview ¶
Copyright 2018 The Rook Authors. All rights reserved.
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.
Package k8sutil for Kubernetes helpers.
Package k8sutil for Kubernetes helpers.
Package k8sutil for Kubernetes helpers.
Copyright 2018 The Rook Authors. All rights reserved.
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.
Package k8sutil for Kubernetes helpers.
Package k8sutil for Kubernetes helpers.
Package k8sutil for Kubernetes helpers.
Package k8sutil for Kubernetes helpers.
Index ¶
- Constants
- func ClusterDaemonEnvVars() []v1.EnvVar
- func ConfigDirEnvVar(dataDir string) v1.EnvVar
- func ConfigOverrideEnvVar() v1.EnvVar
- func ConfigOverrideMount() v1.VolumeMount
- func ConfigOverrideVolume() v1.Volume
- func DeleteBatchJob(clientset kubernetes.Interface, namespace, name string, wait bool) 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 GetContainerImage(pod *v1.Pod, name string) (string, error)
- func GetDeploymentImage(clientset kubernetes.Interface, namespace, name, container string) (string, error)
- func GetDeploymentSpecImage(clientset kubernetes.Interface, d extensions.Deployment, container string) (string, error)
- func GetDeployments(clientset kubernetes.Interface, namespace, labelSelector string) (*extensions.DeploymentList, error)
- func GetK8SVersion(clientset kubernetes.Interface) (*version.Version, error)
- func GetMatchingContainer(containers []v1.Container, name string) (v1.Container, error)
- func GetNodeHostNames(clientset kubernetes.Interface) (map[string]string, error)
- func GetNodeNameFromHostname(clientset kubernetes.Interface, hostName string) (string, error)
- func GetPodLog(clientset kubernetes.Interface, namespace string, labelSelector string) (string, error)
- func GetPodPhaseMap(pods *v1.PodList) map[v1.PodPhase][]string
- func GetRunningPod(clientset kubernetes.Interface) (*v1.Pod, error)
- func GetSpecContainerImage(spec v1.PodSpec, name string) (string, error)
- func GetValidNodes(rookNodes []rookalpha.Node, 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 PathToVolumeName(path string) string
- func PodIPEnvVar(property string) v1.EnvVar
- func PodsRunningWithLabel(clientset kubernetes.Interface, namespace, label string) (int, error)
- func RunReplaceableJob(clientset kubernetes.Interface, job *batch.Job) error
- func SetOwnerRef(clientset kubernetes.Interface, namespace string, object *metav1.ObjectMeta, ...)
- func SetOwnerRefs(clientset kubernetes.Interface, namespace string, object *metav1.ObjectMeta, ...)
- func TruncateNodeName(format, nodeName string) string
- func UpdateDeploymentAndWait(context *clusterd.Context, deployment *extensions.Deployment, namespace string) error
- func ValidNode(node v1.Node, placement rookalpha.Placement) (bool, error)
- func WaitForDeploymentImage(clientset kubernetes.Interface, ...) error
- func WaitForJobCompletion(clientset kubernetes.Interface, job *batch.Job, timeout time.Duration) 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
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" )
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" )
Variables ¶
This section is empty.
Functions ¶
func ClusterDaemonEnvVars ¶
Environment variables used by storage cluster daemons
func ConfigDirEnvVar ¶
ConfigDirEnvVar config dir env var
func ConfigOverrideEnvVar ¶
ConfigOverrideEnvVar config override env var
func ConfigOverrideMount ¶
func ConfigOverrideMount() v1.VolumeMount
ConfigOverrideMount is an override mount
func ConfigOverrideVolume ¶
ConfigOverrideVolume is an override volume
func DeleteBatchJob ¶
func DeleteBatchJob(clientset kubernetes.Interface, namespace, name string, wait bool) error
func DeleteDaemonset ¶
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 ¶
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 ¶
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 GetDeploymentImage ¶
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 ¶
func GetDeploymentSpecImage(clientset kubernetes.Interface, d extensions.Deployment, container string) (string, error)
func GetDeployments ¶
func GetDeployments(clientset kubernetes.Interface, namespace, labelSelector string) (*extensions.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 ¶
func GetK8SVersion(clientset kubernetes.Interface) (*version.Version, error)
GetK8SVersion gets the version of the running K8S cluster
func GetMatchingContainer ¶
func GetNodeHostNames ¶
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 ¶
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 GetPodLog ¶
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 ¶
GetPodPhaseMap takes a list of pods and returns a map of pod phases to the names of pods that are in that phase
func GetRunningPod ¶
func GetRunningPod(clientset kubernetes.Interface) (*v1.Pod, error)
func GetSpecContainerImage ¶
func GetValidNodes ¶
func IndexToName ¶
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 ¶
func MergeResourceRequirements(first, second v1.ResourceRequirements) v1.ResourceRequirements
func NameToIndex ¶
NameToIndex converts a daemon name to an index, which is the inverse of IndexToName For example:
a -> 0 b -> 1
func NodeConfigURI ¶
NodeConfigURI returns the node config URI path for this node
func PathToVolumeName ¶
PathToVolumeName converts a path to a valid volume name
func PodsRunningWithLabel ¶
func PodsRunningWithLabel(clientset kubernetes.Interface, namespace, label string) (int, error)
func RunReplaceableJob ¶
func RunReplaceableJob(clientset kubernetes.Interface, job *batch.Job) error
func SetOwnerRef ¶
func SetOwnerRef(clientset kubernetes.Interface, namespace string, object *metav1.ObjectMeta, ownerRef *metav1.OwnerReference)
func SetOwnerRefs ¶
func SetOwnerRefs(clientset kubernetes.Interface, namespace string, object *metav1.ObjectMeta, ownerRefs []metav1.OwnerReference)
func TruncateNodeName ¶
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 ¶
func UpdateDeploymentAndWait(context *clusterd.Context, deployment *extensions.Deployment, namespace string) error
func WaitForDeploymentImage ¶
func WaitForDeploymentImage(clientset kubernetes.Interface, namespace, label, container, desiredImage string) error
func WaitForJobCompletion ¶
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.
Types ¶
type ConfigMapKVStore ¶
type ConfigMapKVStore struct {
// contains filtered or unexported fields
}
func NewConfigMapKVStore ¶
func NewConfigMapKVStore(namespace string, clientset kubernetes.Interface, ownerRef metav1.OwnerReference) *ConfigMapKVStore
func (*ConfigMapKVStore) ClearStore ¶
func (kv *ConfigMapKVStore) ClearStore(storeName string) error
func (*ConfigMapKVStore) GetStore ¶
func (kv *ConfigMapKVStore) GetStore(storeName string) (map[string]string, error)
func (*ConfigMapKVStore) GetValue ¶
func (kv *ConfigMapKVStore) GetValue(storeName, key string) (string, error)
func (*ConfigMapKVStore) SetValue ¶
func (kv *ConfigMapKVStore) SetValue(storeName, key, value string) error
func (*ConfigMapKVStore) SetValueWithLabels ¶
func (kv *ConfigMapKVStore) SetValueWithLabels(storeName, key, value string, labels map[string]string) error