protokube

package
v1.20.1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: Apache-2.0 Imports: 65 Imported by: 93

Documentation

Index

Constants

View Source
const (
	// KubeProxyClusterRoleName sets the name for the kube-proxy ClusterRole
	KubeProxyClusterRoleName = "system:node-proxier"

	// Constants for what we name our ServiceAccounts with limited access to the cluster in case of RBAC
	KubeDNSServiceAccountName   = "kube-dns"
	KubeProxyServiceAccountName = "kube-proxy"
)

The below code should mirror the code in kubeadm. We'll develop it here then contribute it back once they are out of core - otherwise it is using the wrong version of the k8s client.

View Source
const MetadataLatest string = "http://169.254.169.254/openstack/latest/meta_data.json"
View Source
const TaintsAnnotationKey string = "scheduler.alpha.kubernetes.io/taints"

TaintsAnnotationKey represents the key of taints data (json serialized) in the Annotations of a Node. Note that this is for k8s <= 1.5 only

Variables

View Source
var (
	// Containerized indicates the etcd is containerized
	Containerized = false
	// RootFS is the root fs path
	RootFS = "/"
)

Functions

func BuildEtcdManifest added in v1.10.0

func BuildEtcdManifest(c *EtcdCluster) *v1.Pod

BuildEtcdManifest creates the pod spec, based on the etcd cluster

func DebugString

func DebugString(o interface{}) string

func GetClusterID added in v1.16.0

func GetClusterID() (string, error)

func GetDropletInternalIP added in v1.10.0

func GetDropletInternalIP() (net.IP, error)

GetDropletInternalIP gets the private IP of the droplet running this program This function is exported so it can be called from protokube

Types

type ALIVolumes added in v1.15.1

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

ALIVolumes is the Volumes implementation for Aliyun ECS

func NewALIVolumes added in v1.15.1

func NewALIVolumes() (*ALIVolumes, error)

func (*ALIVolumes) AttachVolume added in v1.15.1

func (a *ALIVolumes) AttachVolume(volume *Volume) error

AttachVolume attaches the specified volume to this instance, returning the mountpoint & nil if successful

func (*ALIVolumes) ClusterID added in v1.15.1

func (a *ALIVolumes) ClusterID() string

ClusterID implements Volumes ClusterID

func (*ALIVolumes) FindMountedVolume added in v1.15.1

func (a *ALIVolumes) FindMountedVolume(volume *Volume) (string, error)

FindMountedVolume implements Volumes::FindMountedVolume

func (*ALIVolumes) FindVolumes added in v1.15.1

func (a *ALIVolumes) FindVolumes() ([]*Volume, error)

func (*ALIVolumes) GossipSeeds added in v1.15.1

func (a *ALIVolumes) GossipSeeds() (gossip.SeedProvider, error)

func (*ALIVolumes) InstanceID added in v1.15.1

func (a *ALIVolumes) InstanceID() string

InstanceID implements Volumes InstanceID

func (*ALIVolumes) InternalIP added in v1.15.1

func (a *ALIVolumes) InternalIP() net.IP

InternalIP implements Volumes InternalIP

type AWSVolumes

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

AWSVolumes defines the aws volume implementation

func NewAWSVolumes

func NewAWSVolumes() (*AWSVolumes, error)

NewAWSVolumes returns a new aws volume provider

func (*AWSVolumes) AttachVolume

func (a *AWSVolumes) AttachVolume(volume *Volume) error

AttachVolume attaches the specified volume to this instance, returning the mountpoint & nil if successful

func (*AWSVolumes) ClusterID

func (a *AWSVolumes) ClusterID() string

func (*AWSVolumes) FindMountedVolume added in v1.10.0

func (v *AWSVolumes) FindMountedVolume(volume *Volume) (string, error)

FindMountedVolume implements Volumes::FindMountedVolume

func (*AWSVolumes) FindVolumes

