controllers

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterReconciler

type ClusterReconciler struct {
	client.Client
	Log    logr.Logger
	Scheme *runtime.Scheme
}

ClusterReconciler reconciles a Cluster object

func (*ClusterReconciler) Reconcile

func (r *ClusterReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error)

func (*ClusterReconciler) SetupWithManager

func (r *ClusterReconciler) SetupWithManager(mgr ctrl.Manager) error

type ProviderBase

type ProviderBase struct {
	// types.Metadata `json:",inline"`
	// types.Status   `json:"status"`
	// types.SSH      `json:",inline"`
	APIServerAddresses string
	CmdFlags           types.CmdFlags
	Cluster            *k3sv1alpha1.Cluster
	Clientset          *kubernetes.Clientset
	Kubeconfig         string
	Config             *clientcmdapi.Config
	SSH                *easyssh.MakeConfig
	M                  *sync.Map
	Log                *logrus.Logger
	Callbacks          map[string]*providerProcess
	Plugins            interfaces.EnabledPlugins
	HelmRelease        k3sv1alpha1.HelmRelease
	ENV                k3sv1alpha1.EnvConfig
	EnvServer          k3sv1alpha1.EnvServer
	EnvViper           *viper.Viper
}

func NewClusterFromConfig

func NewClusterFromConfig(configViper *viper.Viper, cmdFlags types.CmdFlags) (providerBase *ProviderBase, err error)

NewClusterFromViperConfig new base provider.

func (*ProviderBase) AddNode

func (p *ProviderBase) AddNode(nodeName string) (ok bool)

AddNode add node to cluster.

func (*ProviderBase) AddNodeToCluster added in v0.6.5

func (p *ProviderBase) AddNodeToCluster(node *k3sv1alpha1.Node) (err error)

AddNodeToCluster add worker node to cluster.

func (*ProviderBase) CheckExitFile

func (p *ProviderBase) CheckExitFile(file string, node *k3sv1alpha1.Node) (ok bool)

CheckExitFile проверка на существование файла на сервере

func (*ProviderBase) CreateK3sCluster

func (p *ProviderBase) CreateK3sCluster() (err error)

CreateK3sCluster create K3S cluster.

func (*ProviderBase) DeleteNode

func (p *ProviderBase) DeleteNode(nodeName string, allNodes bool) (cnt int)

DeleteNode delete node from cluster

func (*ProviderBase) Execute

func (p *ProviderBase) Execute(command string, node *k3sv1alpha1.Node, stream bool) (stdOut string, err error)

Execute command local or ssh

func (*ProviderBase) ExecuteMaster

func (p *ProviderBase) ExecuteMaster(command string, first bool) (stdOuts []string, err error)

ExecuteMaster execute command in master node

func (*ProviderBase) FromViperSimple

func (p *ProviderBase) FromViperSimple(config *viper.Viper) error

FromViperSimple Load config from Viper

func (*ProviderBase) GetAPIServerAddress added in v0.7.1

func (p *ProviderBase) GetAPIServerAddress() (servers []string, err error)

GetAPIServerAddress get kubernetes api server address.

func (*ProviderBase) GetAPIServerPort added in v0.7.1

func (p *ProviderBase) GetAPIServerPort() int32

GetAPIServerPort get api server port

func (*ProviderBase) GetAPIServerUrl

func (p *ProviderBase) GetAPIServerUrl(master *k3sv1alpha1.Node, retry int, isExternal bool) (apiServerUrl string, err error)

GetAPIServerUrl url для подключения к API серверу сперва проверяется InternalDNS, InternalIP, ExternalDNS, ExternalIP если isExternal=true то сперва ExternalDNS, ExternalIP, InternalDNS, InternalIP если retry > 0 то проверяется tcp ping на API сервер (время между повторами с каждым радом больше в 2 раза)

func (*ProviderBase) GetAgentToken

func (p *ProviderBase) GetAgentToken(master *k3sv1alpha1.Node) (token string, err error)

GetAgentToken возвращает токен агента

func (*ProviderBase) GetClusterStatus

func (p *ProviderBase) GetClusterStatus() string

GetClusterStatus cluster status

func (*ProviderBase) GetK3sEnv

func (p *ProviderBase) GetK3sEnv(master *k3sv1alpha1.Node) (envValues string, err error)

