deployment

package
v0.0.0-...-e7c744b Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OperationSucceededStatus = "SUCCEEDED"
	OperationFailedStatus    = "FAILED"
)
View Source
const (
	NotInstalledStatus = "NOT INSTALLED"
	StaleStatus        = "STALE"
	UnknownStatus      = "UNKNOWN"
)
View Source
const FeatureName = "deployment"

Variables

This section is empty.

Functions

func IsDeploymentAlreadyExistsError

func IsDeploymentAlreadyExistsError(err error) bool

IsDeploymentAlreadyExistsError returns true if the passed in error designates a deployment already exists error

func IsDeploymentNotFoundError

func IsDeploymentNotFoundError(err error) bool

IsDeploymentNotFoundError returns true if the passed in error designates a deployment not found error

func IsMemberClusterNotFoundError

func IsMemberClusterNotFoundError(err error) (*memberClusterNotFoundError, bool)

IsMemberClusterNotFoundError returns true if the passed in error designates a cluster group member is not found

func Migrate

func Migrate(db *gorm.DB, logger logrus.FieldLogger) error

Migrate executes the table migrations for the cluster module.

Types

type CGDeploymentManager

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

CGDeploymentManager

func NewCGDeploymentManager

func NewCGDeploymentManager(
	db *gorm.DB,
	clusterGetter api.ClusterGetter,
	logger logrus.FieldLogger,
	errorHandler emperror.Handler,
	helmService HelmService,
) *CGDeploymentManager

NewCGDeploymentManager returns a new CGDeploymentManager instance.

func (CGDeploymentManager) CreateDeployment

func (m CGDeploymentManager) CreateDeployment(clusterGroup *api.ClusterGroup, orgId uint, orgName string, cgDeployment *ClusterGroupDeployment) ([]TargetClusterStatus, error)

func (CGDeploymentManager) DeleteDeployment

func (m CGDeploymentManager) DeleteDeployment(clusterGroup *api.ClusterGroup, releaseName string, forceDelete bool) ([]TargetClusterStatus, error)

DeleteDeployment deletes deployments from target clusters

func (CGDeploymentManager) GenerateReleaseName

func (m CGDeploymentManager) GenerateReleaseName(clusterGroup *api.ClusterGroup) string

func (CGDeploymentManager) GetAllDeployments

func (m CGDeploymentManager) GetAllDeployments(clusterGroup *api.ClusterGroup) ([]*ListDeploymentResponse, error)

func (CGDeploymentManager) GetDeployment

func (m CGDeploymentManager) GetDeployment(clusterGroup *api.ClusterGroup, deploymentName string) (*DeploymentInfo, error)

func (*CGDeploymentManager) GetMembersStatus

func (m *CGDeploymentManager) GetMembersStatus(featureState api.Feature) (map[uint]string, error)

func (*CGDeploymentManager) IsReleaseNameAvailable

func (m *CGDeploymentManager) IsReleaseNameAvailable(clusterGroup *api.ClusterGroup, releaseName string, namespace string) bool

func (*CGDeploymentManager) ReconcileState

func (m *CGDeploymentManager) ReconcileState(featureState api.Feature) error

ReconcileState reconciles state of cluster group deployments according to cluster group state changes

func (CGDeploymentManager) SyncDeployment

func (m CGDeploymentManager) SyncDeployment(clusterGroup *api.ClusterGroup, orgId uint, releaseName string) ([]TargetClusterStatus, error)

SyncDeployment deletes deployments from target clusters not belonging to the group anymore, installs or upgrades to member clusters

func (CGDeploymentManager) UpdateDeployment

func (m CGDeploymentManager) UpdateDeployment(clusterGroup *api.ClusterGroup, orgId uint, cgDeployment *ClusterGroupDeployment) ([]TargetClusterStatus, error)

UpdateDeployment upgrades deployment using provided values or using already provided values if ReUseValues = true. The deployment is installed on a member cluster in case it's was not installed previously.