func (a *AWSVolumes) FindVolumes() ([]*Volume, error)

func (*AWSVolumes) GossipSeeds added in v1.10.0

func (a *AWSVolumes) GossipSeeds() (gossip.SeedProvider, error)

func (*AWSVolumes) InstanceID added in v1.10.0

func (a *AWSVolumes) InstanceID() string

func (*AWSVolumes) InternalIP

func (a *AWSVolumes) InternalIP() net.IP

type AzureVolumes added in v1.20.0

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

AzureVolumes implements the Volumes interface for Azure.

func NewAzureVolumes added in v1.20.0

func NewAzureVolumes() (*AzureVolumes, error)

NewAzureVolumes returns a new AzureVolumes.

func (*AzureVolumes) AttachVolume added in v1.20.0

func (a *AzureVolumes) AttachVolume(volume *Volume) error

func (*AzureVolumes) ClusterID added in v1.20.0

func (a *AzureVolumes) ClusterID() string

ClusterID implements Volumes ClusterID.

func (*AzureVolumes) FindMountedVolume added in v1.20.0

func (a *AzureVolumes) FindMountedVolume(volume *Volume) (string, error)

func (*AzureVolumes) FindVolumes added in v1.20.0

func (a *AzureVolumes) FindVolumes() ([]*Volume, error)

func (*AzureVolumes) GossipSeeds added in v1.20.0

func (a *AzureVolumes) GossipSeeds() (gossip.SeedProvider, error)

func (*AzureVolumes) InstanceID added in v1.20.0

func (a *AzureVolumes) InstanceID() string

InstanceID implements Volumes InstanceID.

func (*AzureVolumes) InternalIP added in v1.20.0

func (a *AzureVolumes) InternalIP() net.IP

InternalIP implements Volumes InternalIP.

type ByEtcdClusterName added in v1.10.0

type ByEtcdClusterName []*Volume

ByEtcdClusterName sorts volumes so that we mount in a consistent order, and in addition we try to mount the main etcd volume before the events etcd volume

func (ByEtcdClusterName) Len added in v1.10.0

func (a ByEtcdClusterName) Len() int

func (ByEtcdClusterName) Less added in v1.10.0

func (a ByEtcdClusterName) Less(i, j int) bool

func (ByEtcdClusterName) Swap added in v1.10.0

func (a ByEtcdClusterName) Swap(i, j int)

type DNSProvider

type DNSProvider interface {
	Replace(fqdn string, values []string) error

	// RemoveRecordsImmediate deletes the specified DNS records, without batching etc
	RemoveRecordsImmediate(records []dns.Record) error

	Run()
}

type DOVolumes added in v1.10.0

type DOVolumes struct {
	ClusterID string
	Cloud     *digitalocean.Cloud
	// contains filtered or unexported fields
}

func NewDOVolumes added in v1.10.0

func NewDOVolumes() (*DOVolumes, error)

func (*DOVolumes) AttachVolume added in v1.10.0

func (d *DOVolumes) AttachVolume(volume *Volume) error

func (*DOVolumes) FindMountedVolume added in v1.10.0

func (d *DOVolumes) FindMountedVolume(volume *Volume) (string, error)

func (*DOVolumes) FindVolumes added in v1.10.0

func (d *DOVolumes) FindVolumes() ([]*Volume, error)

func (*DOVolumes) GossipSeeds added in v1.16.0

func (d *DOVolumes) GossipSeeds() (gossip.SeedProvider, error)

func (*DOVolumes) InstanceName added in v1.16.0

func (d *DOVolumes) InstanceName() string

type EtcdCluster

