k8s

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AgentName is the name of the Buoyant Cloud Agent deployment.
	AgentName = "buoyant-cloud-agent"
	// MetricsName is the name of the Buoyant Cloud Metrics deployment.
	MetricsName = "buoyant-cloud-metrics"
	// VersionLabel is the label key for the agent's version
	VersionLabel = "app.kubernetes.io/version"
)
View Source
const (
	// PartOfKey is the label key found on all Buoyant Cloud resources.
	PartOfKey = "app.kubernetes.io/part-of"
	// PartOfVal is the label value found on all Buoyant Cloud resources.
	PartOfVal = "buoyant-cloud"
)

Variables

This section is empty.

Functions

func Version

func Version(deploy *appsv1.Deployment) string

Version returns the label value of app.kubernetes.io/version.

Types

type Agent

type Agent struct {
	Name    string
	Id      string
	Version string
}

Agent represents the Buoyant Cloud agent. Any of these fields may not be present, depending on which resources are already on the cluster.

type Client

type Client interface {
	// Namespace retrieves the buoyant-cloud Namespace.
	Namespace(ctx context.Context) (*v1.Namespace, error)
	// ClusterRole retrieves the buoyant-cloud-agent CR.
	ClusterRole(ctx context.Context) (*rbacv1.ClusterRole, error)
	// ClusterRoleBinding retrieves the buoyant-cloud-agent CRB.
	ClusterRoleBinding(ctx context.Context) (*rbacv1.ClusterRoleBinding, error)
	// ConfigMap retrieves the agent-metadata ConfigMap.
	ConfigMap(ctx context.Context) (*v1.ConfigMap, error)
	// Secret retrieves the buoyant-cloud-org-credentials Secret.
	Secret(ctx context.Context) (*v1.Secret, error)
	// ServiceAccount retrieves the buoyant-cloud-agent ServiceAccount.
	ServiceAccount(ctx context.Context) (*v1.ServiceAccount, error)
	// DaemonSet retrieves a DaemonSet by name in the buoyant-cloud namespace.
	DaemonSet(ctx context.Context, name string) (*appsv1.DaemonSet, error)
	// Deployment retrieves a Deployment by name in the buoyant-cloud namespace.
	Deployment(ctx context.Context, name string) (*appsv1.Deployment, error)
	// Pods retrieves a PodList by labelSelector from the buoyant-cloud
	// namespace.
	Pods(ctx context.Context, labelSelector string) (*v1.PodList, error)

	// Agent retrieves the Buoyant Cloud agent from Kubernetes, and returns the
	// agent's name, version, and url. If Agent is not found, it will return a
	// nil Agent with no error.
	Agent(ctx context.Context) (*Agent, error)
	// Resources returns all linkerd-buoyant resources required for deletion.
	// Specifically, these three resource types matching the label
	// app.kubernetes.io/part-of=buoyant-cloud:
	// - ClusterRole
	// - ClusterRoleBinding
	// - Namespace
	Resources(ctx context.Context) ([]string, error)
}

Client defines the interface for linkerd-buoyant's Kubernetes client

func New

func New(kubeconfig, kubecontext string) (Client, error)

New takes a kubeconfig and kubecontext and returns an initialized Client.

type MockClient

type MockClient struct {
	MockNamespace          *v1.Namespace
	MockClusterRole        *rbacv1.ClusterRole
	MockClusterRoleBinding *rbacv1.ClusterRoleBinding
	MockConfigMap          *v1.ConfigMap
	MockSecret             *v1.Secret
	MockServiceAccount     *v1.ServiceAccount
	MockDaemonSet          *appsv1.DaemonSet
	MockDeployment         *appsv1.Deployment
	MockPods               *v1.PodList

	MockAgent     *Agent
	MockResources []string
}

MockClient provides a mock Kubernetes client for testing

func (*MockClient) Agent

func (m *MockClient) Agent(ctx context.Context) (*Agent, error)

Agent returns a mock Buoyant Cloud agent.

func (*MockClient) ClusterRole

func (m *MockClient) ClusterRole(ctx context.Context) (*rbacv1.ClusterRole, error)

ClusterRole returns a mock ClusterRole object.

func (*MockClient) ClusterRoleBinding

func (m *MockClient) ClusterRoleBinding(ctx context.Context) (*rbacv1.ClusterRoleBinding, error)

ClusterRoleBinding returns a mock ClusterRoleBinding object.

func (*MockClient) ConfigMap added in v0.8.0

func (m *MockClient) ConfigMap(ctx context.Context) (*v1.ConfigMap, error)

ConfigMap returns a mock ConfigMap object.

func (*MockClient) DaemonSet added in v0.4.4

func (m *MockClient) DaemonSet(ctx context.Context, name string) (*appsv1.DaemonSet, error)

DaemonSet returns a mock DaemonSet object.

func (*MockClient) Deployment

func (m *MockClient) Deployment(ctx context.Context, name string) (*appsv1.Deployment, error)

Deployment returns a mock Deployment object.

func (*MockClient) Namespace

func (m *MockClient) Namespace(ctx context.Context) (*v1.Namespace, error)

Namespace returns a mock Namespace object.

func (*MockClient) Pods

func (m *MockClient) Pods(ctx context.Context, labelSelector string) (*v1.PodList, error)

Pods returns a mock Pod List.

func (*MockClient) Resources

func (m *MockClient) Resources(ctx context.Context) ([]string, error)

Resources returns mock Buoyant Cloud agent resources.

func (*MockClient) Secret

func (m *MockClient) Secret(ctx context.Context) (*v1.Secret, error)

Secret returns a mock Secret object.

func (*MockClient) ServiceAccount

func (m *MockClient) ServiceAccount(ctx context.Context) (*v1.ServiceAccount, error)

ServiceAccount returns a mock ServiceAccount object.

Jump to

Keyboard shortcuts

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