cluster

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: 129 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExternalBaseURLKey         = contextKey("ExternalBaseURL")
	ExternalBaseURLInsecureKey = contextKey("ExternalBaseURLInsecure")
)
View Source
const CreateClusterWorkflowName = "create-cluster-legacy"
View Source
const DownloadK8sConfigActivityName = "download-k8s-config-legacy"
View Source
const EKSCreateClusterWorkflowName = "eks-create-cluster"
View Source
const EKSDeleteClusterWorkflowName = "eks-delete-cluster"
View Source
const EKSUpdateClusterWorkflowName = "eks-update-cluster"
View Source
const LabelNodesWithNodepoolNameActivityName = "label-nodes-with-nodepool-name-legacy"
View Source
const RBAC_API_VERSION = "rbac.authorization.k8s.io"
View Source
const RunPostHookActivityName = "run-posthook"
View Source
const RunPostHooksWorkflowName = "run-posthooks"
View Source
const (
	StorageAccountContributor = "Storage Account Contributor"
)

Storage Account Contributor role constant

View Source
const UpdateClusterStatusActivityName = "update-cluster-status"

Variables

View Source
var (
	ErrSecretNotFound                = stderrors.New("secret not found")
	ErrKubernetesSecretNotFound      = stderrors.New("kubernetes secret not found")
	ErrKubernetesSecretAlreadyExists = stderrors.New("kubernetes secret already exists")
)

BasePostHookFunctions default posthook functions after cluster create nolint: gochecknoglobals

View Source
var ErrAlreadyExists = stderrors.New("cluster already exists with this name")
View Source
var ErrConfigNotExists = fmt.Errorf("Kubernetes config is not available for the cluster")