type EtcdCluster struct {
	// ClientPort is the incoming ports for client
	ClientPort int
	// ClusterName is the cluster name
	ClusterName string
	// ClusterToken is the cluster token
	ClusterToken string
	// CPURequest is the pod request for CPU
	CPURequest *resource.Quantity
	// MemoryRequest is the pod request for Memory
	MemoryRequest *resource.Quantity
	// DataDirName is the path to the data directory
	DataDirName string
	// ImageSource is the docker image to use
	ImageSource string
	// LogFile is the location of the logfile
	LogFile string
	// Me is the node that we will be in the cluster
	Me *EtcdNode
	// Nodes is a list of nodes in the cluster (including the self-node, Me)
	Nodes []*EtcdNode
	// PeerPort is the port for peers to connect
	PeerPort int
	// PodName is the name given to the pod
	PodName string
	// ProxyMode indicates we are running in proxy mode
	ProxyMode bool
	// Spec is the specification found from the volumes
	Spec *etcd.EtcdClusterSpec
	// VolumeMountPath is the mount path
	VolumeMountPath string
	// TLSAuth indicates we should enforce peer and client verification
	TLSAuth bool
	// TLSCA is the path to a client ca for etcd clients
	TLSCA string
	// TLSCert is the path to a client certificate for etcd
	TLSCert string
	// TLSKey is the path to a client private key for etcd
	TLSKey string
	// PeerCA is the path to a peer ca for etcd
	PeerCA string
	// PeerCert is the path to a peer ca for etcd
	PeerCert string
	// PeerKey is the path to a peer ca for etcd
	PeerKey string
	// ElectionTimeout is the leader election timeout
	ElectionTimeout string
	// HeartbeatInterval is the heartbeat interval
	HeartbeatInterval string
	// BackupImage is the image to use for backing up etcd
	BackupImage string
	// BackupStore is a VFS path for backing up etcd
	BackupStore string
}

EtcdCluster is the configuration for the etcd cluster

func (*EtcdCluster) String

func (c *EtcdCluster) String() string

String returns the debug string

type EtcdController

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

EtcdController defines the etcd controller

func (*EtcdController) RunSyncLoop

func (k *EtcdController) RunSyncLoop()

RunSyncLoop is responsible for managing the etcd sign loop

type EtcdNode

type EtcdNode struct {
	Name         string
	InternalName string
}

EtcdNode is a definition for the etcd node

func (*EtcdNode) String

func (e *EtcdNode) String() string

type GCEVolumes added in v1.10.0

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

GCEVolumes is the Volumes implementation for GCE

func NewGCEVolumes added in v1.10.0

func NewGCEVolumes() (*GCEVolumes, error)

NewGCEVolumes builds a GCEVolumes

func (*GCEVolumes) AttachVolume added in v1.10.0

func (v *GCEVolumes) AttachVolume(volume *Volume) error

AttachVolume attaches the specified volume to this instance, returning the mountpoint & nil if successful

func (*GCEVolumes) ClusterID added in v1.10.0

func (a *GCEVolumes) ClusterID() string

ClusterID implements Volumes ClusterID

func (*GCEVolumes) FindMountedVolume added in v1.10.0

func (v *GCEVolumes) FindMountedVolume(volume *Volume) (string, error)

FindMountedVolume implements Volumes::FindMountedVolume

func (*GCEVolumes) FindVolumes added in v1.10.0

func (v *GCEVolumes) FindVolumes() ([]*Volume, error)

func (*GCEVolumes) GossipSeeds added in v1.10.0

func (g *GCEVolumes) GossipSeeds() (gossip.SeedProvider, error)

func (*GCEVolumes) InstanceName added in v1.10.0

func (g *GCEVolumes) InstanceName() string

func (*GCEVolumes) InternalIP added in v1.10.0

func (a *GCEVolumes) InternalIP() net.IP

InternalIP implements Volumes InternalIP

func (*GCEVolumes) Project added in v1.10.0

func (a *GCEVolumes) Project() string

Project returns the current GCE project

type GossipDnsProvider added in v1.10.0

type GossipDnsProvider struct {
	DNSView *dns.DNSView
	Zone    dns.DNSZoneInfo
}

func (*GossipDnsProvider) RemoveRecordsImmediate added in v1.15.1

