kubernetes

package
v0.0.0-...-35696f1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultProvider               = types.ProviderTypeKind
	DefaultInstaller              = types.InstallerTypeHelm
	DefaultClusterCreationTimeout = 30 * time.Minute
	DefaultKubernetesVersion      = "1.28"
	DefaultNamespace              = "default"
)
View Source
const (
	GatewayHostPort      = 30080
	ListOperationTimeout = 30
)
View Source
const (
	AppComponentLabel = "app.kubernetes.io/component"
	AppNameLabel      = "app.kubernetes.io/name"
)

https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/

Variables

This section is empty.

Functions

func NewClientFromKubeConfig

func NewClientFromKubeConfig(kubeConfig []byte) (kubernetes.Interface, error)

func ServiceStateFromReplicas

func ServiceStateFromReplicas(ready, total int32) envtypes.ServiceState

Types

type Config

type Config struct {
	// EnvName the name of the environment to be created
	EnvName string `mapstructure:"env_name"`
	// Namespace where to deploy
	Namespace string `mapstructure:"namespace"`
	// Provider defines the infrastructure/platform provider
	Provider types.ProviderType `mapstructure:"provider"`
	// Installer defines the installer to be used for deployment
	Installer types.InstallerType `mapstructure:"installer"`
	// HelmConfig defines the Helm specific configuration
	HelmConfig *helm.Config `mapstructure:"helm,omitempty"`
	// Images contains the list of container images to be used for deployment
	Images ContainerImages `mapstructure:",squash"`
	// WorkDir absolute path to the directory where the deployment files prior performing actions
	WorkDir string `mapstructure:"work_dir"`
	// SkipAssetInstall defines whether to deploy test assets to environment or not
	SkipAssetInstall bool `mapstructure:"skip_asset_install"`

	// ProviderConfig contains the configuration for the Kubernetes provider.
	// NOTE(chrisgacsal): mapstructure does not support *squash* for ptr types
	types.ProviderConfig `mapstructure:",squash"`
	// contains filtered or unexported fields
}

type ConfigOptFn

type ConfigOptFn func(*Config) error

ConfigOptFn defines transformer function for Config.

func WithLogger

func WithLogger(logger *logrus.Entry) ConfigOptFn

func WithWorkDir

func WithWorkDir(dir string) ConfigOptFn

WithWorkDir set workDir for Config.

type ContextKeyType

type ContextKeyType string
const KubeClientContextKey ContextKeyType = "KubeClient"

type KubernetesEnv

type KubernetesEnv struct {
	// Provider used for deploying Kubernetes cluster
	types.Provider
	// Installer used for deploying applications to Kubernetes cluster
	types.Installer
	// Config stores all the configuration for Kubernetes environment
	*Config
	// contains filtered or unexported fields
}

func New

func New(config *Config, opts ...ConfigOptFn) (*KubernetesEnv, error)

func (*KubernetesEnv) Context

func (e *KubernetesEnv) Context(ctx context.Context) (context.Context, error)

func (*KubernetesEnv) Endpoints

func (e *KubernetesEnv) Endpoints(_ context.Context) (*envtypes.Endpoints, error)

func (*KubernetesEnv) ServiceLogs

func (e *KubernetesEnv) ServiceLogs(ctx context.Context, services []string, startTime time.Time, stdout, _ io.Writer) error

func (*KubernetesEnv) Services

func (e *KubernetesEnv) Services(ctx context.Context) (envtypes.Services, error)

func (*KubernetesEnv) ServicesReady

func (e *KubernetesEnv) ServicesReady(ctx context.Context) (bool, error)

func (*KubernetesEnv) SetUp

func (e *KubernetesEnv) SetUp(ctx context.Context) error

type Service

type Service struct {
	ID          string
	Namespace   string
	Application string
	Component   string
	State       envtypes.ServiceState
}

func ServiceFromDaemonSet

func ServiceFromDaemonSet(d *appsv1.DaemonSet) *Service

func ServiceFromDeployment

func ServiceFromDeployment(d *appsv1.Deployment) *Service

func ServiceFromMeta

func ServiceFromMeta(m *metav1.ObjectMeta) *Service

func ServiceFromStatefulSet

func ServiceFromStatefulSet(d *appsv1.StatefulSet) *Service

func (*Service) GetApplicationName

func (s *Service) GetApplicationName() string

func (*Service) GetComponentName

func (s *Service) GetComponentName() string

func (*Service) GetID

func (s *Service) GetID() string

func (*Service) GetNamespace

func (s *Service) GetNamespace() string

func (*Service) GetState

func (s *Service) GetState() envtypes.ServiceState

func (Service) String

func (s Service) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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