k8s

package
v0.1.2-0...-3e0559f Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldCPU    = "CPU"
	FieldMemory = "Memory"

	GroupLimits   = "Limits"
	GroupRequests = "Requests"
)
View Source
const (
	ServiceMonitorKind    = "ServiceMonitor"
	ServiceMonitorVersion = "monitoring.coreos.com/v1"
)
View Source
const CraneUpdatedAnnotation = "crane.dyrector.io/restartedAt"
View Source
const LogBufferSize = 2048
View Source
const SecretFileName = "private.key"

Variables

This section is empty.

Functions

func Delete

func Delete(c context.Context, containerPreName, containerName string) error

soft-delete: deployment,services,configmaps, ingresses

func DeleteMultiple

func DeleteMultiple(c context.Context, request *common.DeleteContainersRequest) error

hard-delete if called with prefix name only without container name

func Deploy

func Deploy(c context.Context, dog *dogger.DeploymentLogger, deployImageRequest *v1.DeployImageRequest,
	versionData *v1.VersionData,
) error

func WaitForRunningDeployment

func WaitForRunningDeployment(ctx context.Context, namespace, name string, expectedReplicaCount int32,
	timeout time.Duration, cfg *config.Configuration,
) error

utility method ensuring deployment is running

Types

type Client

type Client struct {
	InClusterConfig      func() (*rest.Config, error)
	BuildConfigFromFlags func(masterUrl, kubeconfigPath string) (*rest.Config, error)
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cfg *config.Configuration) *Client

func (*Client) GetClientSet

func (c *Client) GetClientSet() (*kubernetes.Clientset, error)

func (*Client) GetRestConfig

func (c *Client) GetRestConfig() (*rest.Config, error)

func (*Client) VerifyAPIResourceExists

func (c *Client) VerifyAPIResourceExists(targetGroup, targetKind string) bool

type DeleteFacade

type DeleteFacade struct {
	// contains filtered or unexported fields
}

func NewDeleteFacade

func NewDeleteFacade(ctx context.Context, namespace, name string, cfg *config.Configuration) *DeleteFacade

func (*DeleteFacade) DeleteConfigMaps

func (d *DeleteFacade) DeleteConfigMaps() error

func (*DeleteFacade) DeleteDeployment

func (d *DeleteFacade) DeleteDeployment() error

func (*DeleteFacade) DeleteIngresses

func (d *DeleteFacade) DeleteIngresses() error

func (*DeleteFacade) DeleteNamespace

func (d *DeleteFacade) DeleteNamespace(namespace string) error

func (*DeleteFacade) DeleteServices

func (d *DeleteFacade) DeleteServices() error

type DeployFacade

type DeployFacade struct {
	ServiceMonitor *ServiceMonitor
	// contains filtered or unexported fields
}

func NewDeployFacade

func NewDeployFacade(params *DeployFacadeParams, cfg *config.Configuration) *DeployFacade

func (*DeployFacade) CheckPreConditions

func (d *DeployFacade) CheckPreConditions() error

func (*DeployFacade) Clear

func (d *DeployFacade) Clear() error

func (*DeployFacade) Deploy

func (d *DeployFacade) Deploy() error

func (*DeployFacade) PostDeploy

func (d *DeployFacade) PostDeploy() error

func (*DeployFacade) PreDeploy

func (d *DeployFacade) PreDeploy() error

TODO docs

type DeployFacadeParams

type DeployFacadeParams struct {
	Ctx             context.Context
	Image           string
	InstanceConfig  v1.InstanceConfig
	ContainerConfig v1.ContainerConfig
	RuntimeConfig   *string

	Issuer string
	// contains filtered or unexported fields
}

type DeployIngressOptions

type DeployIngressOptions struct {
	// contains filtered or unexported fields
}

type Deployment

type Deployment struct {
	// contains filtered or unexported fields
}

facade object for Deployment management

func NewDeployment

func NewDeployment(ctx context.Context, cfg *config.Configuration) *Deployment

func (*Deployment) DeployDeployment

func (d *Deployment) DeployDeployment(p *deploymentParams) error

func (*Deployment) GetDeployments

func (d *Deployment) GetDeployments(ctx context.Context, namespace string, cfg *config.Configuration) (*kappsv1.DeploymentList, error)

func (*Deployment) Restart

func (d *Deployment) Restart(namespace, name string) error

func (*Deployment) Scale

func (d *Deployment) Scale(namespace, name string, target int) error

type DockerConfig

type DockerConfig map[string]DockerConfigEntry

DockerConfig represents the config file used by the docker CLI.

type DockerConfigEntry

