kubernetes

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2021 License: Apache-2.0 Imports: 44 Imported by: 25

Documentation

Index

Constants

View Source
const (
	LabelAppKey            = "app"
	LabelAppValue          = "nats"
	LabelClusterNameKey    = "nats_cluster"
	LabelClusterVersionKey = "nats_version"
)
View Source
const (
	TolerateUnreadyEndpointsAnnotation = "service.alpha.kubernetes.io/tolerate-unready-endpoints"
)

Variables

This section is empty.

Functions

func ByCoordinates added in v0.4.2

func ByCoordinates(namespace, name string) fields.Selector

ByCoordinates returns a field selector that can be used to filter Kubernetes resources based on their name and namespace.

func ClientServiceName added in v0.4.2

func ClientServiceName(clusterName string) string

ClientServiceName returns the name of the client service based on the specified cluster name.

func ClusterListOpt

func ClusterListOpt(clusterName string) metav1.ListOptions

We are using internal api types for cluster related.

func ConfigSecret added in v0.4.2

func ConfigSecret(clusterName string) string

ConfigSecret returns the name of the secret that contains the configuration for the NATS cluster with the specified name.

func CreateAndWaitPod

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

CreateAndWaitPod is an util for testing. We should eventually get rid of this in critical code path and move it to test util.

func CreateClientService

func CreateClientService(
	kubecli corev1client.CoreV1Interface,
	clusterName, ns string,
	owner metav1.OwnerReference,
	websocketPort int,
	labels map[string]string,
	annotations map[string]string,
) error

func CreateConfigSecret added in v0.4.2

func CreateConfigSecret(kubecli corev1client.CoreV1Interface, operatorcli natsalphav2client.NatsV1alpha2Interface, clusterName, ns string, cluster v1alpha2.ClusterSpec, owner metav1.OwnerReference) error

CreateConfigSecret creates the secret that contains the configuration file for a given NATS cluster..

func CreateMgmtService

func CreateMgmtService(
	kubecli corev1client.CoreV1Interface,
	clusterName, clusterVersion, ns string,
	owner metav1.OwnerReference,
	websocketPort int,
	gatewayPort int,
	leafnodePort int,
	labels map[string]string,
	annotations map[string]string,
) error

CreateMgmtService creates an headless service for NATS management purposes.

func CreatePatch

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

func ExecInContainer added in v0.4.2

func ExecInContainer(ctx context.Context, kubeClient kubernetes.Interface, kubeCfg *rest.Config, podNamespace, podName, containerName string, args ...string) (int, error)

ExecInContainer runs a command in the specified container, blocking until the command finishes execution or the specified context times out. It returns the command's exit code (if available), its output (stdout and stderr) and the associated error (if any).

func GetClusterList

func GetClusterList(restcli rest.Interface, ns string) (*v1alpha2.NatsClusterList, error)

func GetNATSVersion

func GetNATSVersion(pod *v1.Pod) string

func GetPodNames

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

func InClusterConfig

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

func InitCRDs added in v0.4.2

func InitCRDs(extsClient extsclientset.Interface) error

InitCRDs registers the CRDs for the nats.io/v1alpha2 API and waits for them to become ready.

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

func LabelSelectorForCluster(clusterName string) labels.Selector

LabelSelectorForCluster returns a label selector that matches resources belonging to the NATS cluster with the specified name.

func LabelsForCluster

func LabelsForCluster(clusterName string) map[string]string

func MakeNATSImage

func MakeNATSImage(version string, serverImage string) string

func ManagementServiceName

func ManagementServiceName(clusterName string) string

func MustNewKubeClientFromConfig added in v0.4.2

func MustNewKubeClientFromConfig(cfg *rest.Config) kubernetes.Interface

MustNewKubeClientFromConfig builds a Kubernetes client based on the specified configuration object.

func MustNewKubeConfig added in v0.4.2

func MustNewKubeConfig(kubeconfig string) *rest.Config

MustNewKubeConfig builds a configuration object by either reading from the specified kubeconfig file or by using an in-cluster config.

func MustNewKubeExtClient

func MustNewKubeExtClient(cfg *rest.Config) extsclientset.Interface

MustNewKubeExtClient creates a new client for the apiextensions.k8s.io/v1 API.

func MustNewNatsClientFromConfig added in v0.4.2

func MustNewNatsClientFromConfig(cfg *rest.Config) natsclient.Interface

MustNewNatsClientFromConfig builds a client for our API based on the specified configuration object.

func NatsServiceRoleLabelSelectorForCluster added in v0.4.2

func NatsServiceRoleLabelSelectorForCluster(clusterName string) labels.Selector

NatsServiceRoleLabelSelectorForCuster returns a label selector that matches NatsServiceRole resources referencing the NATS cluster with the specified name.

func NewNatsPodSpec

func NewNatsPodSpec(namespace, name, clusterName string, cs v1alpha2.ClusterSpec, owner metav1.OwnerReference) *v1.Pod

NewNatsPodSpec returns a NATS peer pod specification, based on the cluster specification.

func PodSpecToPrettyJSON

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

func PodWithAntiAffinity

func PodWithAntiAffinity(pod *v1.Pod, clusterName string) *v1.Pod

PodWithAntiAffinity sets pod anti-affinity with the pods in the same NATS cluster

func PodWithNodeSelector

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

func ResourceKey added in v0.4.2

func ResourceKey(obj interface{}) string

ResourceKey returns the "namespace/name" key that represents the specified resource.

func SetNATSVersion

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

func UniquePodName

func UniquePodName() string

UniquePodName generates a unique name for the Pod.

func UpdateConfigSecret added in v0.4.2

func UpdateConfigSecret(
	kubecli corev1client.CoreV1Interface,
	operatorcli natsalphav2client.NatsV1alpha2Interface,
	clusterName, ns string,
	cluster v1alpha2.ClusterSpec,
	owner metav1.OwnerReference,
) error

UpdateConfigSecret applies the new configuration of the cluster, such as modifying the routes available in the cluster.

func WaitCRDs added in v0.4.2

func WaitCRDs(extsClient extsclientset.Interface) error

WaitCRDs waits for the CRDs to become ready.

func WaitUntilDeploymentCondition added in v0.4.2

func WaitUntilDeploymentCondition(ctx context.Context, kubeClient kubernetes.Interface, namespace, name string, fn watch.ConditionFunc) error

WaitUntilDeploymentCondition establishes a watch on the specified deployment and blocks until the specified condition function is satisfied.

func WaitUntilPodCondition added in v0.4.2

func WaitUntilPodCondition(ctx context.Context, kubeClient corev1.CoreV1Interface, pod *v1.Pod, fn watch.ConditionFunc) error

WaitUntilPodCondition establishes a watch on the specified pod and blocks until the specified condition function is satisfied.

func WaitUntilPodReady added in v0.4.2

func WaitUntilPodReady(ctx context.Context, kubeClient corev1.CoreV1Interface, pod *v1.Pod) error

WaitUntilPodReady establishes a watch on the specified pod and blocks until the pod is running, ready and has its ".status.podIP" field populated.

Types

type NatsClusterCRUpdateFunc

type NatsClusterCRUpdateFunc func(*v1alpha2.NatsCluster)

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

Jump to

Keyboard shortcuts

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