func (*CGDeploymentManager) ValidateProperties

func (m *CGDeploymentManager) ValidateProperties(clusterGroup api.ClusterGroup, currentProperties, properties interface{}) error

func (*CGDeploymentManager) ValidateState

func (m *CGDeploymentManager) ValidateState(featureState api.Feature) error

type CGDeploymentRepository

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

CGDeploymentRepository

func (*CGDeploymentRepository) Delete

func (g *CGDeploymentRepository) Delete(model *ClusterGroupDeploymentModel, targetClustersStatus []TargetClusterStatus) error

Delete deletes a cluster group deployment if every target cluster is deleted successfully

func (*CGDeploymentRepository) DeleteTargetCluster

func (g *CGDeploymentRepository) DeleteTargetCluster(model *TargetCluster) error

Delete deletes a target cluster from deployment

func (*CGDeploymentRepository) FindAll

func (g *CGDeploymentRepository) FindAll(clusterGroupID uint) ([]*ClusterGroupDeploymentModel, error)

FindAll returns all cluster group deployments

func (*CGDeploymentRepository) FindByName

func (g *CGDeploymentRepository) FindByName(clusterGroupID uint, deploymentName string) (*ClusterGroupDeploymentModel, error)

FindByName returns a cluster group deployment by name.

func (*CGDeploymentRepository) Save

type ChartMeta

type ChartMeta struct {
	Name        string
	Version     string
	Description string
}

type ClusterGroupDeployment

type ClusterGroupDeployment struct {
	ReleaseName    string                            `json:"releaseName" yaml:"releaseName"`
	Name           string                            `json:"name" yaml:"name" binding:"required"`
	Version        string                            `json:"version,omitempty" yaml:"version,omitempty"`
	Package        []byte                            `json:"package,omitempty" yaml:"package,omitempty"`
	ReUseValues    bool                              `json:"reuseValues" yaml:"reuseValues"`
	Namespace      string                            `json:"namespace,omitempty" yaml:"namespace,omitempty"`
	DryRun         bool                              `json:"dryrun,omitempty" yaml:"dryrun,omitempty"`
	Values         map[string]interface{}            `json:"values,omitempty" yaml:"values,omitempty"`
	ValueOverrides map[string]map[string]interface{} `json:"valueOverrides,omitempty" yaml:"valueOverrides,omitempty"`
	RollingMode    bool                              `json:"rollingMode,omitempty" yaml:"rollingMode,omitempty"`
	Atomic         bool                              `json:"atomic,omitempty" yaml:"atomic,omitempty"`
}

ClusterGroupDeployment describes a Helm deployment to a Cluster Group

type ClusterGroupDeploymentModel

type ClusterGroupDeploymentModel struct {
	ID                    uint `gorm:"primary_key"`
	ClusterGroupID        uint `gorm:"unique_index:idx_unique_cid_rname"`
	CreatedAt             time.Time
	UpdatedAt             *time.Time
	DeploymentName        string
	DeploymentVersion     string
	DeploymentPackage     []byte
	DeploymentReleaseName string `gorm:"unique_index:idx_unique_cid_rname"`
	Description           string
	ChartName             string
	Namespace             string
	OrganizationName      string
	Values                []byte           `sql:"type:text;"`
	TargetClusters        []*TargetCluster `gorm:"foreignkey:ClusterGroupDeploymentID"`
}

ClusterGroupDeploymentModel describes a cluster group deployment

func (ClusterGroupDeploymentModel) TableName

func (ClusterGroupDeploymentModel) TableName() string

TableName changes the default table name.

type CreateUpdateDeploymentResponse

type CreateUpdateDeploymentResponse struct {
	ReleaseName    string                `json:"releaseName"`
	TargetClusters []TargetClusterStatus `json:"targetClusters"`
}