type DockerConfigEntry struct {
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
	Email    string `json:"email,omitempty"`
	Auth     string `json:"auth,omitempty"`
}

DockerConfigEntry holds the user information that grant the access to docker registry

type DockerConfigJSON

type DockerConfigJSON struct {
	Auths DockerConfig `json:"auths"`
}

types from kubectl DockerConfigJSON represents a local docker auth config file for pulling images.

type KubeContainerLogReader

type KubeContainerLogReader struct {
	EventChannel chan grpc.ContainerLogEvent
	LogStreams   []io.ReadCloser
	ErrorGroup   *errgroup.Group

	grpc.ContainerLogReader
}

func (*KubeContainerLogReader) Close

func (kubeReader *KubeContainerLogReader) Close() error

func (*KubeContainerLogReader) Next

func (kubeReader *KubeContainerLogReader) Next() <-chan grpc.ContainerLogEvent

type Namespace

type Namespace struct {
	// contains filtered or unexported fields
}

Namespace wrapper for the facade

func NewNamespaceClient

func NewNamespaceClient(ctx context.Context, name string, client *Client) *Namespace

func (*Namespace) DeleteNamespace

func (n *Namespace) DeleteNamespace(name string) error

func (*Namespace) DeployNamespace

func (n *Namespace) DeployNamespace(name string) error

func (*Namespace) EnsureExists

func (n *Namespace) EnsureExists(namespace string) error

func (*Namespace) GetNamespaces

func (n *Namespace) GetNamespaces() ([]NamespaceResponse, error)

type NamespaceResponse

type NamespaceResponse struct {
	Name string `json:"name" binding:"required"`
}

namespace entity

type PVC

type PVC struct {
	// contains filtered or unexported fields
}

facade object for PVC management

func NewPVC

func NewPVC(ctx context.Context, client *Client) *PVC

func (*PVC) ApplyVolume

func (p *PVC) ApplyVolume(client typedv1.PersistentVolumeClaimInterface,
	namespace, name string, volume *v1.Volume, volumeType coreV1.PersistentVolumeAccessMode,
) error

func (*PVC) DeployPVC

func (p *PVC) DeployPVC(namespace, name string, mountList []string, volumes []v1.Volume) error

type ResourceError

type ResourceError struct {
	Field    string
	Group    string
	Fallback bool
}

func NewResourceError

func NewResourceError(errorField, errorGroup string, fallback bool) ResourceError

func (ResourceError) Error

func (resourceError ResourceError) Error() string

type Secret

type Secret struct {
	// contains filtered or unexported fields
}

namespace wrapper for the facade

func NewSecret

func NewSecret(ctx context.Context, client *Client) *Secret

func (*Secret) ApplyOpaqueSecret

func (s *Secret) ApplyOpaqueSecret(ctx context.Context, namespace, name string, values map[string][]byte) (
	version string, err error,
)

func (*Secret) ApplyRegistryAuthSecret

func (s *Secret) ApplyRegistryAuthSecret(ctx context.Context,
	namespace,
	name string,
	credentials *imageHelper.RegistryAuth,
	appConfig *config.Configuration,
) error

func (*Secret) GetSecret

func (s *Secret) GetSecret(namespace, name string) (
	secretFiles map[string][]byte, version string, err error,
)

func (*Secret) GetValidSecret

func (s *Secret) GetValidSecret() (string, error)

func (*Secret) ListSecrets

func (s *Secret) ListSecrets(namespace, name string) ([]string, error)

type Service

type Service struct {
	// contains filtered or unexported fields
}

facade object for Service management

func NewService

func NewService(ctx context.Context, client *Client) *Service

func (*Service) DeployService

func (s *Service) DeployService(params *ServiceParams) error

func (*Service) GetServices

func (s *Service) GetServices(namespace string) (*corev1.ServiceList, error)

type ServiceMonitor

type ServiceMonitor struct {
	Ctx    context.Context
	Client *Client

	ClientSet *versionedv1.Clientset
	// contains filtered or unexported fields
}

func NewServiceMonitor

func NewServiceMonitor(ctx context.Context, cli *Client) (*ServiceMonitor, error)

service monitor is spawned per deployment

func (*ServiceMonitor) Cleanup

func (sm *ServiceMonitor) Cleanup(namespace, serviceName string) error

cleanup ignores errors, expected to run if no metrics were defined

func (*ServiceMonitor) Deploy

func (sm *ServiceMonitor) Deploy(namespace, serviceName string, metricParams v1.Metrics, firstPort string) error

Deploy firstPort is used as a fallback if only path is provided, the first port is used

type ServiceParams

type ServiceParams struct {
	LBAnnotations map[string]string
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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