cluster

package
v0.2.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2018 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KubeDNSAddonResourceName      = "rke-kubedns-addon"
	UserAddonResourceName         = "rke-user-addon"
	IngressAddonResourceName      = "rke-ingress-controller"
	UserAddonsIncludeResourceName = "rke-user-includes-addons"

	IngressAddonJobName            = "rke-ingress-controller-deploy-job"
	IngressAddonDeleteJobName      = "rke-ingress-controller-delete-job"
	MetricsServerAddonResourceName = "rke-metrics-addon"
	NginxIngressAddonAppName       = "ingress-nginx"
	KubeDNSAddonAppName            = "kube-dns"
	KubeDNSAutoscalerAppName       = "kube-dns-autoscaler"
)
View Source
const (
	CloudConfigDeployer    = "cloud-config-deployer"
	CloudConfigServiceName = "cloud"
	CloudConfigPath        = "/etc/kubernetes/cloud-config"
	CloudConfigEnv         = "RKE_CLOUD_CONFIG"
)
View Source
const (
	X509AuthenticationProvider = "x509"
	StateConfigMapName         = "cluster-state"
	FullStateConfigMapName     = "full-cluster-state"
	UpdateStateTimeout         = 30
	GetStateTimeout            = 30
	KubernetesClientTimeOut    = 30
	SyncWorkers                = 10
	NoneAuthorizationMode      = "none"
	LocalNodeAddress           = "127.0.0.1"
	LocalNodeHostname          = "localhost"
	LocalNodeUser              = "root"
	CloudProvider              = "CloudProvider"
	ControlPlane               = "controlPlane"
	WorkerPlane                = "workerPlan"
	EtcdPlane                  = "etcd"

	KubeAppLabel = "k8s-app"
	AppLabel     = "app"
	NameLabel    = "name"

	WorkerThreads = util.WorkerThreads
)
View Source
const (
	DefaultServiceClusterIPRange = "10.43.0.0/16"
	DefaultNodePortRange         = "30000-32767"
	DefaultClusterCIDR           = "10.42.0.0/16"
	DefaultClusterDNSService     = "10.43.0.10"
	DefaultClusterDomain         = "cluster.local"
	DefaultClusterName           = "local"
	DefaultClusterSSHKeyPath     = "~/.ssh/id_rsa"

	DefaultK8sVersion = v3.DefaultK8s

	DefaultSSHPort        = "22"
	DefaultDockerSockPath = "/var/run/docker.sock"

	DefaultAuthStrategy      = "x509"
	DefaultAuthorizationMode = "rbac"

	DefaultNetworkPlugin        = "canal"
	DefaultNetworkCloudProvider = "none"

	DefaultIngressController         = "nginx"
	DefaultEtcdBackupCreationPeriod  = "12h"
	DefaultEtcdBackupRetentionPeriod = "72h"
	DefaultEtcdSnapshot              = true
	DefaultMonitoringProvider        = "metrics-server"

	DefaultEtcdHeartbeatIntervalName  = "heartbeat-interval"
	DefaultEtcdHeartbeatIntervalValue = "500"
	DefaultEtcdElectionTimeoutName    = "election-timeout"
	DefaultEtcdElectionTimeoutValue   = "5000"
)
View Source
const (
	NetworkPluginResourceName = "rke-network-plugin"

	PortCheckContainer        = "rke-port-checker"
	EtcdPortListenContainer   = "rke-etcd-port-listener"
	CPPortListenContainer     = "rke-cp-port-listener"
	WorkerPortListenContainer = "rke-worker-port-listener"

	KubeAPIPort         = "6443"
	EtcdPort1           = "2379"
	EtcdPort2           = "2380"
	ScedulerPort        = "10251"
	ControllerPort      = "10252"
	KubeletPort         = "10250"
	KubeProxyPort       = "10256"
	FlannetVXLANPortUDP = "8472"

	ProtocolTCP = "TCP"
	ProtocolUDP = "UDP"

	NoNetworkPlugin = "none"

	FlannelNetworkPlugin = "flannel"
	FlannelIface         = "flannel_iface"
	FlannelBackendType   = "flannel_backend_type"

	CalicoNetworkPlugin = "calico"
	CalicoCloudProvider = "calico_cloud_provider"

	CanalNetworkPlugin      = "canal"
	CanalIface              = "canal_iface"
	CanalFlannelBackendType = "canal_flannel_backend_type"

	WeaveNetworkPlugin = "weave"
	WeavePasswordKey   = "weave_password"

	// EtcdEndpoints is the server address for Etcd, used by calico
	EtcdEndpoints = "EtcdEndpoints"
	// APIRoot is the kubernetes API address
	APIRoot = "APIRoot"

	EtcdClientCert     = "EtcdClientCert"
	EtcdClientKey      = "EtcdClientKey"
	EtcdClientCA       = "EtcdClientCA"
	EtcdClientCertPath = "EtcdClientCertPath"
	EtcdClientKeyPath  = "EtcdClientKeyPath"
	EtcdClientCAPath   = "EtcdClientCAPath"

	ClientCertPath = "ClientCertPath"
	ClientKeyPath  = "ClientKeyPath"
	ClientCAPath   = "ClientCAPath"

	KubeCfg = "KubeCfg"

	ClusterCIDR = "ClusterCIDR"

	Image              = "Image"
	CNIImage           = "CNIImage"
	NodeImage          = "NodeImage"
	ControllersImage   = "ControllersImage"
	CanalFlannelImg    = "CanalFlannelImg"
	WeaveLoopbackImage = "WeaveLoopbackImage"

	Calicoctl = "Calicoctl"

	FlannelInterface = "FlannelInterface"
	FlannelBackend   = "FlannelBackend"
	CanalInterface   = "CanalInterface"
	WeavePassword    = "WeavePassword"
	RBACConfig       = "RBACConfig"
	ClusterVersion   = "ClusterVersion"
)
View Source
const (
	EtcdPathPrefix     = "/registry"
	ContainerNameLabel = "io.rancher.rke.container.name"
	CloudConfigSumEnv  = "RKE_CLOUD_CONFIG_CHECKSUM"

	DefaultToolsEntrypoint        = "/opt/rke-tools/entrypoint.sh"
	DefaultToolsEntrypointVersion = "0.1.13"
	LegacyToolsEntrypoint         = "/opt/rke/entrypoint.sh"

	KubeletDockerConfigEnv     = "RKE_KUBELET_DOCKER_CONFIG"
	KubeletDockerConfigFileEnv = "RKE_KUBELET_DOCKER_FILE"
	KubeletDockerConfigPath    = "/var/lib/kubelet/config.json"
)