func (p *GossipDnsProvider) RemoveRecordsImmediate(records []k8sdns.Record) error

func (*GossipDnsProvider) Replace added in v1.10.0

func (p *GossipDnsProvider) Replace(fqdn string, values []string) error

func (*GossipDnsProvider) Run added in v1.10.0

func (p *GossipDnsProvider) Run()

type InstanceMetadata added in v1.15.1

type InstanceMetadata struct {
	Name             string    `json:"name"`
	UserMeta         *Metadata `json:"meta"`
	ProjectID        string    `json:"project_id"`
	AvailabilityZone string    `json:"availability_zone"`
	Hostname         string    `json:"hostname"`
	ServerID         string    `json:"uuid"`
}

type KopsDnsProvider added in v1.10.0

type KopsDnsProvider struct {
	DNSScope      dns.Scope
	DNSController *dns.DNSController
}

func (*KopsDnsProvider) RemoveRecordsImmediate added in v1.15.1

func (p *KopsDnsProvider) RemoveRecordsImmediate(records []dns.Record) error

func (*KopsDnsProvider) Replace added in v1.10.0

func (p *KopsDnsProvider) Replace(fqdn string, values []string) error

func (*KopsDnsProvider) Run added in v1.10.0

func (p *KopsDnsProvider) Run()

type KubeBoot

type KubeBoot struct {
	// Channels is a list of channel to apply
	Channels []string
	// InitializeRBAC should be set to true if we should create the core RBAC roles
	InitializeRBAC bool
	// InternalDNSSuffix is the dns zone we are living in
	InternalDNSSuffix string
	// InternalIP is the internal ip address of the node
	InternalIP net.IP
	// ApplyTaints controls whether we set taints based on the master label
	ApplyTaints bool
	// DNS is the dns provider
	DNS DNSProvider
	// ModelDir is the model directory
	ModelDir string
	// Kubernetes holds a kubernetes client
	Kubernetes *KubernetesContext
	// Master indicates we are a master node
	Master bool

	// ManageEtcd is true if we should manage etcd.
	// Deprecated in favor of etcd-manager.
	ManageEtcd bool
	// EtcdBackupImage is the image to use for backing up etcd
	EtcdBackupImage string
	// EtcdBackupStore is the VFS path to which we should backup etcd
	EtcdBackupStore string
	// Etcd container registry location.
	EtcdImageSource string
	// EtcdElectionTimeout is the leader election timeout
	EtcdElectionTimeout string
	// EtcdHeartbeatInterval is the heartbeat interval
	EtcdHeartbeatInterval string
	// TLSAuth indicates we should enforce peer and client verification
	TLSAuth bool
	// TLSCA is the path to a client ca for etcd
	TLSCA string
	// TLSCert is the path to a tls certificate for etcd
	TLSCert string
	// TLSKey is the path to a tls private key for etcd
	TLSKey string
	// PeerCA is the path to a peer ca for etcd
	PeerCA string
	// PeerCert is the path to a peer certificate for etcd
	PeerCert string
	// PeerKey is the path to a peer private key for etcd
	PeerKey string

	// BootstrapMasterNodeLabels controls the initial application of node labels to our node
	// The node is found by matching NodeName
	BootstrapMasterNodeLabels bool

	// NodeName is the name of our node as it will be registered in k8s.
	// Used by BootstrapMasterNodeLabels
	NodeName string
	// contains filtered or unexported fields
}

KubeBoot is the options for the protokube service

func (*KubeBoot) BuildInternalDNSName

func (k *KubeBoot) BuildInternalDNSName(key string) string

BuildInternalDNSName builds a DNS name for use inside the cluster, adding our internal DNS suffix to the key

func (*KubeBoot) CreateInternalDNSNameRecord

func (k *KubeBoot) CreateInternalDNSNameRecord(fqdn string) error

CreateInternalDNSNameRecord maps a FQDN to the internal IP address of the current machine

