core

package
v0.0.0-...-f45d039 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2020 License: Apache-2.0 Imports: 35 Imported by: 1

Documentation

Index

Constants

View Source
const (
	NginxIngressAddonAppName = "ingress-nginx"
	CoreDNSAddonAppName      = "coredns"
)
View Source
const (
	PortCheckContainer        = "zke-port-checker"
	EtcdPortListenContainer   = "zke-etcd-port-listener"
	CPPortListenContainer     = "zke-cp-port-listener"
	WorkerPortListenContainer = "zke-worker-port-listener"

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

	ProtocolTCP = "TCP"
	ProtocolUDP = "UDP"

	NoNetworkPlugin = "none"

	FlannelNetworkPlugin = "flannel"
	CalicoNetworkPlugin  = "calico"
	CalicoCloudProvider  = "calico_cloud_provider"
	FlannelInterface     = "FlannelInterface"
	FlannelBackend       = "FlannelBackend"

	FlannelIface                = "flannel_iface"
	FlannelBackendType          = "flannel_backend_type"
	FlannelBackendDirectrouting = "flannel_vxlan_directrouting"

	// EtcdEndpoints is the server address for Etcd, used by calico
	EtcdEndpoints = "EtcdEndpoints"
	// APIRoot is the kubernetes API address
	APIRoot = "APIRoot"
	// kubernetes client certificates and kubeconfig paths
	EtcdClientCert     = "EtcdClientCert"
	EtcdClientKey      = "EtcdClientKey"
	EtcdClientCA       = "EtcdClientCA"
	EtcdClientCertPath = "EtcdClientCertPath"
	EtcdClientKeyPath  = "EtcdClientKeyPath"
	EtcdClientCAPath   = "EtcdClientCAPath"

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

	RBACConfig     = "RBACConfig"
	ClusterVersion = "ClusterVersion"
)
View Source
const (
	AuthnX509Provider       = "x509"
	AuthnWebhookProvider    = "webhook"
	StateConfigMapName      = "cluster-state"
	ClusterConfigMapName    = "cluster-config"
	UpdateStateTimeout      = 30
	GetStateTimeout         = 30
	KubernetesClientTimeOut = 30
	NoneAuthorizationMode   = "none"
	LocalNodeAddress        = "127.0.0.1"
	LocalNodeHostname       = "localhost"
	LocalNodeUser           = "root"
	ControlPlane            = "controlPlane"
	WorkerPlane             = "workerPlan"
	EtcdPlane               = "etcd"

	KubeAppLabel = "k8s-app"
	AppLabel     = "app"
	NameLabel    = "name"
)
View Source
const (
	DefaultSSHUser        = "zcloud"
	DefaultSSHPort        = "22"
	DefaultSSHKeyPath     = "~/.ssh/id_rsa"
	DefaultDockerSockPath = "/var/run/docker.sock"

	DefaultClusterName           = "local"
	DefaultK8sVersion            = types.DefaultK8s
	DefaultServiceClusterIPRange = "10.43.0.0/16"
	DefaultClusterCIDR           = "10.42.0.0/16"
	DefaultNodePortRange         = "30000-32767"
	DefaultClusterDomain         = "cluster.local"
	DefaultClusterDNSService     = "10.43.0.10"

	DefaultNetworkPlugin      = "flannel"
	DefaultFlannelBackendType = "vxlan"

	DefaultDNSProvider       = "coredns"
	DefaultAuthStrategy      = "x509"
	DefaultAuthorizationMode = "rbac"

	DefaultIngressController             = "nginx"
	DefaultEtcdBackupCreationPeriod      = "12h"
	DefaultEtcdBackupRetentionPeriod     = "72h"
	DefaultEtcdSnapshot                  = true
	DefaultEtcdBackupConfigIntervalHours = 12
	DefaultEtcdBackupConfigRetention     = 6

	DefaultEtcdHeartbeatIntervalName  = "heartbeat-interval"
	DefaultEtcdHeartbeatIntervalValue = "500"
	DefaultEtcdElectionTimeoutName    = "election-timeout"
	DefaultEtcdElectionTimeoutValue   = "5000"

	DefaultMonitorMetricsProvider = "metrics-server"

	DefaultIngressNodeSelector = "node-role.kubernetes.io/edge"

	DefaultAuthnWebhookFile = `` /* 321-byte string literal not displayed */

	DefaultAuthnCacheTimeout = "5s"
	DefaultConfigVersion     = "v1.0.10"
)
View Source
const (
	ContainerName = "file-deployer"
	ServiceName   = "file-deploy"
	ConfigEnv     = "FILE_DEPLOY"
)
View Source
const (
	EtcdPathPrefix     = "/registry"
	ContainerNameLabel = "zcloud.cn.zke.container.name"
	CloudConfigSumEnv  = "ZKE_CLOUD_CONFIG_CHECKSUM"

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

	KubeletDockerConfigEnv     = "ZKE_KUBELET_DOCKER_CONFIG"
	KubeletDockerConfigFileEnv = "ZKE_KUBELET_DOCKER_FILE"
	KubeletDockerConfigPath    = "/var/lib/kubelet/config.json"
)
View Source
const (
	SupportedSyncToolsVersion = "0.1.22"
)

Variables