Variables

View Source
var ControlPlanePortList = []string{
	KubeAPIPort,
}
View Source
var EtcdClientPortList = []string{
	EtcdPort1,
}
View Source
var EtcdPortList = []string{
	EtcdPort1,
	EtcdPort2,
}
View Source
var WorkerPortList = []string{
	KubeletPort,
}

Functions

func ApplyAuthzResources added in v0.1.2

func ApplyAuthzResources(ctx context.Context, rkeConfig v3.RancherKubernetesEngineConfig, flags ExternalFlags, dailersOptions hosts.DialersOptions) error

func BuildPortChecksFromPortList added in v0.1.2

func BuildPortChecksFromPortList(host *hosts.Host, portList []string, proto string) []v3.PortCheck

func BuildRKEConfigNodePlan added in v0.1.2

func BuildRKEConfigNodePlan(ctx context.Context, myCluster *Cluster, host *hosts.Host, hostDockerInfo types.Info) v3.RKEConfigNodePlan

func CheckEtcdHostsChanged

func CheckEtcdHostsChanged(kubeCluster, currentCluster *Cluster) error

func ConfigureCluster added in v0.1.2

func ConfigureCluster(
	ctx context.Context,
	rkeConfig v3.RancherKubernetesEngineConfig,
	crtBundle map[string]pki.CertificatePKI,
	flags ExternalFlags,
	dailersOptions hosts.DialersOptions,
	useKubectl bool) error

func GeneratePlan added in v0.1.2

func GeneratePlan(ctx context.Context, rkeConfig *v3.RancherKubernetesEngineConfig, hostsInfoMap map[string]types.Info) (v3.RKEPlan, error)

func GetClusterCertsFromKubernetes added in v0.2.0

func GetClusterCertsFromKubernetes(ctx context.Context, kubeCluster *Cluster) (map[string]pki.CertificatePKI, error)

func GetK8sVersion

func GetK8sVersion(localConfigPath string, k8sWrapTransport k8s.WrapTransport) (string, error)

func GetLocalRKEConfig

func GetLocalRKEConfig() *v3.RancherKubernetesEngineConfig

func GetLocalRKENodeConfig

func GetLocalRKENodeConfig() *v3.RKEConfigNode

func GetStateFilePath added in v0.2.0

func GetStateFilePath(configPath, configDir string) string