GetK3sEnv

func (*ProviderBase) GetKubeconfig

func (p *ProviderBase) GetKubeconfig(master *k3sv1alpha1.Node) (*clientcmdapi.Config, error)

GetKubeconfig

func (*ProviderBase) GetMasterNodes

func (p *ProviderBase) GetMasterNodes() (masters []*k3sv1alpha1.Node)

GetMasterNodes return master nodes

func (*ProviderBase) GetWorkerNodes

func (p *ProviderBase) GetWorkerNodes() (workers []*k3sv1alpha1.Node)

GetMasterNodes return workers nodes

func (*ProviderBase) InitK3sCluster

func (p *ProviderBase) InitK3sCluster() error

InitK3sCluster initial K3S cluster.

func (*ProviderBase) ListNodes

func (p *ProviderBase) ListNodes() ([]v1.Node, error)

ListNodes Read more on Kubernets Nodes. In client-go, NodeInterface includes all the APIs to deal with Nodes.

func (*ProviderBase) LoadEnv

func (p *ProviderBase) LoadEnv()

LoadEnv load .env file

func (*ProviderBase) LoadEnvServer

func (p *ProviderBase) LoadEnvServer(node *k3sv1alpha1.Node) (envViper *viper.Viper, err error)

LoadEnvServer load k3s server env file

func (*ProviderBase) LoadNodeStatus

func (p *ProviderBase) LoadNodeStatus()

LoadNodeStatus

func (*ProviderBase) MakeAgentInstallExec

func (p *ProviderBase) MakeAgentInstallExec(opts *k3sv1alpha1.K3sWorkerOptions) string

MakeAgentInstallExec compile agent install string

func (*ProviderBase) MakeInstallExec

func (p *ProviderBase) MakeInstallExec() (k3sIstallOptions k3sv1alpha1.K3sIstallOptions)

MakeInstallExec установка сервера

func (*ProviderBase) NewSSH

func (p *ProviderBase) NewSSH(bastion *k3sv1alpha1.BastionNode)

func (*ProviderBase) Run

func (p *ProviderBase) Run(command string) (done bool, err error)

Run command on remote machine

Example:

func (*ProviderBase) SetAddons

func (p *ProviderBase) SetAddons(addonsName string)

SetAddons

func (*ProviderBase) SetClientset

func (p *ProviderBase) SetClientset(clusterName string) (err error)

SetClientset setting Clientset for clusterName

func (*ProviderBase) SetClientsetFromConfig

func (p *ProviderBase) SetClientsetFromConfig(kubeconfig *clientcmdapi.Config) (err error)

SetClientsetFromConfig create Clientset from clientcmdapi.Config

func (*ProviderBase) SetDefaulSettings

func (p *ProviderBase) SetDefaulSettings()

SetDefaulSettings

func (*ProviderBase) SetEnvServer

func (p *ProviderBase) SetEnvServer(envViper *viper.Viper) (err error)

SetEnvServer

func (*ProviderBase) SetKubeconfig

func (p *ProviderBase) SetKubeconfig(node *k3sv1alpha1.Node) bool

SetKubeconfig check is install k3s and load kubeconfig file, set Clientset

func (*ProviderBase) SetNodeLabel added in v0.6.5

func (p *ProviderBase) SetNodeLabel(nodeName string, labels []string)

SetNodeLabel set label to node (TODO: move to label operator)

func (*ProviderBase) SetProviders added in v0.5.0

func (p *ProviderBase) SetProviders(cfg *k3sv1alpha1.Cluster)

func (*ProviderBase) ShutDownWithDrain

func (p *ProviderBase) ShutDownWithDrain(node *k3sv1alpha1.Node)

ShutDownWithDrain will cause q to ignore all new items added to it. As soon as the worker goroutines have "drained", i.e: finished processing and called Done on all existing items in the queue; they will be instructed to exit and ShutDownWithDrain will return. Hence: a strict requirement for using this is; your workers must ensure that Done is called on all items in the queue once the shut down has been initiated, if that is not the case: this will block indefinitely. It is, however, safe to call ShutDown after having called ShutDownWithDrain, as to force the queue shut down to terminate immediately without waiting for the drainage.

Jump to

Keyboard shortcuts

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