k8sutil

package
v0.0.0-...-ba674e6 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2018 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EtcdClientPort is the client port on client service and etcd nodes.
	EtcdClientPort = 2379

	// AnnotationScope annotation name for defining instance scope. Used for specifing cluster wide clusters.
	AnnotationScope = "sensu.io/scope"
	//AnnotationClusterWide annotation value for cluster wide clusters.
	AnnotationClusterWide = "clusterwide"
)
View Source
const TolerateUnreadyEndpointsAnnotation = "service.alpha.kubernetes.io/tolerate-unready-endpoints"

Variables

This section is empty.

Functions

func APIServiceName

func APIServiceName(clusterName string) string

func AddEtcdVolumeToPod

func AddEtcdVolumeToPod(pod *v1.Pod, pvc *v1.PersistentVolumeClaim)

AddEtcdVolumeToPod abstract the process of appending volume spec to pod spec

func AgentServiceName

func AgentServiceName(clusterName string) string

func CascadeDeleteOptions

func CascadeDeleteOptions(gracePeriodSeconds int64) *metav1.DeleteOptions

func ClusterListOpt

func ClusterListOpt(clusterName string) metav1.ListOptions

We are using internal api types for cluster related.

func CreateAPIService

func CreateAPIService(kubecli kubernetes.Interface, clusterName, ns string, owner metav1.OwnerReference) error

func CreateAgentService

func CreateAgentService(kubecli kubernetes.Interface, clusterName, ns string, owner metav1.OwnerReference) error

func CreateAndWaitDeployment

func CreateAndWaitDeployment(kubecli kubernetes.Interface, ns string, deployment *appsv1beta1.Deployment, timeout time.Duration) (*appsv1beta1.Deployment, error)

CreateAndWaitDeployment creates a deployment and waits until the defined number of replicas is reached

func CreateAndWaitPod

func CreateAndWaitPod(kubecli kubernetes.Interface, ns string, pod *v1.Pod, timeout time.Duration) (*v1.Pod, error)

CreateAndWaitPod creates a pod and waits until it is running

func CreateCRD

func CreateCRD(clientset apiextensionsclient.Interface, crdName, rkind, rplural, shortName string) error

func CreateDashboardService

func CreateDashboardService(kubecli kubernetes.Interface, clusterName, ns string, owner metav1.OwnerReference) error

func CreateEtcdPeerService

func CreateEtcdPeerService(kubecli kubernetes.Interface, clusterName, ns string, owner metav1.OwnerReference) error

func CreateNetPolicy

func CreateNetPolicy(kubecli kubernetes.Interface, clusterName, namespace string, owner metav1.OwnerReference) error

CreateNetPolicy creates a NetworkPolicy for a Sensu cluster

func CreatePatch

func CreatePatch(o, n, datastruct interface{}) ([]byte, error)

func CreatePeerService

func CreatePeerService(kubecli kubernetes.Interface, clusterName, ns string, owner metav1.OwnerReference) error

func DashboardServiceName

func DashboardServiceName(clusterName string) string

func GetClusterList

func GetClusterList(restcli rest.Interface, ns string) (*api.SensuClusterList, error)

func GetPodNames

func GetPodNames(pods []*v1.Pod) []string

func GetSensuVersion

func GetSensuVersion(pod *v1.Pod) string

func ImageName

func ImageName(repo, version string) string

func InClusterConfig

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

func IsKubernetesResourceAlreadyExistError

func IsKubernetesResourceAlreadyExistError(err error) bool

func IsKubernetesResourceNotFoundError

func IsKubernetesResourceNotFoundError(err error) bool

func IsPodReady

func IsPodReady(pod *v1.Pod) bool

IsPodReady returns false if the Pod Status is nil

func LabelsForCluster

func LabelsForCluster(clusterName string) map[string]string

func MemberRemoveEvent

func MemberRemoveEvent(memberName string, cl *api.SensuCluster) *v1.Event

func MemberUpgradedEvent

func MemberUpgradedEvent(memberName, oldVersion, newVersion string, cl *api.SensuCluster) *v1.Event

func MustNewKubeClient

func MustNewKubeClient() kubernetes.Interface

func MustNewKubeExtClient

func MustNewKubeExtClient() apiextensionsclient.Interface

func NewMemberAddEvent

func NewMemberAddEvent(memberName string, cl *api.SensuCluster) *v1.Event

func NewSeedMemberPod

func NewSeedMemberPod(clusterName string, ms etcdutil.MemberSet, m *etcdutil.Member, cs api.ClusterSpec, owner metav1.OwnerReference, backupURL *url.URL) *v1.Pod

NewSeedMemberPod returns a Pod manifest for a seed member. It's special that it has new token, and might need recovery init containers

func NewSensuPod

func NewSensuPod(m *etcdutil.Member, initialCluster []string, clusterName, state, token string, cs api.ClusterSpec, owner metav1.OwnerReference) *v1.Pod

func NewSensuPodPVC

func NewSensuPodPVC(m *etcdutil.Member, pvcSpec v1.PersistentVolumeClaimSpec, clusterName, namespace string, owner metav1.OwnerReference) *v1.PersistentVolumeClaim

NewEtcdPodPVC create PVC object from etcd pod's PVC spec

func PVCNameFromMember

func PVCNameFromMember(memberName string) string

PVCNameFromMember the way we get PVC name from the member name

func PatchDeployment

func PatchDeployment(kubecli kubernetes.Interface, namespace, name string, updateFunc func(*appsv1beta1.Deployment)) error

func PodSpecToPrettyJSON

func PodSpecToPrettyJSON(pod *v1.Pod) (string, error)

func PodWithNodeSelector

func PodWithNodeSelector(p *v1.Pod, ns map[string]string) *v1.Pod

func ReplacingDeadMemberEvent

func ReplacingDeadMemberEvent(memberName string, cl *api.SensuCluster) *v1.Event

func SetSensuVersion

func SetSensuVersion(pod *v1.Pod, version string)

func UniqueMemberName

func UniqueMemberName(clusterName string) string

func WaitCRDReady

func WaitCRDReady(clientset apiextensionsclient.Interface, crdName string) error

Types

type SensuClusterCRUpdateFunc

type SensuClusterCRUpdateFunc func(*api.SensuCluster)

SensuClusterCRUpdateFunc is a function to be used when atomically updating a Cluster CR.

type TLSData

type TLSData struct {
	CertData []byte
	KeyData  []byte
	CAData   []byte
}

func GetTLSDataFromSecret

func GetTLSDataFromSecret(kubecli kubernetes.Interface, ns, se string) (*TLSData, error)

GetTLSDataFromSecret retrives the kubernete secret that contain etcd tls certs and put them into TLSData.

Jump to

Keyboard shortcuts

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