func ParseConfig

func ParseConfig(clusterFile string) (*v3.RancherKubernetesEngineConfig, error)

func RebuildKubeconfig added in v0.2.0

func RebuildKubeconfig(ctx context.Context, kubeCluster *Cluster) error

func ReconcileCluster

func ReconcileCluster(ctx context.Context, kubeCluster, currentCluster *Cluster, flags ExternalFlags) error

func RestartClusterPods added in v0.2.0

func RestartClusterPods(ctx context.Context, kubeCluster *Cluster) error

func RotateRKECertificates added in v0.1.18

func RotateRKECertificates(ctx context.Context, c *Cluster, flags ExternalFlags, rotateflags RotateCertificatesFlags, clusterState *FullState) error

func SaveFullStateToKubernetes added in v0.2.0

func SaveFullStateToKubernetes(ctx context.Context, kubeCluster *Cluster, fullState *FullState) error

func SetUpAuthentication

func SetUpAuthentication(ctx context.Context, kubeCluster, currentCluster *Cluster, fullState *FullState) error

func ValidateHostCount added in v0.1.2

func ValidateHostCount(c *Cluster) error

Types

type Cluster

type Cluster struct {
	ConfigPath                       string
	ConfigDir                        string
	CloudConfigFile                  string
	ControlPlaneHosts                []*hosts.Host
	Certificates                     map[string]pki.CertificatePKI
	ClusterDomain                    string
	ClusterCIDR                      string
	ClusterDNSServer                 string
	DockerDialerFactory              hosts.DialerFactory
	EtcdHosts                        []*hosts.Host
	EtcdReadyHosts                   []*hosts.Host
	InactiveHosts                    []*hosts.Host
	K8sWrapTransport                 k8s.WrapTransport
	KubeClient                       *kubernetes.Clientset
	KubernetesServiceIP              net.IP
	LocalKubeConfigPath              string
	LocalConnDialerFactory           hosts.DialerFactory
	PrivateRegistriesMap             map[string]v3.PrivateRegistry
	StateFilePath                    string
	UseKubectlDeploy                 bool
	UpdateWorkersOnly                bool
	v3.RancherKubernetesEngineConfig `yaml:",inline"`
	WorkerHosts                      []*hosts.Host
}

func GetStateFromKubernetes added in v0.2.0

func GetStateFromKubernetes(ctx context.Context, kubeCluster *Cluster) (*Cluster, error)

func InitClusterObject added in v0.2.0

func InitClusterObject(ctx context.Context, rkeConfig *v3.RancherKubernetesEngineConfig, flags ExternalFlags) (*Cluster, error)

func (*Cluster) ApplySystemAddonExecuteJob added in v0.1.9

func (c *Cluster) ApplySystemAddonExecuteJob(addonJob string, addonUpdated bool) error

func (*Cluster) BuildEtcdProcess added in v0.1.2

func (c *Cluster) BuildEtcdProcess(host *hosts.Host, etcdHosts []*hosts.Host, prefixPath string) v3.Process

func (*Cluster) BuildKubeAPIProcess added in v0.1.2

func (c *Cluster) BuildKubeAPIProcess(prefixPath string) v3.Process

func (*Cluster) BuildKubeControllerProcess added in v0.1.2

func (c *Cluster) BuildKubeControllerProcess(prefixPath string) v3.Process

func (*Cluster) BuildKubeProxyProcess added in v0.1.2

func (c *Cluster) BuildKubeProxyProcess(host *hosts.Host, prefixPath string) v3.Process

func (*Cluster) BuildKubeletProcess added in v0.1.2

func (c *Cluster) BuildKubeletProcess(host *hosts.Host, prefixPath string) v3.Process

func (*Cluster) BuildProxyProcess added in v0.1.2

func (c *Cluster) BuildProxyProcess() v3.Process

func (*Cluster) BuildSchedulerProcess added in v0.1.2

func (c *Cluster) BuildSchedulerProcess(prefixPath string) v3.Process

func (*Cluster) BuildSidecarProcess added in v0.1.2

func (c *Cluster) BuildSidecarProcess() v3.Process

func (*Cluster) CheckClusterPorts

func (c *Cluster) CheckClusterPorts(ctx context.Context, currentCluster *Cluster) error

func (*Cluster) CleanDeadLogs added in v0.1.3

func (c *Cluster) CleanDeadLogs(ctx context.Context) error

func (*Cluster) CleanupFiles added in v0.2.0

func (c *Cluster) CleanupFiles(ctx context.Context) error