ErrConfigNotExists means that a cluster has no kubeconfig stored in vault (probably didn't successfully start yet)

View Source
var ErrInvalidClusterInstance = errors.New("invalid cluster instance")
View Source
var ErrNoInfrastructureRG = errors.New("no infrastructure resource group found")

HookMap for api hook endpoints nolint: gochecknoglobals

Functions

func CreateClusterWorkflow

func CreateClusterWorkflow(ctx workflow.Context, input CreateClusterWorkflowInput) error

func CreateOrUpdateResourceGroup

func CreateOrUpdateResourceGroup(orgID uint, secretID string, resourceGroupName, location string) error

CreateOrUpdateResourceGroup creates or updates a resource group

func EKSCreateClusterWorkflow

func EKSCreateClusterWorkflow(ctx workflow.Context, input EKSCreateClusterWorkflowInput) error

CreateClusterWorkflow executes the Cadence workflow responsible for creating and configuring an EKS cluster

func EKSDeleteClusterWorkflow

func EKSDeleteClusterWorkflow(ctx workflow.Context, input EKSDeleteClusterWorkflowInput) error

DeleteClusterWorkflow executes the Cadence workflow responsible for deleting an EKS cluster

func GetDesiredLabelsForCluster

func GetDesiredLabelsForCluster(ctx context.Context, cluster CommonCluster, nodePoolLabels []NodePoolLabels) (map[string]map[string]string, error)

GetDesiredLabelsForCluster returns desired set of labels for each node pool name, adding reserved labels like: head node, ondemand labels + cloudinfo to user defined labels in specified nodePools map. All user labels are deleted in case Label map is empty in NodePoolLabels, however in case Label map is nil no labels are returned to avoid overriding already exisisting user specified labels.

func GetEKSNodePools

func GetEKSNodePools(cluster CommonCluster) ([]*eksmodel.AmazonNodePoolsModel, error)

GetEKSNodePools returns EKS node pools from a common cluster.

func GetKubernetesVersion

func GetKubernetesVersion(orgID uint, secretID string, location string) ([]string, error)

GetKubernetesVersion returns a list of supported kubernetes version in the specified subscription

func GetLocations

func GetLocations(orgID uint, secretID string) (locations []string, err error)

GetLocations returns all the locations that are available for resource providers

func GetMachineTypes

func GetMachineTypes(orgID uint, secretID string, location string) (pkgCluster.MachineTypes, error)

GetMachineTypes lists all available virtual machine sizes for a subscription in a location

func InstallSecret

func InstallSecret(cc interface {
	GetK8sConfig() ([]byte, error)
	GetOrganizationId() uint
}, secretName string, req InstallSecretRequest,
) (string, error)

InstallSecret installs a new secret under the name into namespace of a Kubernetes cluster. It returns the installed secret name and meta about how to mount it.

func InstallSecretByK8SConfig

func InstallSecretByK8SConfig(kubeConfig []byte, orgID uint, secretName string, req InstallSecretRequest) (string, error)

InstallSecretByK8SConfig is the same as InstallSecret but use this if you already have a K8S config at hand.

func InstallSecrets

func InstallSecrets(ctx context.Context, cc CommonCluster, query *secret.ListSecretsQuery, namespace string) ([]string, error)

InstallSecrets installs or updates secrets that matches the query under the name into namespace of a Kubernetes cluster. It returns the list of installed secret names and meta about how to mount them.

func InstallSecretsByK8SConfig

func InstallSecretsByK8SConfig(ctx context.Context, kubeConfig []byte, orgID uint, query *secret.ListSecretsQuery, namespace string) ([]string, error)

InstallSecretsByK8SConfig is the same as InstallSecrets but use this if you already have a K8S config at hand.

func ListResourceGroups

func ListResourceGroups(orgID uint, secretID string) (res []string, err error)

ListResourceGroups returns all resource group

func MergeSecret

func MergeSecret(ctx context.Context, cc CommonCluster, secretName string, req InstallSecretRequest) (string, error)

MergeSecret merges a secret with an already existing one in a Kubernetes cluster. It returns the installed secret name and meta about how to mount it.

func MergeSecretByK8SConfig

func MergeSecretByK8SConfig(ctx context.Context, kubeConfig []byte, orgID uint, secretName string, req InstallSecretRequest) (string, error)

MergeSecretByK8SConfig is the same as MergeSecret but use this if you already have a K8S config at hand.

func NewClusterCheckMiddleware

func NewClusterCheckMiddleware(manager *Manager, errorHandler emperror.Handler) gin.HandlerFunc

NewClusterCheckMiddleware returns a new gin middleware that checks cluster is exists in the current org.

func NewClusterCreator

func NewClusterCreator(request *pkgCluster.CreateClusterRequest, cluster CommonCluster, workflowClient client.Client) clusterCreator

NewClusterCreator returns a new PKE or Common cluster creator instance depending on the cluster.

func NewClusterEvents

func NewClusterEvents(eb eventBus) *clusterEventBus

func NewCommonClusterCreator

func NewCommonClusterCreator(request *pkgCluster.CreateClusterRequest, cluster CommonCluster) *commonCreator

NewCommonClusterCreator returns a new cluster creator instance.

func NewCommonClusterUpdater

func NewCommonClusterUpdater(
	request *cluster.UpdateClusterRequest,
	clientFactory DynamicClientFactory,
	cluster CommonCluster,
	userID uint,
	workflowClient client.Client,
	externalBaseURL string,
	externalBaseURLInsecure bool,
	helmService HelmService,
) *commonUpdater

NewCommonClusterUpdater returns a new cluster creator instance.

func NewCommonNodepoolUpdater

func NewCommonNodepoolUpdater(request *cluster.UpdateNodePoolsRequest, cluster CommonCluster, userID uint) *commonNodepoolUpdater

NewCommonNodepoolUpdater returns a new cluster creator instance.

func NewCreatorBaseFields

func NewCreatorBaseFields(createdAt time.Time, createdBy uint) *pkgCommon.CreatorBaseFields

NewCreatorBaseFields creates a new CreatorBaseFields instance from createdAt and createdBy

func NewExporter

func NewExporter() *pipelineMetrics

func NewLogurLogger

func NewLogurLogger(fl logrus.FieldLogger) logur.Logger

func NewNopClusterEvents

func NewNopClusterEvents() *nopClusterEvents

func RunPostHooksWorkflow

func RunPostHooksWorkflow(ctx workflow.Context, input RunPostHooksWorkflowInput) error

func StoreKubernetesConfig

func StoreKubernetesConfig(cluster CommonCluster, config []byte) error

StoreKubernetesConfig stores the given K8S config in vault

Types

type AKSCluster

type AKSCluster struct {
	CommonClusterBase
	// contains filtered or unexported fields
}

AKSCluster represents an AKS cluster

func CreateAKSClusterFromModel

func CreateAKSClusterFromModel(clusterModel *model.ClusterModel) *AKSCluster

CreateAKSClusterFromModel creates ClusterModel struct from model

func CreateAKSClusterFromRequest

func CreateAKSClusterFromRequest(request *pkgCluster.CreateClusterRequest, orgID uint, userID uint) (*AKSCluster, error)

CreateAKSClusterFromRequest returns an AKS cluster instance created from the specified request

func (*AKSCluster) AddDefaultsToUpdate

func (c *AKSCluster) AddDefaultsToUpdate(r *pkgCluster.UpdateClusterRequest)

AddDefaultsToUpdate adds defaults to update request

func (*AKSCluster) CheckEqualityToUpdate

func (c *AKSCluster) CheckEqualityToUpdate(r *pkgCluster.UpdateClusterRequest) error

CheckEqualityToUpdate validates the update request

func (*AKSCluster) CreateCluster

func (c *AKSCluster) CreateCluster() error

CreateCluster creates a new cluster

func (*AKSCluster) DeleteCluster

func (c *AKSCluster) DeleteCluster() error

DeleteCluster deletes the cluster from AKS

func (*AKSCluster) DeleteFromDatabase

func (c *AKSCluster) DeleteFromDatabase() error

DeleteFromDatabase deletes model from the database

func (*AKSCluster) DownloadK8sConfig

func (c *AKSCluster) DownloadK8sConfig() ([]byte, error)

DownloadK8sConfig returns the kubeconfig file's contents from AKS

func (*AKSCluster) GetAKSNodePools

func (c *AKSCluster) GetAKSNodePools() []*azureadapter.AKSNodePoolModel

GetAKSNodePools returns AKS node pools.

func (*AKSCluster) GetAPIEndpoint

func (c *AKSCluster) GetAPIEndpoint() (string, error)

GetAPIEndpoint returns the Kubernetes API endpoint

func (*AKSCluster) GetCloud

func (c *AKSCluster) GetCloud() string

GetCloud returns the cloud type of the cluster

func (*AKSCluster) GetConfigSecretId

func (c *AKSCluster) GetConfigSecretId() string

GetConfigSecretId returns the cluster's config secret ID

func (*AKSCluster) GetDistribution

func (c *AKSCluster) GetDistribution() string

GetDistribution returns the distribution type of the cluster

func (*AKSCluster) GetID

func (c *AKSCluster) GetID() uint

GetID returns the cluster's ID

func (*AKSCluster) GetK8sConfig

func (c *AKSCluster) GetK8sConfig() ([]byte, error)

GetK8sConfig returns the Kubernetes config

func (*AKSCluster) GetK8sUserConfig

func (c *AKSCluster) GetK8sUserConfig() ([]byte, error)

GetK8sUserConfig returns the Kubernetes config for external users

func (*AKSCluster) GetKubernetesVersion

func (c *AKSCluster) GetKubernetesVersion() (string, error)

func (*AKSCluster) GetLocation

func (c *AKSCluster) GetLocation() string

GetLocation returns the location of the cluster

func (*AKSCluster) GetModel

func (c *AKSCluster) GetModel() *model.ClusterModel

GetModel returns the cluster's model

func (*AKSCluster) GetName

func (c *AKSCluster) GetName() string

GetName returns the name of the cluster

func (*AKSCluster) GetOrganizationId

func (c *AKSCluster) GetOrganizationId() uint

GetOrganizationId returns the ID of the organization where the cluster belongs to

func (*AKSCluster) GetResourceGroupName

func (c *AKSCluster) GetResourceGroupName() string

GetResourceGroupName return the resource group's name the cluster belongs in

func (*AKSCluster) GetSecretId

func (c *AKSCluster) GetSecretId() string

GetSecretId returns the cluster secret's ID

func (*AKSCluster) GetSecretWithValidation

func (c *AKSCluster) GetSecretWithValidation() (*secret.SecretItemResponse, error)

GetSecretWithValidation returns secret from vault

func (*AKSCluster) GetSshSecretId

func (c *AKSCluster) GetSshSecretId() string

GetSSHSecretID returns the cluster's SSH secret ID

func (*AKSCluster) GetStatus

GetStatus returns the cluster's status

func (*AKSCluster) GetUID

func (c *AKSCluster) GetUID() string

GetUID returns the cluster's UID

func (*AKSCluster) IsReady

func (c *AKSCluster) IsReady() (bool, error)

IsReady checks if the cluster is running according to the cloud provider

func (*AKSCluster) NodePoolExists

func (c *AKSCluster) NodePoolExists(nodePoolName string) bool

NodePoolExists returns true if node pool with nodePoolName exists

func (*AKSCluster) Persist

func (c *AKSCluster) Persist() error

Persist saves the cluster model Deprecated: Do not use.

func (*AKSCluster) RbacEnabled

func (c *AKSCluster) RbacEnabled() bool

RbacEnabled returns true if rbac enabled on the cluster

func (*AKSCluster) RequiresSshPublicKey

func (c *AKSCluster) RequiresSshPublicKey() bool

RequiresSshPublicKey returns true if a public SSH key is needed for bootstrapping the cluster

func (*AKSCluster) SaveConfigSecretId

func (c *AKSCluster) SaveConfigSecretId(configSecretID string) error

SaveConfigSecretId saves the config secret ID in database

func (*AKSCluster) SaveSshSecretId

func (c *AKSCluster) SaveSshSecretId(sshSecretID string) error

SaveSshSecretId saves the SSH secret ID to database

func (*AKSCluster) SetStatus

func (c *AKSCluster) SetStatus(status, statusMessage string) error

SetStatus sets the cluster's status

func (*AKSCluster) UpdateCluster

func (c *AKSCluster) UpdateCluster(request *pkgCluster.UpdateClusterRequest, userID uint) error

UpdateCluster updates the cluster in AKS

func (*AKSCluster) UpdateNodePools

func (c *AKSCluster) UpdateNodePools(request *pkgCluster.UpdateNodePoolsRequest, userID uint) error

UpdateNodePools updates nodes pools of a cluster

func (*AKSCluster) ValidateCreationFields

func (c *AKSCluster) ValidateCreationFields(r *pkgCluster.CreateClusterRequest) error

ValidateCreationFields validates all field

type ClientFactory

type ClientFactory interface {
	// FromSecret creates a Kubernetes client for a cluster from a secret.
	FromSecret(ctx context.Context, secretID string) (kubernetes.Interface, error)
}

ClientFactory returns a Kubernetes client.

type CommonCluster

type CommonCluster interface {
	// Entity properties
	GetID() uint
	GetUID() string
	GetOrganizationId() uint
	GetName() string
	GetCloud() string
	GetDistribution() string
	GetLocation() string

	// Secrets
	GetSecretId() string
	GetSshSecretId() string
	SaveSshSecretId(string) error
	SaveConfigSecretId(string) error
	GetConfigSecretId() string
	GetSecretWithValidation() (*secret.SecretItemResponse, error)

	// Persistence
	Persist() error
	DeleteFromDatabase() error

	// Cluster management
	CreateCluster() error
	ValidateCreationFields(r *pkgCluster.CreateClusterRequest) error
	UpdateCluster(*pkgCluster.UpdateClusterRequest, uint) error
	UpdateNodePools(*pkgCluster.UpdateNodePoolsRequest, uint) error
	CheckEqualityToUpdate(*pkgCluster.UpdateClusterRequest) error
	AddDefaultsToUpdate(*pkgCluster.UpdateClusterRequest)
	DeleteCluster() error

	// Kubernetes
	GetAPIEndpoint() (string, error)
	GetK8sConfig() ([]byte, error)
	GetK8sUserConfig() ([]byte, error)
	RequiresSshPublicKey() bool
	RbacEnabled() bool

	// Cluster info
	GetStatus() (*pkgCluster.GetClusterStatusResponse, error)
	IsReady() (bool, error)
	NodePoolExists(nodePoolName string) bool

	SetStatus(status, statusMessage string) error
}

CommonCluster interface for clusters.

func CreateCommonClusterFromRequest

func CreateCommonClusterFromRequest(createClusterRequest *pkgCluster.CreateClusterRequest, orgId uint, userId uint) (CommonCluster, error)

CreateCommonClusterFromRequest creates a CommonCluster from a request

func GetCommonClusterFromModel

func GetCommonClusterFromModel(modelCluster *model.ClusterModel) (CommonCluster, error)

GetCommonClusterFromModel extracts CommonCluster from a ClusterModel

type CommonClusterBase

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

CommonClusterBase holds the fields that is common to all cluster types also provides default implementation for common interface methods.

func (*CommonClusterBase) RequiresSshPublicKey

func (c *CommonClusterBase) RequiresSshPublicKey() bool

RequiresSshPublicKey returns true if an ssh public key is needed for the cluster for bootstrapping it. The default is false.

type CreateClusterWorkflowInput

type CreateClusterWorkflowInput struct {
	ClusterID        uint
	ClusterUID       string
	ClusterName      string
	OrganizationID   uint
	OrganizationName string
	Distribution     string
	NodePoolLabels   map[string]map[string]string
	PostHooks        pkgCluster.PostHooks
	Cloud            string
}

type CreationContext

type CreationContext struct {
	OrganizationID          uint
	UserID                  uint
	ExternalBaseURL         string
	ExternalBaseURLInsecure bool
	Name                    string
	Provider                string
	SecretID                string
	SecretIDs               []string
	PostHooks               pkgCluster.PostHooks
}

CreationContext represents the data necessary to do generic cluster creation steps/checks.

type DownloadK8sConfigActivity

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

func NewDownloadK8sConfigActivity

func NewDownloadK8sConfigActivity(manager *Manager) DownloadK8sConfigActivity

func (DownloadK8sConfigActivity) Execute

type DownloadK8sConfigActivityInput

type DownloadK8sConfigActivityInput struct {
	ClusterID uint
}

type DynamicClientFactory

type DynamicClientFactory interface {
	// FromSecret creates a Kubernetes client for a cluster from a secret.
	FromSecret(ctx context.Context, secretID string) (dynamic.Interface, error)
}

DynamicClientFactory returns a dynamic Kubernetes client.

type EC2ClusterPKE

type EC2ClusterPKE struct {

	// amazonCluster *ec2.EC2 //Don't use this directly
	APIEndpoint string

	CommonClusterBase
	// contains filtered or unexported fields
}

func CreateEC2ClusterPKEFromModel

func CreateEC2ClusterPKEFromModel(modelCluster *model.ClusterModel) (*EC2ClusterPKE, error)

func CreateEC2ClusterPKEFromRequest

func CreateEC2ClusterPKEFromRequest(request *pkgCluster.CreateClusterRequest, orgId uint, userId uint) (*EC2ClusterPKE, error)

func (*EC2ClusterPKE) AddDefaultsToUpdate

func (c *EC2ClusterPKE) AddDefaultsToUpdate(*pkgCluster.UpdateClusterRequest)

func (*EC2ClusterPKE) CheckEqualityToUpdate

func (c *EC2ClusterPKE) CheckEqualityToUpdate(*pkgCluster.UpdateClusterRequest) error

func (*EC2ClusterPKE) CreateCluster

func (c *EC2ClusterPKE) CreateCluster() error

func (*EC2ClusterPKE) CreatePKECluster

func (c *EC2ClusterPKE) CreatePKECluster(tokenGenerator TokenGenerator, externalBaseURL string) error

func (*EC2ClusterPKE) DeleteCluster

func (c *EC2ClusterPKE) DeleteCluster() error

func (*EC2ClusterPKE) DeleteFromDatabase

func (c *EC2ClusterPKE) DeleteFromDatabase() error

DeleteFromDatabase deletes the distribution related entities from the database

func (*EC2ClusterPKE) DeletePKECluster

func (c *EC2ClusterPKE) DeletePKECluster(ctx context.Context, workflowClient client.Client) error

func (*EC2ClusterPKE) GetAPIEndpoint

func (c *EC2ClusterPKE) GetAPIEndpoint() (string, error)

func (*EC2ClusterPKE) GetAWSClient

func (c *EC2ClusterPKE) GetAWSClient() (*session.Session, error)

func (*EC2ClusterPKE) GetBootstrapCommand

func (c *EC2ClusterPKE) GetBootstrapCommand(
	nodePoolName string,
	url string,
	urlInsecure bool,
	token string,
	labels []string,
	version string,
) (string, error)

GetBootstrapCommand returns a command line to use to install a node in the given nodepool

func (*EC2ClusterPKE) GetCAHash

func (c *EC2ClusterPKE) GetCAHash() (string, error)

func (*EC2ClusterPKE) GetCloud

func (c *EC2ClusterPKE) GetCloud() string

func (*EC2ClusterPKE) GetConfigSecretId

func (c *EC2ClusterPKE) GetConfigSecretId() string

func (*EC2ClusterPKE) GetCurrentWorkflowID

func (c *EC2ClusterPKE) GetCurrentWorkflowID() string

func (*EC2ClusterPKE) GetDistribution

func (c *EC2ClusterPKE) GetDistribution() string

func (*EC2ClusterPKE) GetID

func (c *EC2ClusterPKE) GetID() uint

func (*EC2ClusterPKE) GetK8sConfig

func (c *EC2ClusterPKE) GetK8sConfig() ([]byte, error)

func (*EC2ClusterPKE) GetK8sUserConfig

func (c *EC2ClusterPKE) GetK8sUserConfig() ([]byte, error)

func (*EC2ClusterPKE) GetKubernetesContainerRuntime

func (c *EC2ClusterPKE) GetKubernetesContainerRuntime() (string, error)

func (*EC2ClusterPKE) GetKubernetesNetworkProvider

func (c *EC2ClusterPKE) GetKubernetesNetworkProvider() (string, error)

func (*EC2ClusterPKE) GetKubernetesVersion

func (c *EC2ClusterPKE) GetKubernetesVersion() (string, error)

func (*EC2ClusterPKE) GetLocation

func (c *EC2ClusterPKE) GetLocation() string

func (*EC2ClusterPKE) GetName

func (c *EC2ClusterPKE) GetName() string

func (*EC2ClusterPKE) GetNetworkApiServerAddress

func (c *EC2ClusterPKE) GetNetworkApiServerAddress() (host, port string, err error)

GetNetworkApiServerAddress returns Kubernetes API Server host and port.

func (*EC2ClusterPKE) GetNetworkCloudProvider

func (c *EC2ClusterPKE) GetNetworkCloudProvider() (cloudProvider, vpcID string, subnets []string, err error)

GetNetworkCloudProvider return cloud provider specific network information.

func (*EC2ClusterPKE) GetNodePools

func (c *EC2ClusterPKE) GetNodePools() []PKENodePool

func (*EC2ClusterPKE) GetOrganizationId

func (c *EC2ClusterPKE) GetOrganizationId() uint

func (*EC2ClusterPKE) GetPipelineToken

func (c *EC2ClusterPKE) GetPipelineToken(tokenGenerator interface{}) (string, error)

GetPipelineToken returns a lazily generated token for Pipeline

func (*EC2ClusterPKE) GetSecretId

func (c *EC2ClusterPKE) GetSecretId() string

func (*EC2ClusterPKE) GetSecretWithValidation

func (c *EC2ClusterPKE) GetSecretWithValidation() (*secret.SecretItemResponse, error)

func (*EC2ClusterPKE) GetSshPublicKey

func (c *EC2ClusterPKE) GetSshPublicKey() (string, error)

func (*EC2ClusterPKE) GetSshSecretId

func (c *EC2ClusterPKE) GetSshSecretId() string

func (*EC2ClusterPKE) GetStatus

func (*EC2ClusterPKE) GetUID

func (c *EC2ClusterPKE) GetUID() string

func (*EC2ClusterPKE) HasK8sConfig

func (c *EC2ClusterPKE) HasK8sConfig() (bool, error)

HasK8sConfig returns true if the cluster's k8s config is available

func (*EC2ClusterPKE) IsMasterReady

func (c *EC2ClusterPKE) IsMasterReady() (bool, error)

IsMasterReady returns true when the master node has been reported as ready

func (*EC2ClusterPKE) IsReady

func (c *EC2ClusterPKE) IsReady() (bool, error)

IsReady checks if the cluster is running according to the cloud provider.

func (*EC2ClusterPKE) ListNodePools

func (c *EC2ClusterPKE) ListNodePools() ([]string, error)

ListNodePools returns node pool names.

func (*EC2ClusterPKE) NodePoolExists

func (c *EC2ClusterPKE) NodePoolExists(nodePoolName string) bool

func (*EC2ClusterPKE) Persist

func (c *EC2ClusterPKE) Persist() error

func (*EC2ClusterPKE) RbacEnabled

func (c *EC2ClusterPKE) RbacEnabled() bool

func (*EC2ClusterPKE) RegisterNode

func (c *EC2ClusterPKE) RegisterNode(name, nodePoolName, ip string, master, worker bool) error

RegisterNode adds a Node to the DB

func (*EC2ClusterPKE) RequiresSshPublicKey

func (c *EC2ClusterPKE) RequiresSshPublicKey() bool

RequiresSshPublicKey returns true as a public ssh key is needed for bootstrapping the cluster

func (*EC2ClusterPKE) SaveConfigSecretId

func (c *EC2ClusterPKE) SaveConfigSecretId(configSecretId string) error

func (*EC2ClusterPKE) SaveNetworkApiServerAddress

func (c *EC2ClusterPKE) SaveNetworkApiServerAddress(host, port string) error

SaveNetworkApiServerAddress stores Kubernetes API Server host and port.

func (*EC2ClusterPKE) SaveNetworkCloudProvider

func (c *EC2ClusterPKE) SaveNetworkCloudProvider(cloudProvider, vpcID string, subnets []string) error

SaveNetworkCloudProvider saves cloud provider specific network information.

func (*EC2ClusterPKE) SaveSshSecretId

func (c *EC2ClusterPKE) SaveSshSecretId(sshSecretId string) error

func (*EC2ClusterPKE) SetCurrentWorkflowID

func (c *EC2ClusterPKE) SetCurrentWorkflowID(workflowID string) error

func (*EC2ClusterPKE) SetStatus

func (c *EC2ClusterPKE) SetStatus(status, statusMessage string) error

SetStatus sets the cluster's status

func (*EC2ClusterPKE) UpdateCluster

func (*EC2ClusterPKE) UpdateNodePools

func (*EC2ClusterPKE) UpdatePKECluster

func (c *EC2ClusterPKE) UpdatePKECluster(ctx context.Context, request *pkgCluster.UpdateClusterRequest, userID uint, workflowClient client.Client, externalBaseURL string, externalBaseURLInsecure bool) error

func (*EC2ClusterPKE) ValidateCreationFields

func (c *EC2ClusterPKE) ValidateCreationFields(r *pkgCluster.CreateClusterRequest) error

type EKSCluster

type EKSCluster struct {
	EncryptionConfig []pkgEks.EncryptionConfig

	// maps node pools to subnets. The subnets identified by the "default" key represent the subnets provided in
	// request.Properties.CreateClusterEKS.Subnets
	SubnetMapping map[string][]*pkgEks.Subnet

	CommonClusterBase
	// contains filtered or unexported fields
}

EKSCluster struct for EKS cluster

func CreateEKSClusterFromModel

func CreateEKSClusterFromModel(clusterModel *model.ClusterModel) (*EKSCluster, error)

CreateEKSClusterFromModel creates ClusterModel struct from the model

func CreateEKSClusterFromRequest

func CreateEKSClusterFromRequest(request *pkgCluster.CreateClusterRequest, orgId uint, userId uint) (*EKSCluster, error)

CreateEKSClusterFromRequest creates ClusterModel struct from the request

func (*EKSCluster) AddDefaultsToUpdate

func (c *EKSCluster) AddDefaultsToUpdate(r *pkgCluster.UpdateClusterRequest)

AddDefaultsToUpdate adds defaults to update request

func (*EKSCluster) CheckEqualityToUpdate

func (c *EKSCluster) CheckEqualityToUpdate(r *pkgCluster.UpdateClusterRequest) error

CheckEqualityToUpdate validates the update request

func (*EKSCluster) CreateCluster

func (c *EKSCluster) CreateCluster() error

func (*EKSCluster) DeleteCluster

func (c *EKSCluster) DeleteCluster() error

func (*EKSCluster) DeleteFromDatabase

func (c *EKSCluster) DeleteFromDatabase() error

DeleteFromDatabase deletes model from the database

func (*EKSCluster) GetAPIEndpoint

func (c *EKSCluster) GetAPIEndpoint() (string, error)

GetAPIEndpoint returns the Kubernetes Api endpoint

func (*EKSCluster) GetCloud

func (c *EKSCluster) GetCloud() string

GetCloud returns the cloud type of the cluster

func (*EKSCluster) GetConfigSecretId

func (c *EKSCluster) GetConfigSecretId() string

GetConfigSecretId returns config secret id

func (*EKSCluster) GetDistribution

func (c *EKSCluster) GetDistribution() string

GetDistribution returns the distribution type of the cluster

func (*EKSCluster) GetID

func (c *EKSCluster) GetID() uint

GetID returns the DB ID of this cluster

func (*EKSCluster) GetK8sConfig

func (c *EKSCluster) GetK8sConfig() ([]byte, error)

GetK8sConfig returns the Kubernetes config for internal use

func (*EKSCluster) GetK8sUserConfig

func (c *EKSCluster) GetK8sUserConfig() ([]byte, error)

GetK8sUserConfig returns the Kubernetes config for external users

func (*EKSCluster) GetKubernetesVersion

func (c *EKSCluster) GetKubernetesVersion() (string, error)

func (*EKSCluster) GetLocation

func (c *EKSCluster) GetLocation() string

GetLocation gets where the cluster is.

func (*EKSCluster) GetModel

func (c *EKSCluster) GetModel() *eksmodel.EKSClusterModel

GetModel returns the DB model of this cluster

func (*EKSCluster) GetName

func (c *EKSCluster) GetName() string

GetName returns the name of the cluster

func (*EKSCluster) GetOrganizationId

func (c *EKSCluster) GetOrganizationId() uint

GetOrganizationId gets org where the cluster belongs

func (*EKSCluster) GetSecretId

func (c *EKSCluster) GetSecretId() string

GetSecretId retrieves the secret id

func (*EKSCluster) GetSecretWithValidation

func (c *EKSCluster) GetSecretWithValidation() (*secret.SecretItemResponse, error)

GetSecretWithValidation returns secret from vault

func (*EKSCluster) GetSshSecretId

func (c *EKSCluster) GetSshSecretId() string

GetSshSecretId retrieves the secret id

func (*EKSCluster) GetStatus

GetStatus describes the status of this EKS cluster.

func (*EKSCluster) GetSubnetMapping

func (c *EKSCluster) GetSubnetMapping() map[string][]*pkgEks.Subnet

func (*EKSCluster) GetUID

func (c *EKSCluster) GetUID() string

func (*EKSCluster) IsReady

func (c *EKSCluster) IsReady() (bool, error)

IsReady checks if the cluster is running according to the cloud provider.

func (*EKSCluster) IsSSHGenerated

func (c *EKSCluster) IsSSHGenerated() bool

func (*EKSCluster) NodePoolExists

func (c *EKSCluster) NodePoolExists(nodePoolName string) bool

NodePoolExists returns true if node pool with nodePoolName exists

func (*EKSCluster) Persist

func (c *EKSCluster) Persist() error

Persist saves the cluster model Deprecated: Do not use.

func (*EKSCluster) PersistSSHGenerate

func (c *EKSCluster) PersistSSHGenerate(sshGenerated bool) error

func (*EKSCluster) RbacEnabled

func (c *EKSCluster) RbacEnabled() bool

RbacEnabled returns true if rbac enabled on the cluster

func (*EKSCluster) RequiresSshPublicKey

func (c *EKSCluster) RequiresSshPublicKey() bool

RequiresSshPublicKey returns true as a public ssh key is needed for bootstrapping the cluster

func (*EKSCluster) SaveConfigSecretId

func (c *EKSCluster) SaveConfigSecretId(configSecretId string) error

SaveConfigSecretId saves the config secret id in database

func (*EKSCluster) SaveSshSecretId

func (c *EKSCluster) SaveSshSecretId(sshSecretId string) error

SaveSshSecretId saves the ssh secret id to database

func (*EKSCluster) SetCurrentWorkflowID

func (c *EKSCluster) SetCurrentWorkflowID(workflowID string) error

func (*EKSCluster) SetStatus

func (c *EKSCluster) SetStatus(status string, statusMessage string) error

SetStatus sets the cluster's status

func (*EKSCluster) UpdateCluster deprecated

func (c *EKSCluster) UpdateCluster(*pkgCluster.UpdateClusterRequest, uint) error

Deprecated: UpdateCluster updates EKS cluster in cloud

func (*EKSCluster) UpdateNodePools

func (c *EKSCluster) UpdateNodePools(request *pkgCluster.UpdateNodePoolsRequest, userId uint) error

UpdateNodePools updates nodes pools of a cluster

This will become obsolete once we have the Node Pool API ready

func (*EKSCluster) ValidateCreationFields

func (c *EKSCluster) ValidateCreationFields(*pkgCluster.CreateClusterRequest) error

type EKSClusterRepository

type EKSClusterRepository interface {
	DeleteClusterModel(model *clustermodel.ClusterModel) error
	DeleteModel(model *eksmodel.EKSClusterModel) error
	DeleteNodePool(model *eksmodel.AmazonNodePoolsModel) error
	DeleteSubnet(model *eksmodel.EKSSubnetModel) error
	SaveModel(model *eksmodel.EKSClusterModel) error
	SaveStatusHistory(model *clustermodel.StatusHistoryModel) error
}

EKSClusterRepository describes a EKS cluster's persistent storage repository

func NewDBEKSClusterRepository

func NewDBEKSClusterRepository(db *gorm.DB) (EKSClusterRepository, error)

NewDBEKSClusterRepository returns a new EKSClusterRepository backed by a GORM DB

type EKSCreateClusterWorkflowInput

type EKSCreateClusterWorkflowInput struct {
	eksWorkflow.CreateInfrastructureWorkflowInput

	OrganizationName string
	PostHooks        pkgCluster.PostHooks
	NodePoolLabels   map[string]map[string]string
}

CreateClusterWorkflowInput holds data needed by the create cluster workflow

type EKSDeleteClusterWorkflowInput

type EKSDeleteClusterWorkflowInput struct {
	OrganizationID uint
	SecretID       string
	Region         string

	ClusterName   string
	NodePoolNames []string

	ClusterID  uint
	ClusterUID string

	// the identifier of the kubeconfig secret of the cluster
	K8sSecretID string
	DefaultUser bool

	// force delete
	Forced bool

	GeneratedSSHKeyUsed bool
}

DeleteClusterWorkflowInput holds data needed by the delete cluster workflow

type EKSUpdateClusterWorkflow

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

func NewEKSUpdateClusterWorkflow

func NewEKSUpdateClusterWorkflow(nodePoolStore eks.NodePoolStore) (eksUpdateClusterWorkflow *EKSUpdateClusterWorkflow)

func (EKSUpdateClusterWorkflow) Execute

UpdateClusterstructureWorkflow executes the Cadence workflow responsible for updating EKS worker nodes

type EKSUpdateClusterstructureWorkflowInput

type EKSUpdateClusterstructureWorkflowInput struct {
	Region         string
	OrganizationID uint
	SecretID       string
	ConfigSecretID string

	ClusterID     uint
	ClusterName   string
	Tags          map[string]string
	UpdaterUserID uint

	DeletableNodePoolNames []string
	NewNodePools           []eks.NewNodePool
	NewNodePoolSubnetIDs   map[string][]string
	NodePoolLabels         map[string]map[string]string // TODO: remove when UpdateNodePoolWorkflow is refactored.
	UpdatedNodePools       []eksWorkflow.AutoscaleGroup
}

EKSUpdateClusterstructureWorkflowInput holds data needed to update EKS cluster worker node pools

type ErrorHandler

type ErrorHandler struct{}

ErrorHandler is the common struct which implement Error function

func (*ErrorHandler) Error

func (*ErrorHandler) Error(c CommonCluster, err error)

type GKECluster

type GKECluster struct {
	APIEndpoint string

	CommonClusterBase
	// contains filtered or unexported fields
}

GKECluster struct for GKE cluster

func CreateGKEClusterFromModel

func CreateGKEClusterFromModel(clusterModel *model.ClusterModel) (*GKECluster, error)

CreateGKEClusterFromModel creates ClusterModel struct from model

func CreateGKEClusterFromRequest

func CreateGKEClusterFromRequest(request *pkgCluster.CreateClusterRequest, orgID uint, userID uint) (*GKECluster, error)

CreateGKEClusterFromRequest creates ClusterModel struct from the request

func (*GKECluster) AddDefaultsToUpdate

func (c *GKECluster) AddDefaultsToUpdate(r *pkgCluster.UpdateClusterRequest)

AddDefaultsToUpdate adds defaults to update request

func (*GKECluster) CheckEqualityToUpdate

func (c *GKECluster) CheckEqualityToUpdate(r *pkgCluster.UpdateClusterRequest) error

CheckEqualityToUpdate validates the update request

func (*GKECluster) CreateCluster

func (c *GKECluster) CreateCluster() error

CreateCluster creates a new cluster

func (*GKECluster) DeleteCluster

func (c *GKECluster) DeleteCluster() error

DeleteCluster deletes cluster from google

func (*GKECluster) DeleteFromDatabase

func (c *GKECluster) DeleteFromDatabase() error

DeleteFromDatabase deletes model from the database

func (*GKECluster) DownloadK8sConfig

func (c *GKECluster) DownloadK8sConfig() ([]byte, error)

DownloadK8sConfig downloads the kubeconfig file from cloud

func (*GKECluster) GetAPIEndpoint

func (c *GKECluster) GetAPIEndpoint() (string, error)

GetAPIEndpoint returns the Kubernetes Api endpoint

func (*GKECluster) GetAllMachineTypes

func (c *GKECluster) GetAllMachineTypes() (map[string]pkgCluster.MachineTypes, error)

GetAllMachineTypes lists all supported machine types

func (*GKECluster) GetAllMachineTypesByZone

func (c *GKECluster) GetAllMachineTypesByZone(zone string) (map[string]pkgCluster.MachineTypes, error)

GetAllMachineTypesByZone lists supported machine types by zone

func (*GKECluster) GetCloud

func (c *GKECluster) GetCloud() string

GetCloud returns the cloud type of the cluster

func (*GKECluster) GetConfigSecretId

func (c *GKECluster) GetConfigSecretId() string

GetConfigSecretId return config secret id

func (*GKECluster) GetDistribution

func (c *GKECluster) GetDistribution() string

GetDistribution returns the distribution type of the cluster

func (*GKECluster) GetGkeServerConfig

func (c *GKECluster) GetGkeServerConfig(zone string) (*gke.ServerConfig, error)

GetGkeServerConfig returns configuration info about the Kubernetes Engine service.

func (*GKECluster) GetGoogleCluster

func (c *GKECluster) GetGoogleCluster() (*gke.Cluster, error)

GetGoogleCluster returns with a Cluster from GKE

func (*GKECluster) GetID

func (c *GKECluster) GetID() uint

GetID returns the specified cluster id

func (*GKECluster) GetK8sConfig

func (c *GKECluster) GetK8sConfig() ([]byte, error)

GetK8sConfig returns the Kubernetes config

func (*GKECluster) GetK8sUserConfig

func (c *GKECluster) GetK8sUserConfig() ([]byte, error)

GetK8sUserConfig returns the Kubernetes config

func (*GKECluster) GetLocation

func (c *GKECluster) GetLocation() string

GetLocation gets where the cluster is.

func (*GKECluster) GetName

func (c *GKECluster) GetName() string

GetName returns the name of the cluster

func (*GKECluster) GetOrganizationId

func (c *GKECluster) GetOrganizationId() uint

GetOrganizationId gets org where the cluster belongs

func (*GKECluster) GetProjectId

func (c *GKECluster) GetProjectId() (string, error)

GetProjectId returns with project id from secret

func (*GKECluster) GetSecretId

func (c *GKECluster) GetSecretId() string

GetSecretId retrieves the secret id

func (*GKECluster) GetSecretWithValidation

func (c *GKECluster) GetSecretWithValidation() (*secret.SecretItemResponse, error)

GetSecretWithValidation returns secret from vault

func (*GKECluster) GetSshSecretId

func (c *GKECluster) GetSshSecretId() string

GetSshSecretId retrieves the secret id

func (*GKECluster) GetStatus

GetStatus gets cluster status

func (*GKECluster) GetUID

func (c *GKECluster) GetUID() string

func (*GKECluster) GetZones

func (c *GKECluster) GetZones() ([]string, error)

GetZones lists supported zones

func (*GKECluster) IsReady

func (c *GKECluster) IsReady() (bool, error)

IsReady checks if the cluster is running according to the cloud provider.

func (*GKECluster) NodePoolExists

func (c *GKECluster) NodePoolExists(nodePoolName string) bool

NodePoolExists returns true if node pool with nodePoolName exists

func (*GKECluster) Persist

func (c *GKECluster) Persist() error

Persist save the cluster model

func (*GKECluster) RbacEnabled

func (c *GKECluster) RbacEnabled() bool

RbacEnabled returns true if rbac enabled on the cluster

func (*GKECluster) SaveConfigSecretId

func (c *GKECluster) SaveConfigSecretId(configSecretId string) error

SaveConfigSecretId saves the config secret id in database

func (*GKECluster) SaveSshSecretId

func (c *GKECluster) SaveSshSecretId(sshSecretId string) error

SaveSshSecretId saves the ssh secret id to database

func (*GKECluster) SetStatus

func (c *GKECluster) SetStatus(status, statusMessage string) error

SetStatus sets the cluster's status

func (*GKECluster) UpdateCluster

func (c *GKECluster) UpdateCluster(updateRequest *pkgCluster.UpdateClusterRequest, userId uint) error

UpdateCluster updates GKE cluster in cloud

func (*GKECluster) UpdateNodePools

func (c *GKECluster) UpdateNodePools(request *pkgCluster.UpdateNodePoolsRequest, userId uint) error

UpdateNodePools updates nodes pools of a cluster

func (*GKECluster) ValidateCreationFields

func (c *GKECluster) ValidateCreationFields(r *pkgCluster.CreateClusterRequest) error

ValidateCreationFields validates all field

type GKEClusterRepository

type GKEClusterRepository interface {
	DeleteClusterModel(model *clustermodel.ClusterModel) error
	DeleteModel(model *google.GKEClusterModel) error
	DeleteNodePool(model *google.GKENodePoolModel) error
	SaveModel(model *google.GKEClusterModel) error
	SaveStatusHistory(model *clustermodel.StatusHistoryModel) error
}

GKEClusterRepository describes a GKE cluster's persistent storage repository

func NewDBGKEClusterRepository

func NewDBGKEClusterRepository(db *gorm.DB) (GKEClusterRepository, error)

NewDBGKEClusterRepository returns a new GKEClusterRepository backed by a GORM DB

type HelmService

type HelmService interface {
	ApplyDeployment(
		ctx context.Context,
		clusterID uint,
		namespace string,
		chartName string,
		releaseName string,
		values []byte,
		chartVersion string,
	) error

	ApplyDeploymentReuseValues(
		ctx context.Context,
		clusterID uint,
		namespace string,
		chartName string,
		releaseName string,
		values []byte,
		chartVersion string,
		reuseValues bool,
	) error

	InstallDeployment(
		ctx context.Context,
		clusterID uint,
		namespace string,
		chartName string,
		releaseName string,
		values []byte,
		chartVersion string,
		wait bool,
	) error

	// DeleteDeployment deletes a deployment from a specific cluster.
	DeleteDeployment(ctx context.Context, clusterID uint, releaseName, namespace string) error

	// GetDeployment gets a deployment by release name from a specific cluster.
	GetDeployment(ctx context.Context, clusterID uint, releaseName, namespace string) (*pkgHelm.GetDeploymentResponse, error)
}

A generic interface for using Helm for hooks

type HelmServiceInjector

type HelmServiceInjector interface {
	InjectHelmService(HelmService)
}

type HookWithParamsFactory

type HookWithParamsFactory interface {
	Create(pkgCluster.PostHookParam) PostFunctioner
}

type InitSpotConfigPostHook

type InitSpotConfigPostHook struct {
	Priority
	ErrorHandler
	// contains filtered or unexported fields
}

func (*InitSpotConfigPostHook) Do

func (ph *InitSpotConfigPostHook) Do(cluster CommonCluster) error

InitSpotConfig creates a ConfigMap to store spot related config and installs the scheduler and the spot webhook charts

func (*InitSpotConfigPostHook) InjectHelmService

func (h *InitSpotConfigPostHook) InjectHelmService(helmService HelmService)

InjectHelmService injects the service to be used by the "parent" struct

type InstallSecretRequest

type InstallSecretRequest struct {
	SourceSecretName string
	Namespace        string
	Spec             map[string]InstallSecretRequestSpecItem
	Update           bool
}

type InstallSecretRequestSpecItem

type InstallSecretRequestSpecItem struct {
	Source    string
	SourceMap map[string]string
	Value     string
}

type K8sConfigDownloader

type K8sConfigDownloader interface {
	DownloadK8sConfig() ([]byte, error)
}

K8sConfigDownloader can download a cluster config.

type KubeAPIProxy

type KubeAPIProxy struct {
	Handler gin.HandlerFunc
}

func NewKubeAPIProxy

func NewKubeAPIProxy(requestSchema string, requestHost string, apiProxyPrefix string, cluster CommonCluster, keepalive time.Duration) (*KubeAPIProxy, error)

NewKubeAPIProxy creates a new Kubernetes API Server Proxy to the given cluster with a well-defined keep-alive timeout.

type KubeCluster

type KubeCluster struct {
	APIEndpoint string

	CommonClusterBase
	// contains filtered or unexported fields
}

KubeCluster struct for Build your own cluster

func CreateKubernetesClusterFromModel

func CreateKubernetesClusterFromModel(clusterModel *model.ClusterModel) (*KubeCluster, error)

CreateKubernetesClusterFromModel converts ClusterModel to KubeCluster

func CreateKubernetesClusterFromRequest

func CreateKubernetesClusterFromRequest(request *pkgCluster.CreateClusterRequest, orgId uint, userId uint) (*KubeCluster, error)

CreateKubernetesClusterFromRequest creates ClusterModel struct from the request

func (*KubeCluster) AddDefaultsToUpdate

func (c *KubeCluster) AddDefaultsToUpdate(*pkgCluster.UpdateClusterRequest)

AddDefaultsToUpdate adds defaults to update request, in this case no update function

func (*KubeCluster) CheckEqualityToUpdate

func (c *KubeCluster) CheckEqualityToUpdate(*pkgCluster.UpdateClusterRequest) error

CheckEqualityToUpdate validates the update request, in this case no update function

func (*KubeCluster) CreateCluster

func (c *KubeCluster) CreateCluster() error

CreateCluster creates a new cluster

func (*KubeCluster) DeleteCluster

func (c *KubeCluster) DeleteCluster() error

DeleteCluster deletes cluster from cloud, in this case no delete function

func (*KubeCluster) DeleteFromDatabase

func (c *KubeCluster) DeleteFromDatabase() error

DeleteFromDatabase deletes model from the database

func (*KubeCluster) DownloadK8sConfig

func (c *KubeCluster) DownloadK8sConfig() ([]byte, error)

DownloadK8sConfig downloads the kubeconfig file from cloud

func (*KubeCluster) GetAPIEndpoint

func (c *KubeCluster) GetAPIEndpoint() (string, error)

GetAPIEndpoint returns the Kubernetes Api endpoint

func (*KubeCluster) GetCloud

func (c *KubeCluster) GetCloud() string

GetCloud returns the cloud type of the cluster

func (*KubeCluster) GetConfigSecretId

func (c *KubeCluster) GetConfigSecretId() string

GetConfigSecretId return config secret id

func (*KubeCluster) GetDistribution

func (c *KubeCluster) GetDistribution() string

GetDistribution returns the distribution type of the cluster

func (*KubeCluster) GetID

func (c *KubeCluster) GetID() uint

GetID returns the specified cluster id

func (*KubeCluster) GetK8sConfig

func (c *KubeCluster) GetK8sConfig() ([]byte, error)

GetK8sConfig returns the Kubernetes config

func (*KubeCluster) GetK8sUserConfig

func (c *KubeCluster) GetK8sUserConfig() ([]byte, error)

GetK8sUserConfig returns the Kubernetes config

func (*KubeCluster) GetLocation

func (c *KubeCluster) GetLocation() string

GetLocation gets where the cluster is.

func (*KubeCluster) GetModel

func (c *KubeCluster) GetModel() *model.ClusterModel

GetModel returns the whole clusterModel

func (*KubeCluster) GetName

func (c *KubeCluster) GetName() string

GetName returns the name of the cluster

func (*KubeCluster) GetOrganizationId

func (c *KubeCluster) GetOrganizationId() uint

GetOrganizationId returns the specified organization id

func (*KubeCluster) GetSecretId

func (c *KubeCluster) GetSecretId() string

GetSecretId returns the specified secret id

func (*KubeCluster) GetSecretWithValidation

func (c *KubeCluster) GetSecretWithValidation() (*secret.SecretItemResponse, error)

GetSecretWithValidation returns secret from vault

func (*KubeCluster) GetSshSecretId

func (c *KubeCluster) GetSshSecretId() string

GetSshSecretId returns the specified ssh secret id

func (*KubeCluster) GetStatus

GetStatus gets cluster status

func (*KubeCluster) GetUID

func (c *KubeCluster) GetUID() string

func (*KubeCluster) IsReady

func (c *KubeCluster) IsReady() (bool, error)

IsReady checks if the cluster is running according to the cloud provider.

func (*KubeCluster) NodePoolExists

func (c *KubeCluster) NodePoolExists(nodePoolName string) bool

NodePoolExists returns true if node pool with nodePoolName exists

func (*KubeCluster) Persist

func (c *KubeCluster) Persist() error

Persist save the cluster model Deprecated: Do not use.

func (*KubeCluster) RbacEnabled

func (c *KubeCluster) RbacEnabled() bool

RbacEnabled returns true if rbac enabled on the cluster

func (*KubeCluster) SaveConfigSecretId

func (c *KubeCluster) SaveConfigSecretId(configSecretId string) error

SaveConfigSecretId saves the config secret id in database

func (*KubeCluster) SaveSshSecretId

func (c *KubeCluster) SaveSshSecretId(sshSecretId string) error

SaveSshSecretId saves the ssh secret id to database

func (*KubeCluster) SetStatus

func (c *KubeCluster) SetStatus(status, statusMessage string) error

SetStatus sets the cluster's status

func (*KubeCluster) UpdateCluster

func (c *KubeCluster) UpdateCluster(updateRequest *pkgCluster.UpdateClusterRequest, _ uint) error

UpdateCluster updates cluster in cloud, in this case no update function

func (*KubeCluster) UpdateNodePools

func (c *KubeCluster) UpdateNodePools(request *pkgCluster.UpdateNodePoolsRequest, userId uint) error

UpdateNodePools updates nodes pools of a cluster

func (*KubeCluster) ValidateCreationFields

func (c *KubeCluster) ValidateCreationFields(r *pkgCluster.CreateClusterRequest) error

ValidateCreationFields validates all field

type KubeProxyCache

type KubeProxyCache interface {
	Get(clusterUID string) (*KubeAPIProxy, bool)
	Put(clusterUID string, proxy *KubeAPIProxy)
	Delete(clusterUID string)
}

type KubernetesDashboardPostHook

type KubernetesDashboardPostHook struct {
	Priority
	ErrorHandler
	// contains filtered or unexported fields
}

func (*KubernetesDashboardPostHook) Do

func (*KubernetesDashboardPostHook) InjectHelmService

func (h *KubernetesDashboardPostHook) InjectHelmService(helmService HelmService)

InjectHelmService injects the service to be used by the "parent" struct

type LabelNodesWithNodepoolNameActivity

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

func NewLabelNodesWithNodepoolNameActivity

func NewLabelNodesWithNodepoolNameActivity(clientFactory ClientFactory, manager *Manager) LabelNodesWithNodepoolNameActivity

func (LabelNodesWithNodepoolNameActivity) Execute

type LabelNodesWithNodepoolNameActivityInput

type LabelNodesWithNodepoolNameActivityInput struct {
	ClusterID uint
	SecretID  string
}

type Manager

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

func NewManager

func NewManager(
	clusters clusterRepository,
	secrets secretValidator,
	events clusterEvents,
	statusChangeDurationMetric metrics.ClusterStatusChangeDurationMetric,
	clusterTotalMetric *prometheus.CounterVec,
	workflowClient client.Client,
	logger logrus.FieldLogger,
	errorHandler emperror.Handler,
	clusterStore interface {
		SetStatus(ctx context.Context, id uint, status, message string) error
	},
	releaseDeleter interface {
		DeleteReleases(ctx context.Context, orgID uint, kubeConfig []byte, namespaces []string) error
	},
) *Manager

func (*Manager) CreateCluster

func (m *Manager) CreateCluster(
	ctx context.Context,
	creationCtx CreationContext,
	creator clusterCreator,
) (CommonCluster, error)

CreateCluster creates a new cluster in the background.

func (*Manager) DeleteCluster

func (m *Manager) DeleteCluster(ctx context.Context, cluster CommonCluster, force bool) error

DeleteCluster deletes a cluster.

func (*Manager) DeleteKubeProxy

func (m *Manager) DeleteKubeProxy(commonCluster CommonCluster)

func (*Manager) GetAllClusters

func (m *Manager) GetAllClusters(ctx context.Context) ([]CommonCluster, error)

GetAllClusters returns all cluster instances.

func (*Manager) GetClusterByID

func (m *Manager) GetClusterByID(ctx context.Context, organizationID uint, clusterID uint) (CommonCluster, error)

GetClusterByID returns the cluster instance for an organization ID by cluster ID.

func (*Manager) GetClusterByIDOnly

func (m *Manager) GetClusterByIDOnly(ctx context.Context, clusterID uint) (CommonCluster, error)

GetClusterByIDOnly returns the cluster instance by cluster ID.

func (*Manager) GetClusterByName

func (m *Manager) GetClusterByName(ctx context.Context, organizationID uint, clusterName string) (CommonCluster, error)

GetClusterByName returns the cluster instance for an organization ID by cluster name.

func (*Manager) GetClusterStatus

func (m *Manager) GetClusterStatus(ctx context.Context, clusterID uint) (string, error)

GetClusterStatus returns the status of the cluster with the specified ID

func (*Manager) GetClusters

func (m *Manager) GetClusters(ctx context.Context, organizationID uint) ([]CommonCluster, error)

GetClusters returns the cluster instances for an organization ID.

func (*Manager) GetClustersBySecretID

func (m *Manager) GetClustersBySecretID(ctx context.Context, organizationID uint, secretID string) ([]CommonCluster, error)

GetClustersBySecretID returns the cluster instance for an organization ID by secret ID.

func (*Manager) GetKubeProxy

func (m *Manager) GetKubeProxy(requestSchema string, requestHost string, apiProxyPrefix string, commonCluster CommonCluster) (*KubeAPIProxy, error)

func (*Manager) GetKubeProxyCache

func (m *Manager) GetKubeProxyCache() KubeProxyCache

func (*Manager) KubeConfigFunc

func (m *Manager) KubeConfigFunc() func(ctx context.Context, clusterID uint) ([]byte, error)

func (*Manager) UpdateCluster

func (m *Manager) UpdateCluster(ctx context.Context, updateCtx UpdateContext, updater clusterUpdater) error

UpdateCluster updates a cluster.

type NodePoolLabels

type NodePoolLabels struct {
	NodePoolName string
	Existing     bool
	InstanceType string            `json:"instanceType,omitempty"`
	SpotPrice    string            `json:"spotPrice,omitempty"`
	Preemptible  bool              `json:"preemptible,omitempty"`
	CustomLabels map[string]string `json:"labels,omitempty"`
}

func (NodePoolLabels) GetInstanceType

func (n NodePoolLabels) GetInstanceType() string

GetInstanceType returns the node pool instance type.

func (NodePoolLabels) GetLabels

func (n NodePoolLabels) GetLabels() map[string]string

GetLabels returns labels that are/should be applied to every node in the pool.

func (NodePoolLabels) GetName

func (n NodePoolLabels) GetName() string

GetName returns the node pool name.

func (NodePoolLabels) IsOnDemand

func (n NodePoolLabels) IsOnDemand() bool

IsOnDemand determines whether the machines in the node pool are on demand or spot/preemtible instances.

type PKENodePool

type PKENodePool struct {
	Name              string
	MinCount          int
	MaxCount          int
	Count             int
	Autoscaling       bool
	Master            bool
	Worker            bool
	InstanceType      string
	AvailabilityZones []string
	ImageID           string
	VolumeSize        int
	SpotPrice         string
	Subnets           []string
}

type PostFunctioner

type PostFunctioner interface {
	Do(CommonCluster) error
	GetPriority() int
	Error(CommonCluster, error)
}

PostFunctioner manages posthook functions

type Priority

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

Priority can be used to run post hooks in a specific order

func (*Priority) GetPriority

func (p *Priority) GetPriority() int

Priority returns the priority value of a posthook - the lower the value, the sooner the posthook will run

type RunPostHookActivity

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

func NewRunPostHookActivity

func NewRunPostHookActivity(manager *Manager, helmService HelmService) *RunPostHookActivity

func (*RunPostHookActivity) Execute

type RunPostHookActivityInput

type RunPostHookActivityInput struct {
	ClusterID uint
	HookName  string
	HookParam interface{}
	Status    string
}

type RunPostHooksWorkflowInput

type RunPostHooksWorkflowInput struct {
	ClusterID uint
	PostHooks []RunPostHooksWorkflowInputPostHook
}

type RunPostHooksWorkflowInputPostHook

type RunPostHooksWorkflowInputPostHook struct {
	Name  string
	Param interface{}
}

func BuildWorkflowPostHookFunctions

func BuildWorkflowPostHookFunctions(postHooks pkgCluster.PostHooks, alwaysIncludeBasePostHooks bool) []RunPostHooksWorkflowInputPostHook

BuildWorkflowPostHookFunctions builds posthook workflow input.

type TokenGenerator

type TokenGenerator interface {
	GenerateClusterToken(orgID uint, clusterID uint) (string, string, error)
}

type UpdateClusterStatusActivity

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

func NewUpdateClusterStatusActivity

func NewUpdateClusterStatusActivity(manager *Manager) *UpdateClusterStatusActivity

func (*UpdateClusterStatusActivity) Execute

type UpdateClusterStatusActivityInput

type UpdateClusterStatusActivityInput struct {
	ClusterID     uint
	Status        string
	StatusMessage string
}

type UpdateContext

type UpdateContext struct {
	OrganizationID uint
	UserID         uint
	ClusterID      uint
}

UpdateContext represents the data necessary to do generic cluster update steps/checks.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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