CreateUpdateDeploymentResponse describes a create/update deployment response

type DeleteResponse

type DeleteResponse struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
	Name    string `json:"name"`
}

DeleteResponse describes a deployment delete response

type DeploymentInfo

type DeploymentInfo struct {
	ReleaseName          string                            `json:"releaseName"`
	Chart                string                            `json:"chart"`
	ChartName            string                            `json:"chartName"`
	ChartVersion         string                            `json:"chartVersion"`
	Namespace            string                            `json:"namespace"`
	Version              int32                             `json:"version,omitempty"`
	Description          string                            `json:"description"`
	CreatedAt            time.Time                         `json:"createdAt,omitempty"`
	UpdatedAt            time.Time                         `json:"updatedAt,omitempty"`
	Values               map[string]interface{}            `json:"values"`
	ValueOverrides       map[string]map[string]interface{} `json:"valueOverrides,omitempty" yaml:"valueOverrides,omitempty"`
	TargetClusters       map[uint]bool                     `json:"-" yaml:"-"`
	TargetClustersStatus []TargetClusterStatus             `json:"targetClusters"`
}

DeploymentInfo describes the details of a helm deployment

func (*DeploymentInfo) GetValuesForCluster

func (c *DeploymentInfo) GetValuesForCluster(clusterName string) ([]byte, error)

type HelmService

type HelmService interface {
	GetChartMeta(orgId uint, name, version string) (ChartMeta, error)
	InstallOrUpgrade(
		orgID uint,
		c helm.ClusterDataProvider,
		release helm.Release,
		opts helm.Options,
	) error
	GetRelease(c helm.ClusterDataProvider, releaseName, namespace string) (helm.Release, error)
	DeleteRelease(c helm.ClusterDataProvider, releaseName, namespace string) error
}

func NewHelmService

func NewHelmService(facade helm.Service, releaser helm.UnifiedReleaser) HelmService

type ListDeploymentResponse

type ListDeploymentResponse struct {
	Name         string    `json:"releaseName"`
	Chart        string    `json:"chart"`
	ChartName    string    `json:"chartName"`
	ChartVersion string    `json:"chartVersion"`
	Version      int32     `json:"version,omitempty"`
	UpdatedAt    time.Time `json:"updatedAt"`
	Namespace    string    `json:"namespace"`
	CreatedAt    time.Time `json:"createdAt,omitempty"`
}

ListDeploymentResponse describes a deployment list response

type TargetCluster

type TargetCluster struct {
	ID                       uint `gorm:"primary_key"`
	ClusterGroupDeploymentID uint `gorm:"unique_index:idx_unique_dep_cl"`
	ClusterID                uint `gorm:"unique_index:idx_unique_dep_cl"`
	ClusterName              string
	CreatedAt                time.Time
	UpdatedAt                *time.Time
	Values                   []byte `sql:"type:text;"`
}

TargetCluster describes cluster specific values for a cluster group deployment

func (TargetCluster) TableName

func (TargetCluster) TableName() string

TableName changes the default table name.

type TargetClusterStatus

type TargetClusterStatus struct {
	ClusterId    uint   `json:"clusterId"`
	ClusterName  string `json:"clusterName"`
	Cloud        string `json:"cloud,omitempty"`
	Distribution string `json:"distribution,omitempty"`
	Status       string `json:"status"`
	Stale        bool   `json:"stale"`
	Version      string `json:"version,omitempty"`
	Error        string `json:"error,omitempty"`
}

TargetClusterStatus describes a status of a deployment on a target cluster

type TargetOperationStatus

type TargetOperationStatus struct {
	ClusterId   uint   `json:"clusterId"`
	ClusterName string `json:"clusterName"`
	Status      string `json:"status"`
	Error       string `json:"error,omitempty"`
}

TargetOperationStatus describes a status of a deployment operation (install/upgrade/delete) on a target cluster

Jump to

Keyboard shortcuts

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