func (*KubeBoot) Init

func (k *KubeBoot) Init(volumesProvider Volumes)

Init is responsible for initializing the controllers

func (*KubeBoot) RunSyncLoop

func (k *KubeBoot) RunSyncLoop()

RunSyncLoop is responsible for provision the cluster

func (*KubeBoot) String

func (k *KubeBoot) String() string

type KubernetesContext

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

KubernetesContext is the kubernetes context

func NewKubernetesContext

func NewKubernetesContext() *KubernetesContext

NewKubernetesContext returns a new KubernetesContext

func (*KubernetesContext) KubernetesClient

func (c *KubernetesContext) KubernetesClient() (kubernetes.Interface, error)

KubernetesClient returns a new kubernetes api client

type Metadata added in v1.15.1

type Metadata struct {
	// Matches openstack.TagClusterName
	ClusterName string `json:"KubernetesCluster"`
}

type OpenstackVolumes added in v1.15.1

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

GCEVolumes is the Volumes implementation for GCE

func NewOpenstackVolumes added in v1.15.1

func NewOpenstackVolumes() (*OpenstackVolumes, error)

NewOpenstackVolumes builds a OpenstackVolume

func (*OpenstackVolumes) AttachVolume added in v1.15.1

func (v *OpenstackVolumes) AttachVolume(volume *Volume) error

AttachVolume attaches the specified volume to this instance, returning the mountpoint & nil if successful

func (*OpenstackVolumes) ClusterID added in v1.15.1

func (a *OpenstackVolumes) ClusterID() string

ClusterID implements Volumes ClusterID

func (*OpenstackVolumes) FindMountedVolume added in v1.15.1

func (v *OpenstackVolumes) FindMountedVolume(volume *Volume) (string, error)

FindMountedVolume implements Volumes::FindMountedVolume

func (*OpenstackVolumes) FindVolumes added in v1.15.1

func (v *OpenstackVolumes) FindVolumes() ([]*Volume, error)

func (*OpenstackVolumes) GossipSeeds added in v1.15.1

func (g *OpenstackVolumes) GossipSeeds() (gossip.SeedProvider, error)

func (*OpenstackVolumes) InstanceName added in v1.15.1

func (g *OpenstackVolumes) InstanceName() string

func (*OpenstackVolumes) InternalIP added in v1.15.1

func (a *OpenstackVolumes) InternalIP() net.IP

InternalIP implements Volumes InternalIP

func (*OpenstackVolumes) Project added in v1.15.1

func (a *OpenstackVolumes) Project() string

Project returns the current GCE project

type Volume

type Volume struct {
	// ID is the cloud-provider identifier for the volume
	ID string

	// LocalDevice is set if the volume is attached to the local machine
	LocalDevice string

	// AttachedTo is set to the ID of the machine the volume is attached to, or "" if not attached
	AttachedTo string

	// Mountpoint is the path on which the volume is mounted, if mounted
	// It will likely be "/mnt/master-" + ID
	Mountpoint string

	// Status is a volume provider specific Status string; it makes it easier for the volume provider
	Status string

	Info VolumeInfo
}

func (*Volume) String

func (v *Volume) String() string

type VolumeInfo

type VolumeInfo struct {
	Description string
	//MasterID    int
	// TODO: Maybe the events cluster can just be a PetSet - do we need it for boot?
	EtcdClusters []*etcd.EtcdClusterSpec
}

func (*VolumeInfo) String

func (v *VolumeInfo) String() string

type VolumeMountController

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

type Volumes

type Volumes interface {
	AttachVolume(volume *Volume) error
	FindVolumes() ([]*Volume, error)

	// FindMountedVolume returns the device (e.g. /dev/sda) where the volume is mounted
	// If not found, it returns "", nil
	// On error, it returns "", err
	FindMountedVolume(volume *Volume) (device string, err error)
}

Jump to

Keyboard shortcuts

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