k8sutil

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2018 License: Apache-2.0 Imports: 20 Imported by: 0

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.

Package k8sutil for Kubernetes helpers.

Package k8sutil for Kubernetes helpers.

Package k8sutil for Kubernetes helpers.

Index

Constants

View Source
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"
)
View Source
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 ConfigDirEnvVar added in v0.4.0

func ConfigDirEnvVar(dataDir string) v1.EnvVar

ConfigDirEnvVar config dir env var

func ConfigOverrideEnvVar added in v0.5.0

func ConfigOverrideEnvVar() v1.EnvVar

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

func ConfigOverrideVolume() v1.Volume

ConfigOverrideVolume is an override volume

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 GetContainerImage added in v0.7.0

func GetContainerImage(pod *v1.Pod, name string) (string, error)

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 GetMatchingContainer added in v0.8.0

func GetMatchingContainer(containers []v1.Container, name string) (v1.Container, error)

func GetPodPhaseMap added in v0.8.0

func GetPodPhaseMap(pods *v1.PodList) map[v1.PodPhase][]string

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 added in v0.8.0

func GetRunningPod(clientset kubernetes.Interface) (*v1.Pod, error)

func GetSpecContainerImage added in v0.8.1

func GetSpecContainerImage(spec v1.PodSpec, name string) (string, error)

func GetValidNodes added in v0.8.1

func GetValidNodes(rookNodes []rookalpha.Node, clientset kubernetes.Interface, placement rookalpha.Placement) []rookalpha.Node

func Hash added in v0.8.1

func Hash(s string) string

Hash MD5 hash a given string

func MakeRookImage

func MakeRookImage(version string) string

MakeRookImage formats the container name

func MergeResourceRequirements added in v0.7.0

func MergeResourceRequirements(first, second v1.ResourceRequirements) v1.ResourceRequirements

func NameEnvVar added in v0.6.0

func NameEnvVar() v1.EnvVar

NameEnvVar pod name env var

func NamespaceEnvVar

func NamespaceEnvVar() v1.EnvVar

NamespaceEnvVar namespace env var

func NodeConfigURI added in v0.6.0

func NodeConfigURI() (string, error)

NodeConfigURI returns the node config URI path for this node

func NodeEnvVar added in v0.6.0

func NodeEnvVar() v1.EnvVar

NodeEnvVar node env var

func PathToVolumeName added in v0.4.0

func PathToVolumeName(path string) string

PathToVolumeName converts a path to a valid volume name

func PodIPEnvVar

func PodIPEnvVar(property string) v1.EnvVar

PodIPEnvVar private ip env var

func SetOwnerRef added in v0.8.0

func SetOwnerRef(clientset kubernetes.Interface, namespace string, object *metav1.ObjectMeta, ownerRef *metav1.OwnerReference)

func SetOwnerRefs added in v0.8.0

func SetOwnerRefs(clientset kubernetes.Interface, namespace string, object *metav1.ObjectMeta, ownerRefs []metav1.OwnerReference)

func TruncateNodeName added in v0.8.1

func TruncateNodeName(format, nodeName string) string

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 *v1beta1.Deployment, namespace string) error

func ValidNode added in v0.8.1

func ValidNode(node v1.Node, placement rookalpha.Placement) (bool, error)

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

Jump to

Keyboard shortcuts

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