View Source
var ControlPlanePortList = []string{
	KubeAPIPort,
}
View Source
var DefaultUpstreamDNS = []string{"114.114.114.114", "223.5.5.5"}
View Source
var EtcdClientPortList = []string{
	EtcdPort1,
}
View Source
var EtcdPortList = []string{
	EtcdPort1,
	EtcdPort2,
	EtcdPort3,
}
View Source
var WorkerPortList = []string{
	KubeletPort,
}

Functions

func ApplyAuthzResources

func ApplyAuthzResources(ctx context.Context, zkeConfig types.ZKEConfig, k8sClient *kubernetes.Clientset, dailersOptions hosts.DialersOptions) error

func BuildPortChecksFromPortList

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

func BuildZKEConfigNodePlan

func BuildZKEConfigNodePlan(ctx context.Context, myCluster *Cluster, host *hosts.Host, hostDockerInfo dockertypes.Info) types.ZKENodePlan

func CheckEtcdHostsChanged

func CheckEtcdHostsChanged(kubeCluster, currentCluster *Cluster) error

func GetAddonsExecuteJob

func GetAddonsExecuteJob(addonName, nodeName, image string) (string, error)

func GetK8sVersion

func GetK8sVersion(ctx context.Context, k8sClient *kubernetes.Clientset) (string, error)

func GetTagMajorVersion

func GetTagMajorVersion(tag string) string

func ParseConfig

func ParseConfig(ctx context.Context, clusterFile string) (*types.ZKEConfig, error)

func RebuildKubeconfig

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

func ReconcileCluster

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

func RestartClusterPods

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

func SaveZKEConfigToKubernetes

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

func SetUpAuthentication

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

func ValidateHostCount

func ValidateHostCount(c *Cluster) error

Types

type AddonError

type AddonError struct {
	IsCritical bool
	// contains filtered or unexported fields
}

func (*AddonError) Error

func (e *AddonError) Error() string

type Cluster

type Cluster struct {
	types.ZKEConfig      `yaml:",inline"`
	KubeConfig           string
	AuthnStrategies      map[string]bool
	Certificates         map[string]pki.CertificatePKI
	DockerDialerFactory  hosts.DialerFactory
	K8sWrapTransport     k8s.WrapTransport
	KubeClient           *kubernetes.Clientset
	KubernetesServiceIP  net.IP
	PrivateRegistriesMap map[string]types.PrivateRegistry
	ControlPlaneHosts    []*hosts.Host
	EtcdHosts            []*hosts.Host
	EtcdReadyHosts       []*hosts.Host
	InactiveHosts        []*hosts.Host
	WorkerHosts          []*hosts.Host
	EdgeHosts            []*hosts.Host
}

func InitClusterObject

func InitClusterObject(ctx context.Context, zkeConfig *types.ZKEConfig) (*Cluster, error)

func (*Cluster) ApplySystemAddonExecuteJob

func (c *Cluster) ApplySystemAddonExecuteJob(ctx context.Context, addonJob string, addonUpdated bool) error

func (*Cluster) BuildEtcdProcess

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

func (*Cluster) BuildKubeAPIProcess

func (c *Cluster) BuildKubeAPIProcess(host *hosts.Host, prefixPath string) types.Process

func (*Cluster) BuildKubeControllerProcess

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

func (*Cluster) BuildKubeProxyProcess

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

func (*Cluster) BuildKubeletProcess

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

func (*Cluster) BuildProxyProcess

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

func (*Cluster) BuildSchedulerProcess

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

func (*Cluster) BuildSidecarProcess

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

func (*Cluster) CheckClusterPorts

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

func (*Cluster) CleanDeadLogs

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

func (*Cluster) CleanupFiles

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

func (*Cluster) CleanupNodes

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) DoAddonDeploy

func (c *Cluster) DoAddonDeploy(ctx context.Context, addonYaml, resourceName string, IsCritical bool) error

func (*Cluster) GetClusterState

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

func (*Cluster) GetHostInfoMap

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

func (*Cluster) GetKubernetesServicesOptions

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

func (*Cluster) InvertIndexHosts

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

func (*Cluster) PrePullK8sImages

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

func (*Cluster) PrepareBackup

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

func (*Cluster) RemoveOldNodes

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

func (*Cluster) RestoreEtcdSnapshot

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

func (*Cluster) SetUpHosts

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

func (*Cluster) SetupDialers

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

func (*Cluster) SnapshotEtcd

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

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

func (*Cluster) TunnelHosts

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

func (*Cluster) UpdateClusterCurrentState

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

func (*Cluster) UpdateClusterCurrentStateForSingleCloud

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

func (*Cluster) ValidateCluster

func (c *Cluster) ValidateCluster() error

type FullState

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

func ReadStateFile

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

func RebuildState

func RebuildState(ctx context.Context, zkeConfig *types.ZKEConfig, oldState *FullState) (*FullState, error)

func (*FullState) WriteStateFile

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

type State

type State struct {
	ZKEConfig          *types.ZKEConfig              `json:"zkeConfig,omitempty"`
	CertificatesBundle map[string]pki.CertificatePKI `json:"certificatesBundle,omitempty"`
}

Directories

Path Synopsis
pki

Jump to

Keyboard shortcuts

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