cluster

package
v0.0.0-...-ceb5cd5 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const KnativeServiceLabelKey = "serving.knative.dev/service"

Default values for Knative related resources

View Source
const KnativeUserContainerName = "user-container"

Variables

View Source
var (
	ErrNamespaceAlreadyExists = errors.New("namespace already exists")
)

Functions

func InitClusterControllers

func InitClusterControllers(
	gcpProject string,
	environmentClusterMap map[string]string,
	vaultClient vault.VaultClient,
) (map[string]Controller, error)

InitClusterControllers takes in the the app config and a vault client and uses the credentials from vault to initialize one cluster controller per environment and returns a map where the key is the env name and the value is the corresponding controller.

Types

type BaseService

type BaseService struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
	Image     string `json:"image"`

	// Resources
	CPURequests    resource.Quantity `json:"cpu_requests"`
	MemoryRequests resource.Quantity `json:"memory_requests"`

	// Health Checks
	ProbePort             int32  `json:"probe_port"`
	LivenessHTTPGetPath   string `json:"liveness_path"`
	ReadinessHTTPGetPath  string `json:"readiness_path"`
	ProbeInitDelaySeconds int32  `json:"probe_delay_seconds"`

	// Env vars
	Envs []corev1.EnvVar `json:"envs"`

	// Labels
	Labels map[string]string `json:"labels"`

	ConfigMap *ConfigMap

	PersistentVolumeClaim *PersistentVolumeClaim `json:"persistent_volume_claim"`

	// Volumes
	Volumes      []corev1.Volume      `json:"volumes"`
	VolumeMounts []corev1.VolumeMount `json:"volume_mounts"`
}

BaseService defines the common properties of services that can be speficied for its deployment by the cluster controller

type ConfigMap

type ConfigMap struct {
	Name     string `json:"name"`
	FileName string `json:"file_name"`
	Data     string `json:"data"`
}

ConfigMap contains information to create a config map

type Controller

type Controller interface {
	DeployKnativeService(ctx context.Context, svc *KnativeService) error
	DeleteKnativeService(svcName string, namespace string, timeout time.Duration) error
	GetKnativeServiceURL(svcName string, namespace string) string
	ApplyIstioVirtualService(ctx context.Context, routerEndpoint *VirtualService) error
	DeleteIstioVirtualService(svcName string, namespace string, timeout time.Duration) error
	DeployKubernetesService(ctx context.Context, svc *KubernetesService) error
	DeleteKubernetesService(svcName string, namespace string, timeout time.Duration) error
	CreateNamespace(name string) error
	ApplyConfigMap(namespace string, configMap *ConfigMap) error
	DeleteConfigMap(name, namespace string) error
	CreateSecret(ctx context.Context, secret *Secret) error
	DeleteSecret(secretName string, namespace string) error
	ApplyPersistentVolumeClaim(ctx context.Context, namespace string, pvc *PersistentVolumeClaim) error
	DeletePersistentVolumeClaim(pvcName string, namespace string) error
	ListPods(namespace string, labelSelector string) (*apicorev1.PodList, error)
	ListPodLogs(namespace string, podName string, opts *apicorev1.PodLogOptions) (io.ReadCloser, error)
}

Controller defines the operations supported by the cluster controller

type KnativeService

type KnativeService struct {
	*BaseService

	IsClusterLocal bool  `json:"is_cluster_local"`
	ContainerPort  int32 `json:"containerPort"`

	// Autoscaling properties
	MinReplicas int `json:"minReplicas"`
	MaxReplicas int `json:"maxReplicas"`
}

KnativeService defines the properties for Knative services

func (*KnativeService) BuildKnativeServiceConfig

func (cfg *KnativeService) BuildKnativeServiceConfig() *knservingv1alpha1.Service

Creates a new config object compatible with the knative serving API, from the given config

type KubernetesService

type KubernetesService struct {
	*BaseService

	Command         []string                   `json:"command"`
	Args            []string                   `json:"args"`
	Replicas        int                        `json:"replicas"`
	Ports           []Port                     `json:"ports"`
	SecurityContext *corev1.PodSecurityContext `json:"security_context"`
}

KubernetesService defines the properties for Kubernetes services

func (*KubernetesService) BuildKubernetesServiceConfig

func (cfg *KubernetesService) BuildKubernetesServiceConfig() (*appsv1.Deployment, *corev1.Service)

type NameValuePair

type NameValuePair struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

NameValuePair captures a pair of name and value TODO: DATA-2094: This may no longer be necessary

type PersistentVolumeClaim

type PersistentVolumeClaim struct {
	Name        string            `json:"name"`
	Namespace   string            `json:"namespace"`
	AccessModes []string          `json:"access_modes"`
	Size        resource.Quantity `json:"size"`
}

PersistentVolumeClaim contains the information to build a persistent volume claim

func (*PersistentVolumeClaim) BuildPersistentVolumeClaim

func (pvc *PersistentVolumeClaim) BuildPersistentVolumeClaim() *corev1.PersistentVolumeClaim

type Port

type Port struct {
	Name     string `json:"name"`
	Port     int    `json:"port"`
	Protocol string `json:"protocol"`
}

type Secret

type Secret struct {
	Name      string
	Namespace string
	Data      map[string]string
}

Secret defines a kubernetes secret.

func (*Secret) BuildSecret

func (cfg *Secret) BuildSecret() *corev1.Secret

BuildSecret builds a kubernetes secret from the given config.

type VirtualService

type VirtualService struct {
	Name            string            `json:"name"`
	Namespace       string            `json:"namespace"`
	Labels          map[string]string `json:"labels"`
	Gateway         string            `json:"gateway"`
	Endpoint        string            `json:"endpoint"`
	DestinationHost string            `json:"destination_host"`
	HostRewrite     string            `json:"host_rewrite"`
	MatchURIPrefix  string            `json:"match_uri_prefix"`
}

func (VirtualService) BuildVirtualService

func (cfg VirtualService) BuildVirtualService() *v1alpha3.VirtualService

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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