protokube

package
v0.0.0-...-0147870 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: Apache-2.0 Imports: 66 Imported by: 0

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 (
	VolumeMetaDataFile = "/vol-metadata/metadata.json"
	VolStatusValue     = "attached"
)
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

func BuildEtcdManifest(c *EtcdCluster) *v1.Pod

BuildEtcdManifest creates the pod spec, based on the etcd cluster

func DebugString

func DebugString(o interface{}) string

func ExecuteTemplate

func ExecuteTemplate(key string, templateDefinition string, model interface{}) ([]byte, error)

ExecuteTemplate renders the specified template with the model

func GetDropletInternalIP

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

func NewNsEnterExec

func NewNsEnterExec() mount.Exec

NewNsEnterExec builds a mount.Exec implementation that nsenters into the host process It is very similar to mount.NewNsenterMounter, but execs into the host

Types

type ALIVolumes

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

ALIVolumes is the Volumes implementation for Aliyun ECS

func NewALIVolumes

func NewALIVolumes() (*ALIVolumes, error)

func (*ALIVolumes) AttachVolume

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

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

func (*ALIVolumes) ClusterID

func (a *ALIVolumes) ClusterID() string

ClusterID implements Volumes ClusterID

func (*ALIVolumes) FindMountedVolume

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

FindMountedVolume implements Volumes::FindMountedVolume

func (*ALIVolumes) FindVolumes

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

func (*ALIVolumes) GossipSeeds

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

func (*ALIVolumes) InstanceID

func (a *ALIVolumes) InstanceID() string

InstanceID implements Volumes InstanceID

func (*ALIVolumes) InternalIP

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

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

FindMountedVolume implements Volumes::FindMountedVolume

func (*AWSVolumes) FindVolumes

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

func (*AWSVolumes) GossipSeeds

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

func (*AWSVolumes) InstanceID

func (a *AWSVolumes) InstanceID() string

func (*AWSVolumes) InternalIP

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

type ByEtcdClusterName

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

func (a ByEtcdClusterName) Len() int

func (ByEtcdClusterName) Less

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

func (ByEtcdClusterName) Swap

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

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

func NewDOVolumes

func NewDOVolumes(clusterID string) (*DOVolumes, error)

func (*DOVolumes) AttachVolume

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

func (*DOVolumes) FindMountedVolume

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

func (*DOVolumes) FindVolumes

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

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

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

GCEVolumes is the Volumes implementation for GCE

func NewGCEVolumes

func NewGCEVolumes() (*GCEVolumes, error)

NewGCEVolumes builds a GCEVolumes

func (*GCEVolumes) AttachVolume

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

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

func (*GCEVolumes) ClusterID

func (a *GCEVolumes) ClusterID() string

ClusterID implements Volumes ClusterID

func (*GCEVolumes) FindMountedVolume

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

FindMountedVolume implements Volumes::FindMountedVolume

func (*GCEVolumes) FindVolumes

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

func (*GCEVolumes) GossipSeeds

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

func (*GCEVolumes) InstanceName

func (g *GCEVolumes) InstanceName() string

func (*GCEVolumes) InternalIP

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

InternalIP implements Volumes InternalIP

func (*GCEVolumes) Project

func (a *GCEVolumes) Project() string

Project returns the current GCE project

type GossipDnsProvider

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

func (*GossipDnsProvider) RemoveRecordsImmediate

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

func (*GossipDnsProvider) Replace

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

func (*GossipDnsProvider) Run

func (p *GossipDnsProvider) Run()

type InstanceMetadata

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

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

func (*KopsDnsProvider) RemoveRecordsImmediate

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

func (*KopsDnsProvider) Replace

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

func (*KopsDnsProvider) Run

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 is the context methods for kubernetes
	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
	// 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

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

type OpenstackVolumes

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

GCEVolumes is the Volumes implementation for GCE

func NewOpenstackVolumes

func NewOpenstackVolumes() (*OpenstackVolumes, error)

NewOpenstackVolumes builds a OpenstackVolume

func (*OpenstackVolumes) AttachVolume

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

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

func (*OpenstackVolumes) ClusterID

func (a *OpenstackVolumes) ClusterID() string

ClusterID implements Volumes ClusterID

func (*OpenstackVolumes) FindMountedVolume

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

FindMountedVolume implements Volumes::FindMountedVolume

func (*OpenstackVolumes) FindVolumes

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

func (*OpenstackVolumes) GossipSeeds

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

func (*OpenstackVolumes) InstanceName

func (g *OpenstackVolumes) InstanceName() string

func (*OpenstackVolumes) InternalIP

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

InternalIP implements Volumes InternalIP

func (*OpenstackVolumes) Project

func (a *OpenstackVolumes) Project() string

Project returns the current GCE project

type VSphereVolumes

type VSphereVolumes struct{}

VSphereVolumes represents vSphere volume and implements Volumes interface.

func NewVSphereVolumes

func NewVSphereVolumes() (*VSphereVolumes, error)

NewVSphereVolumes returns instance of VSphereVolumes type.

func (*VSphereVolumes) AttachVolume

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

AttachVolume attaches given volume. In case of vSphere, volumes are statically mounted, so no operation is performed.

func (*VSphereVolumes) FindMountedVolume

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

FindMountedVolume implements Volumes::FindMountedVolume

func (*VSphereVolumes) FindVolumes

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

FindVolumes returns Volume instances associated with this VSphereVolumes. EtcdClusterSpec is populated using vSphere volume metadata.

func (*VSphereVolumes) InternalIp

func (v *VSphereVolumes) InternalIp() net.IP

InternalIp returns IP of machine associated with this volume.

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