func (*Cluster) CleanupNodes added in v0.2.0

func (c *Cluster) CleanupNodes(ctx context.Context) error

func (*Cluster) ClusterRemove

func (c *Cluster) ClusterRemove(ctx context.Context) error

func (*Cluster) DeployControlPlane

func (c *Cluster) DeployControlPlane(ctx context.Context) error

func (*Cluster) DeployWorkerPlane

func (c *Cluster) DeployWorkerPlane(ctx context.Context) error

func (*Cluster) GetClusterState

func (c *Cluster) GetClusterState(ctx context.Context, fullState *FullState) (*Cluster, error)

func (*Cluster) GetHostInfoMap added in v0.2.0

func (c *Cluster) GetHostInfoMap() map[string]types.Info

func (*Cluster) GetKubernetesServicesOptions added in v0.1.6

func (c *Cluster) GetKubernetesServicesOptions() v3.KubernetesServicesOptions

func (*Cluster) InvertIndexHosts

func (c *Cluster) InvertIndexHosts() error

func (*Cluster) PrePullK8sImages added in v0.1.1

func (c *Cluster) PrePullK8sImages(ctx context.Context) error

func (*Cluster) RemoveOldNodes added in v0.2.0

func (c *Cluster) RemoveOldNodes(ctx context.Context) error

func (*Cluster) RestoreEtcdSnapshot added in v0.1.7

func (c *Cluster) RestoreEtcdSnapshot(ctx context.Context, snapshotPath string) error

func (*Cluster) SetUpHosts

func (c *Cluster) SetUpHosts(ctx context.Context, rotateCerts bool) error

func (*Cluster) SetupDialers added in v0.2.0

func (c *Cluster) SetupDialers(ctx context.Context, dailersOptions hosts.DialersOptions) error

func (*Cluster) SnapshotEtcd added in v0.1.7

func (c *Cluster) SnapshotEtcd(ctx context.Context, snapshotName string) error

func (*Cluster) StoreAddonConfigMap

func (c *Cluster) StoreAddonConfigMap(ctx context.Context, addonYaml string, addonName string) (bool, error)

func (*Cluster) SyncLabelsAndTaints added in v0.1.1

func (c *Cluster) SyncLabelsAndTaints(ctx context.Context, currentCluster *Cluster) error

func (*Cluster) TunnelHosts

func (c *Cluster) TunnelHosts(ctx context.Context, flags ExternalFlags) error

func (*Cluster) UpdateClusterCurrentState added in v0.2.0

func (c *Cluster) UpdateClusterCurrentState(ctx context.Context, fullState *FullState) error

func (*Cluster) ValidateCluster

func (c *Cluster) ValidateCluster() error

type ExternalFlags added in v0.2.0

type ExternalFlags struct {
	ConfigDir        string
	ClusterFilePath  string
	DisablePortCheck bool
	Local            bool
	UpdateOnly       bool
}

func GetExternalFlags added in v0.2.0

func GetExternalFlags(local, updateOnly, disablePortCheck bool, configDir, clusterFilePath string) ExternalFlags

type FullState added in v0.2.0

type FullState struct {
	DesiredState State `json:"desiredState,omitempty"`
	CurrentState State `json:"currentState,omitempty"`
}

func ReadStateFile added in v0.2.0

func ReadStateFile(ctx context.Context, statePath string) (*FullState, error)

func RebuildState added in v0.2.0

func RebuildState(ctx context.Context, rkeConfig *v3.RancherKubernetesEngineConfig, oldState *FullState, flags ExternalFlags) (*FullState, error)

func (*FullState) WriteStateFile added in v0.2.0

func (s *FullState) WriteStateFile(ctx context.Context, statePath string) error

type MetricsServerOptions added in v0.1.9

type MetricsServerOptions struct {
	RBACConfig         string
	Options            map[string]string
	MetricsServerImage string
	Version            string
}

type RotateCertificatesFlags

type RotateCertificatesFlags struct {
	RotateCACerts    bool
	RotateComponents []string
}

func GetRotateCertsFlags

func GetRotateCertsFlags(rotateCACerts bool, components []string) RotateCertificatesFlags

type State added in v0.2.0

type State struct {
	RancherKubernetesEngineConfig *v3.RancherKubernetesEngineConfig `json:"rkeConfig,omitempty"`
	CertificatesBundle            map[string]pki.CertificatePKI     `json:"certificatesBundle,omitempty"`
}

Jump to

Keyboard shortcuts

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