kluster

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2019 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GenericKeyPairName = "root_ca"
	APIServerCertName  = "node" // TODO: change it in the future to 'kube-node'
)

GenericKeyPairName is the name of the generic key pair

View Source
const (
	DefaultFormat         = "yaml"
	DefaultConfigFilename = "cluster"
	CertificatesDirname   = "certificates"
	TerraformDirname      = "terraform"
	KubernetesDirname     = "kubernetes"
	StateDirname          = ".tfstate"
	RegistryDirname       = "registries"
)

DefaultFormat is the default format for the Kubernetes Cluster (Kluster) configuration file. The options are: yaml, json and toml This format will be used for the file extension, so use a short or extension-like format name

View Source
const CredentialsFileName = ".credentials"

CredentialsFileName is the filename to store the credentials

View Source
const KubeconfigEKSTmpl = `` /* 459-byte string literal not displayed */

KubeconfigEKSTmpl is the kubeconfig template for EKS

View Source
const KubeconfigTmpl = `` /* 526-byte string literal not displayed */

KubeconfigTmpl is the kubeconfig template

Variables

View Source
var (
	// Version is the cluster configuration version this KubeKit creates. Greater
	// versions are not supported.
	Version = "1.1"

	// MinVersion is the cluster configuration file minimum version
	// accepted by this version of KubeKit. If a cluster config file with a lower
	// version is provided by the user, that cluster config file is rejected.
	MinVersion = "1.0"

	// SemVersion is the value of Version in version.SemVer type.
	SemVersion *version.SemVer

	// MinSemVersion is same as MinVersion but as SemVer
	MinSemVersion *version.SemVer
)

AllStatuses contain all the statuses in one variable

View Source
var CACertNames = map[string]CACert{
	GenericKeyPairName: {CN: "kube-ca", Desc: "used to generate the server API certificate and also it's the generic one used by the non provided certificates"},
	"etcd_root_ca":     {CN: "etcd-ca", Desc: "used to generate the etcd certificates"},
	"ingress_root_ca":  {CN: "ingress-ca", Desc: "used to generate the ingress certificates"},
	"srv_acc":          {CN: "", Desc: ""},
}

CACertNames is a list of CA certificates (key and cert) the user can provide with the flags X-ca-{key,cert}-file. The certificate with key "root_ca" is the generic one. This is the CA certificate to use when the specific one is not given. i.e. if the API server certificate is not provided, KubeKit will use the generic cert. If the generic one is not provided, then the CA certificate will be self-signed. The description is used for the CLI flag 'X-ca-{key,cert}-file'

View Source
var CertNames = map[string]Cert{
	APIServerCertName: Cert{
		CN:     "kube-apiserver",
		FromCA: GenericKeyPairName,

		DNSNames: []string{
			"kubernetes",
			"kubernetes.default",
			"kubernetes.default.svc",
			"kubernetes.default.svc.cluster.local",
			"{{ registry }}",
			"{{ masters }}",
			"{{ ALB }}",
		},
		IPAddresses: []string{
			"172.21.0.1",
			"{{ VIP }}",
			"{{ masters }}",
		},
	},
	"kubelet": Cert{
		CN:     "system:node:{{ hostname }}",
		O:      "system:nodes",
		FromCA: GenericKeyPairName,
		DNSNames: []string{
			"kubernetes",
			"kubernetes.default",
			"kubernetes.default.svc",
			"kubernetes.default.svc.cluster.local",
			"{{ registry }}",
			"{{ masters }}",
			"{{ workers }}",
			"{{ ALB }}",
		},
		IPAddresses: []string{
			"172.21.0.1",
			"{{ VIP }}",
			"{{ masters }}",
			"{{ workers }}",
		},
	},
	"kube_proxy": Cert{
		CN:     "kube-proxy",
		FromCA: GenericKeyPairName,
		DNSNames: []string{
			"kubernetes",
			"kubernetes.default",
			"kubernetes.default.svc",
			"kubernetes.default.svc.cluster.local",
			"{{ registry }}",
			"{{ masters }}",
			"{{ workers }}",
			"{{ ALB }}",
		},
		IPAddresses: []string{
			"172.21.0.1",
			"{{ VIP }}",
			"{{ masters }}",
			"{{ workers }}",
		},
	},
	"kube_controller": Cert{
		CN:     "kube-controller-manager",
		FromCA: GenericKeyPairName,
		DNSNames: []string{
			"kubernetes",
			"kubernetes.default",
			"kubernetes.default.svc",
			"kubernetes.default.svc.cluster.local",
			"{{ registry }}",
			"{{ masters }}",
			"{{ ALB }}",
		},
		IPAddresses: []string{
			"172.21.0.1",
			"{{ VIP }}",
			"{{ masters }}",
		},
	},
	"kube_scheduler": Cert{
		CN:     "kube-scheduler",
		FromCA: GenericKeyPairName,
		DNSNames: []string{
			"kubernetes",
			"kubernetes.default",
			"kubernetes.default.svc",
			"kubernetes.default.svc.cluster.local",
			"{{ registry }}",
			"{{ masters }}",
			"{{ ALB }}",
		},
		IPAddresses: []string{
			"172.21.0.1",
			"{{ VIP }}",
			"{{ masters }}",
		},
	},
	"admin": Cert{
		CN:     "kube-apiserver",
		O:      "system:masters",
		FromCA: GenericKeyPairName,
		DNSNames: []string{
			"kubernetes",
			"kubernetes.default",
			"kubernetes.default.svc",
			"kubernetes.default.svc.cluster.local",
			"{{ registry }}",
			"{{ masters }}",
			"{{ workers }}",
			"{{ ALB }}",
		},
		IPAddresses: []string{
			"172.21.0.1",
			"{{ VIP }}",
			"{{ masters }}",
			"{{ workers }}",
		},
	},
	"etcd_node": Cert{
		CN:     "etcd",
		FromCA: "etcd_root_ca",
		DNSNames: []string{
			"kubernetes",
			"kubernetes.default",
			"kubernetes.default.svc",
			"kubernetes.default.svc.cluster.local",
			"{{ registry }}",
			"{{ masters }}",
			"{{ ALB }}",
		},
		IPAddresses: []string{
			"172.21.0.1",
			"{{ VIP }}",
			"{{ masters }}",
		},
		ExtKeyUsage: []x509.ExtKeyUsage{
			x509.ExtKeyUsageServerAuth,
			x509.ExtKeyUsageClientAuth,
		},
	},
	"ingress": Cert{
		CN:     "ingress",
		FromCA: "ingress_root_ca",
		DNSNames: []string{
			"{{ masters }}",
			"{{ workers }}",
			"{{ ingress_additional_dns_alt_names }}",
		},
		IPAddresses: []string{
			"{{ masters }}",
			"{{ workers }}",
			"{{ ingress_additional_dns_alt_ips }}",
		},
	},
	"opa": Cert{
		CN:     "opa",
		FromCA: GenericKeyPairName,
		DNSNames: []string{
			"opa",
			"opa.opa",
			"opa.opa.svc",
			"opa.opa.svc.cluster.local",
			"{{ masters }}",
			"{{ workers }}",
		},
		IPAddresses: []string{
			"172.21.0.1",
			"{{ masters }}",
			"{{ workers }}",
		},
	},
}

CertNames is a list of certificates to generate. Initially contain all the generated certificates but in 'cmd/configure.go' the certificates given by the user are included. If you which to add more certs, add it in cmd.CertNames at 'cmd/configure.go' and make sure the name does not contain 'ca'

Functions

func Ask

func Ask(title string, sensitive bool) (string, error)

Ask asks a query to the user

func AskDefault

func AskDefault(title, defValue string, sensitive bool) (string, error)

AskDefault asks to the user a query proposing a default value

func GetSession

func GetSession(creds map[string]string) (*session.Session, error)

GetSession creates an AWS session from the provided creds

func InvalidFilterParams

func InvalidFilterParams(params map[string]string) []string

InvalidFilterParams return a list of invalid filter parameters for clusters info

func IsValidFilter

func IsValidFilter(params map[string]string) bool

IsValidFilter returns true if one of the filter parameters for clusters info is not valid

func ListNames

func ListNames(path string) ([]string, error)

ListNames returns the list of Klusters name existing in the given directory

func NewPath

func NewPath(clustersPath string) (string, error)

NewPath generates a path for a new cluster

func Path

func Path(clusterName, path string) string

Path returns the path for a given cluster name that should be locates in the given clusters path. Returns an empty string if not found

func Unique

func Unique(clusterName, path string) bool

Unique checks if the given cluster name does not exists (it's unique) in the given cluster path.

func ValidClusterName

func ValidClusterName(clusterName string) (string, error)

ValidClusterName return a valid a cluster name. If the cluster name changed the error contain the changes, if it's not possible to fix returns the error and no name

Types

type AwsCredentials

type AwsCredentials struct {
	Platform     string `json:"platform" yaml:"platform" toml:"platform" mapstructure:"platform" env:"-"`
	AccessKey    string `json:"access_key" yaml:"access_key" toml:"access_key" mapstructure:"access_key" env:"ACCESS_KEY_ID"`
	SecretKey    string `json:"secret_key" yaml:"secret_key" toml:"secret_key" mapstructure:"secret_key" env:"SECRET_ACCESS_KEY"`
	SessionToken string `json:"session_token" yaml:"session_token" toml:"session_token" mapstructure:"session_token" env:"SESSION_TOKEN"`
	Region       string `json:"region" yaml:"region" toml:"region" mapstructure:"region" env:"DEFAULT_REGION"`
	Profile      string `json:"-" yaml:"-" toml:"-" mapstructure:"-" env:"PROFILE"`
	// contains filtered or unexported fields
}

AwsCredentials represents the credentials just for AWS

func NewAWSCredentials

func NewAWSCredentials(clustername, path string) *AwsCredentials

NewAWSCredentials creates an struct ready for AWS credentials

func (*AwsCredentials) Ask

func (c *AwsCredentials) Ask() error

Ask to the user from stdin the AWS credentials suggesting values from the environment

func (*AwsCredentials) AssignFromMap

func (c *AwsCredentials) AssignFromMap(params map[string]string) error

AssignFromMap sets the credentials parameters from a map. The key is the name of the parameter as defined in the json metadata of the AWSCredentials structure

func (*AwsCredentials) Complete

func (c *AwsCredentials) Complete() bool

Complete returns true if all credentials are set. Use it as !Complete() to know if there is a missing parameter. !Complete() is not Empty()

func (*AwsCredentials) Empty

func (c *AwsCredentials) Empty() bool

Empty returns true if there isn't any credentials set

func (*AwsCredentials) Getenv

func (c *AwsCredentials) Getenv(force bool) error

Getenv gets the AWS credentials from environment variables

func (*AwsCredentials) List

func (c *AwsCredentials) List()

List prints to stdout the AWS credentials in table format

func (*AwsCredentials) LoadSharedCredentialsFromProfile

func (c *AwsCredentials) LoadSharedCredentialsFromProfile(profile string, force bool) error

LoadSharedCredentialsFromProfile loads the AWS credentials from the AWS shared credentials file for the given profile

func (*AwsCredentials) LoadSharedRegionFromProfile

func (c *AwsCredentials) LoadSharedRegionFromProfile(profile string, force bool) error

LoadSharedRegionFromProfile loads the AWS region from the AWS shared configuration file for the given profile

func (*AwsCredentials) Read

func (c *AwsCredentials) Read() error

Read reads the AWS credentials from the cluster credentials file

func (*AwsCredentials) Refresh

func (c *AwsCredentials) Refresh(write, reload bool) error

Refresh ensures that the AWS credentials are valid if the credentials are invalid it will check the environment variables and AWS profile fro valid credentials in that order write flag determines whether the new creds are written reload flag determines whether the new creds affect the current session

func (*AwsCredentials) SetParameters

func (c *AwsCredentials) SetParameters(params ...string) error

SetParameters sets the credentials parameters

func (*AwsCredentials) SetPath

func (c *AwsCredentials) SetPath(path string)

SetPath sets the path of the credentials file be stored

func (*AwsCredentials) Validate

func (c *AwsCredentials) Validate() error

Validate validates the AWS session by executing a simple call to the AWS API

func (*AwsCredentials) Write

func (c *AwsCredentials) Write() error

Write writes the AWS credentials to the cluster credentials file

type AzureCredentials

type AzureCredentials struct {
	Platform       string `json:"platform" yaml:"platform" toml:"platform" mapstructure:"platform" env:"-"`
	SubscriptionID string `json:"subscription_id" yaml:"subscription_id" mapstructure:"subscription_id" env:"SUBSCRIPTION_ID"`
	TenantID       string `json:"tenant_id" yaml:"tenant_id" mapstructure:"tenant_id" env:"TENANT_ID"`
	ClientID       string `json:"client_id" yaml:"client_id" mapstructure:"client_id" env:"CLIENT_ID"`
	ClientSecret   string `json:"client_secret" yaml:"client_secret" mapstructure:"client_secret" env:"CLIENT_SECRET"`
	// contains filtered or unexported fields
}

AzureCredentials represents the credentials just for AWS

func NewAzureCredentials

func NewAzureCredentials(clustername, path string) *AzureCredentials

NewAzureCredentials creates an struct ready for Azure credentials

func (*AzureCredentials) Ask

func (c *AzureCredentials) Ask() error

Ask the user from stdin to get the Azure credentials suggesting values from the environment

func (*AzureCredentials) AssignFromMap

func (c *AzureCredentials) AssignFromMap(params map[string]string) error

AssignFromMap sets the credentials parameters from a map. The key is the name of the parameter as defined in the json metadata of the AzureCredentials structure

func (*AzureCredentials) Complete

func (c *AzureCredentials) Complete() bool

Complete returns true if all credentials are set. Use it as !Complete() to know if there is a missing parameter. !Complete() is not Empty()

func (*AzureCredentials) Empty

func (c *AzureCredentials) Empty() bool

Empty returns true if there isn't any credentials set

func (*AzureCredentials) Getenv

func (c *AzureCredentials) Getenv(force bool) error

Getenv gets the Azure credentials from environment variables

func (*AzureCredentials) List

func (c *AzureCredentials) List()

List prints to stdout the AWS credentials in table format

func (*AzureCredentials) Read

func (c *AzureCredentials) Read() error

Read reads the Azure credentials from the cluster credentials file

func (*AzureCredentials) SetParameters

func (c *AzureCredentials) SetParameters(params ...string) error

SetParameters sets the credentials parameters

func (*AzureCredentials) SetPath

func (c *AzureCredentials) SetPath(path string)

SetPath sets the path of the credentials file be stored

func (*AzureCredentials) Write

func (c *AzureCredentials) Write() error

Write writes the Azure credentials to the cluster credentials file

type CACert

type CACert struct {
	CN   string
	Desc string
}

CACert encapsulate the CN and CLI description for a CA cert

type Cert

type Cert struct {
	CN          string
	O           string
	FromCA      string
	DNSNames    []string
	IPAddresses []string
	ExtKeyUsage []x509.ExtKeyUsage
}

Cert encapsulate the CN and CA for a signed cert

type ClusterInfo

type ClusterInfo struct {
	Name       string `json:"name" yaml:"name" toml:"name"`
	Nodes      int    `json:"nodes" yaml:"nodes" toml:"nodes"`
	Platform   string `json:"platform" yaml:"platform" toml:"platform"`
	Status     string `json:"status" yaml:"status" toml:"status"`
	Version    string `json:"version" yaml:"version" toml:"version"`
	Path       string `json:"path" yaml:"path" toml:"path"`
	URL        string `json:"url" yaml:"url" toml:"url"`
	Kubeconfig string `json:"kubeconfig" yaml:"kubeconfig" toml:"kubeconfig"`
}

ClusterInfo basic cluster information

func (ClusterInfo) ContainsAll

func (i ClusterInfo) ContainsAll(params map[string]string) bool

ContainsAll returns true if the cluster information contains all the given parameters. The paramters is a map of key/value pairs, where the keys are the fields of the cluster information named as the JSON value

type ClustersInfo

type ClustersInfo []ClusterInfo

ClustersInfo list of clusters with its information

func GetClustersInfo

func GetClustersInfo(baseDir string, params map[string]string, clustersName ...string) (ClustersInfo, error)

GetClustersInfo gets the list of clusters and its basic information. If clustersName is empty will return the information for all the existing clusters

func (*ClustersInfo) FilterBy

func (ci *ClustersInfo) FilterBy(params map[string]string)

FilterBy filters the clusters information by the given parameters

func (ClustersInfo) JSON

func (ci ClustersInfo) JSON(pp bool) (string, error)

JSON returns the cluster information in JSON format

func (ClustersInfo) Names

func (ci ClustersInfo) Names() []string

Names returns a list of clusters name

func (ClustersInfo) Stringf

func (ci ClustersInfo) Stringf(format string, ppArr ...bool) (result string, err error)

Stringf returns the clusters info in the requested format to be printed

func (ClustersInfo) TOML

func (ci ClustersInfo) TOML() (string, error)

TOML returns the cluster information in TOML format

func (ClustersInfo) Table

func (ci ClustersInfo) Table(wide bool) string

Table returns the cluster information in a plain text table

func (ClustersInfo) Template

func (ci ClustersInfo) Template(format string) (string, error)

Template renders the clusters information from a given Go template

func (ClustersInfo) YAML

func (ci ClustersInfo) YAML() (string, error)

YAML returns the cluster information in YAML format

type CredentialHandler

type CredentialHandler interface {
	SetPath(string)
	Getenv(bool) error

	List()
	Ask() error
	Read() error
	Write() error
	SetParameters(...string) error
	AssignFromMap(map[string]string) error

	Empty() bool
	Complete() bool
	// contains filtered or unexported methods
}

CredentialHandler is an interface with all the methods a credentials struct should implement

func NewCredentials

func NewCredentials(clustername, platform, path string) CredentialHandler

NewCredentials creates a new credentials [handler] based on the given platform

type Kluster

type Kluster struct {
	Version   string                 `json:"version" yaml:"version" mapstructure:"version"`                  // KubeKit Configuration/API version
	Kind      string                 `json:"kind" yaml:"kind" mapstructure:"kind"`                           // File kind/type. Example: config, template
	Name      string                 `json:"name" yaml:"name" mapstructure:"name"`                           // Cluster Name
	Platforms map[string]interface{} `json:"platforms" yaml:"platforms" mapstructure:"platform"`             // Configuration of the platforms where the cluster could be installed
	State     map[string]*State      `json:"state" yaml:"state" mapstructure:"state"`                        // State of the cluster for each platform
	Config    *configurator.Config   `json:"config,omitempty" yaml:"config,omitempty" mapstructure:"config"` // Kubernetes configuration, no matter what platform
	Resources []string               `json:"resources" yaml:"resources" mapstructure:"resources"`
	// contains filtered or unexported fields
}

Kluster encapsulates the Kubernetes Cluster configuration

func CreateCluster

func CreateCluster(clusterName, platform, path, format string, variables map[string]string, parentUI *ui.UI) (cluster *Kluster, err error)

CreateCluster creates a cluster and cluster configuration file

func List

func List(path string, clustersName ...string) ([]*Kluster, error)

List returns a list of Klusters existing in the given directory

func Load

func Load(path string, parentUI *ui.UI) (*Kluster, error)

Load loads a given Kubernetes Cluster config file and dump the settings to a new Kluster which is returned

func LoadCluster

func LoadCluster(clusterName, clustersPath string, ui *ui.UI) (*Kluster, error)

LoadCluster return the cluster loacated in the clustersPath with name clusterName

func LoadSummary

func LoadSummary(path string) (*Kluster, error)

LoadSummary loads the most important information about a Kubernetes cluster configuration. Notice that the returned Kluster is incomplete and just to get basic/important information about it such as the cluster name

func New

func New(name, platformName, path, format string, parentUI *ui.UI, envConfig map[string]string) (*Kluster, error)

New creates a new Kluster or load it if the file already exists

func NewTemplate

func NewTemplate(name string, platforms []string, path, format string, parentUI *ui.UI, envConfig map[string]string) (*Kluster, error)

NewTemplate creates a new Kluster template. A template is a Kluster with multiple platforms

func (*Kluster) CertsDir

func (k *Kluster) CertsDir() string

CertsDir returns the path to store Certificates and KubeConfig file

func (*Kluster) ConfigVariables

func (k *Kluster) ConfigVariables() (vars map[string]string, err error)

ConfigVariables returns a map of string with the configuration in form of kubekit input variables

func (*Kluster) Configure

func (k *Kluster) Configure() error

Configure configures the cluster to have Kubernetes up and running. It uses the configurator to do this task

func (*Kluster) Copy

func (k *Kluster) Copy(name, platformName, path, format string, parentUI *ui.UI, envConfig map[string]string) (*Kluster, error)

Copy copies the current cluster configuration into a new one, with a new or existing platform and format

func (*Kluster) CopyFile

func (k *Kluster) CopyFile(from, to string, nodes []string, pools []string, forceFiles, backupFiles, sudoFiles bool, owner, group, mode string) error

CopyFile is to copy files to/form cluster nodes

func (*Kluster) CopyPackage

func (k *Kluster) CopyPackage(source, target string, backupPkg bool) error

CopyPackage copies a system package (rpm or deb) to every cluster node to a default location `/tmp`

func (*Kluster) Create

func (k *Kluster) Create() error

Create provision the cluster on all the required platforms

func (*Kluster) CreateKubeConfigFile

func (k *Kluster) CreateKubeConfigFile() error

CreateKubeConfigFile creates the kubeconfig file for this cluster

func (*Kluster) Credentials

func (k *Kluster) Credentials(params ...string)

Credentials is used to pass the credential parameters to the provisioner

func (*Kluster) Dir

func (k *Kluster) Dir() string

Dir returns the path of the configuration directory

func (*Kluster) Exec

func (k *Kluster) Exec(command, script string, nodes []string, pools []string, sudoExec bool) (*ssh.CommandResult, error)

Exec execute a script file or command line on every node of the cluster or the selected nodes

func (*Kluster) ExportK8s

func (k *Kluster) ExportK8s() error

ExportK8s exports the Kubernetes manifests templates (YAML files) to the cluster directory

func (*Kluster) ExportTF

func (k *Kluster) ExportTF() error

ExportTF exports to files the Terraform files, the TF code (main.tf) and the TF variables (terraform.tfvars).

func (*Kluster) GenPrivKeyFile

func (k *Kluster) GenPrivKeyFile(writeFile bool) (string, []byte, error)

GenPrivKeyFile generates a private key file in the certificates directory

func (*Kluster) GenPubKeyFile

func (k *Kluster) GenPubKeyFile(platform provisioner.Provisioner) (string, []byte, error)

GenPubKeyFile generates a public key file in the certificates directory

func (*Kluster) GenerateCerts

func (k *Kluster) GenerateCerts(userCACertsFiles tls.KeyPairs, overwrite bool) error

GenerateCerts generates all the certificates self-signed if the CA Key and Cert are not provided.

func (*Kluster) GenerateKubeConfig

func (k *Kluster) GenerateKubeConfig() ([]byte, error)

GenerateKubeConfig generates the KubeConfig file for a cluster

func (*Kluster) GetCredentials

func (k *Kluster) GetCredentials() ([]string, error)

GetCredentials retrieve the platform credentials from the credentials file

func (*Kluster) GetCredentialsAsMap

func (k *Kluster) GetCredentialsAsMap() (map[string]string, error)

GetCredentialsAsMap similar to GetCredentials but returns the credentials in a map of string

func (*Kluster) GetEntrypoint

func (k *Kluster) GetEntrypoint() string

GetEntrypoint returns the Kubernetes entrypoint or empty string if doesn't exists or invalid/malformed

func (*Kluster) GetKubeconfig

func (k *Kluster) GetKubeconfig() (string, error)

GetKubeconfig returns the content of the KubeConfig file

func (*Kluster) HandleKeys

func (k *Kluster) HandleKeys() error

HandleKeys create or load the public/private key required to provision the cluster nodes

func (*Kluster) HostsFilterBy

func (k *Kluster) HostsFilterBy(nodes []string, pools []string) configurator.Hosts

HostsFilterBy returns the cluster hosts or nodes in the given pools or matching the given node name patterns

func (*Kluster) InstallPackage

func (k *Kluster) InstallPackage(filename string, forcePkg bool) (result *ssh.CommandResult, failedNodes []string, err error)

InstallPackage installs a system package (rpm or deb) already located in the cluster nodes. To copy the package use the method `CopyPackage()`

func (*Kluster) JSON

func (k *Kluster) JSON(pp bool) ([]byte, error)

JSON returns the Kluster in JSON format

func (*Kluster) Load

func (k *Kluster) Load() error

Load loads the Kubernetes Cluster config file and dump the settings to this Kluster

func (*Kluster) LoadState

func (k *Kluster) LoadState() error

LoadState load the state from the state file for the given platform

func (*Kluster) LoadSummary

func (k *Kluster) LoadSummary() error

LoadSummary loads the most important information about a Kubernetes cluster configuration. Notice that the returned Kluster is incomplete and just to get basic/important information about it such as the cluster name

func (*Kluster) Lock

func (k *Kluster) Lock(name string) (lockfile.Lockfile, error)

Lock locks the cluster so no action can be done until it's unlocked with lock.Unlock()

func (*Kluster) MakeCertDir

func (k *Kluster) MakeCertDir(platfomName ...string) (string, error)

MakeCertDir creates the certificate directory for the given platforms or the base certificates directory if no platform is given

func (*Kluster) Path

func (k *Kluster) Path() string

Path returns the path of the configuration file

func (*Kluster) Plan

func (k *Kluster) Plan(destroy bool) error

Plan prints to the UI and Log the plan before applying the changes

func (*Kluster) Platform

func (k *Kluster) Platform() string

Platform returns the name of the cluster platform

func (*Kluster) ReadJSON

func (k *Kluster) ReadJSON(b []byte) error

ReadJSON load the Kluster from a JSON format text

func (*Kluster) ReadTOML

func (k *Kluster) ReadTOML(b []byte) error

ReadTOML load the Kluster from a TOML format text

func (*Kluster) ReadYAML

func (k *Kluster) ReadYAML(b []byte) error

ReadYAML load the Kluster from a YAML format text

func (*Kluster) Save

func (k *Kluster) Save() error

Save saves the Kubernetes Cluster configuration into a file

func (*Kluster) SaveCredentials

func (k *Kluster) SaveCredentials(params ...string) error

SaveCredentials saves the Cluster credentials file

func (*Kluster) SaveState

func (k *Kluster) SaveState() error

SaveState saves the state to the state file for the given platform

func (*Kluster) StartShellTo

func (k *Kluster) StartShellTo(nodeName string, in io.Reader, out, e io.Writer) error

StartShellTo opens an interactive shell to the given host name

func (*Kluster) StateDir

func (k *Kluster) StateDir() string

StateDir resturns the directory where the Terraform state file is

func (*Kluster) StateFile

func (k *Kluster) StateFile() string

StateFile resturns the Terraform state file path

func (*Kluster) String

func (k *Kluster) String() string

func (*Kluster) TOML

func (k *Kluster) TOML() ([]byte, error)

TOML returns the Kluster in TOML format

func (*Kluster) Terminate

func (k *Kluster) Terminate() error

Terminate destroy the cluster on all the required platforms

func (*Kluster) Update

func (k *Kluster) Update(envConfig map[string]string) error

Update updates the cluster with the given configuration

func (*Kluster) UpdateState

func (k *Kluster) UpdateState(platform string)

UpdateState creates a new State structure from the given provisioner TF state

func (*Kluster) WriteKubeConfig

func (k *Kluster) WriteKubeConfig(kubeconfigContent []byte) (string, error)

WriteKubeConfig saves the kubeconfig content in a file into the cluster directory

func (*Kluster) YAML

func (k *Kluster) YAML() ([]byte, error)

YAML returns the Kluster in YAML format

type KubeconfigData

type KubeconfigData struct {
	CertificateAuthorityData string
	ClusterName              string
	Server                   string
	Port                     int
	ClientCertData           string
	ClientKeyData            string
}

KubeconfigData contain the data to render the kubeconfig template

type PlatformCredentials

type PlatformCredentials struct {
	Platform string `json:"platform" yaml:"platform" toml:"platform" mapstructure:"platform" env:"-"`
	Server   string `json:"server" yaml:"server" toml:"server" mapstructure:"server" env:"SERVER"`
	Username string `json:"username" yaml:"username" toml:"username" mapstructure:"username" env:"USERNAME"`
	Password string `json:"password" yaml:"password" toml:"password" mapstructure:"password" env:"PASSWORD"`
	// contains filtered or unexported fields
}

PlatformCredentials represents the credentials for any platform but AWS

func NewPlatformCredentials

func NewPlatformCredentials(clustername, platform, path string) *PlatformCredentials

NewPlatformCredentials creates an struct ready for any platform credentials

func (*PlatformCredentials) Ask

func (c *PlatformCredentials) Ask() error

Ask to the user from stdin the platform credentials suggesting values from the environment

func (*PlatformCredentials) AssignFromMap

func (c *PlatformCredentials) AssignFromMap(params map[string]string) error

AssignFromMap sets the credentials parameters from a map. The key is the name of the parameter as defined in the json metadata of the PlatformCredentials structure

func (*PlatformCredentials) Complete

func (c *PlatformCredentials) Complete() bool

Complete returns true if all credentials are set. Use it as !Complete() to know if there is a missing parameter. !Complete() is not Empty()

func (*PlatformCredentials) Empty

func (c *PlatformCredentials) Empty() bool

Empty returns true if there isn't any credentials set

func (*PlatformCredentials) Getenv

func (c *PlatformCredentials) Getenv(force bool) error

Getenv gets the platform credentials from environment variables

func (*PlatformCredentials) List

func (c *PlatformCredentials) List()

List prints to stdout the platform credentials in table format

func (*PlatformCredentials) Read

func (c *PlatformCredentials) Read() error

Read reads the platform credentials from the cluster credentials file

func (*PlatformCredentials) SetParameters

func (c *PlatformCredentials) SetParameters(params ...string) error

SetParameters sets the credentials parameters

func (*PlatformCredentials) SetPath

func (c *PlatformCredentials) SetPath(path string)

SetPath sets the path of the credentials file be stored

func (*PlatformCredentials) Write

func (c *PlatformCredentials) Write() error

Write writes the platform credentials to the cluster credentials file

type State

type State struct {
	Status  string                 `json:"status" yaml:"status" mapstructure:"status"`
	Address string                 `json:"address,omitempty" yaml:"address,omitempty" mapstructure:"address,omitempty"`
	Port    int                    `json:"port,omitempty" yaml:"port,omitempty" mapstructure:"port,omitempty"`
	Nodes   configurator.Hosts     `json:"nodes,omitempty" yaml:"nodes,omitempty" mapstructure:"nodes,omitempty"`
	Data    map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"`
}

State represent the final state of one platform. It's basically the address:port to access the cluster and the list of nodes

type Status

type Status int

Status is used to name the cluster status

const (
	AbsentStatus              Status = 1 << iota // 00000000001 : Does not exists, not created/provisioned yet
	CreatingStatus                               // 00000000010 : It's been created, it's been provisioned
	ProvisionedStatus                            // 00000000100 : The provisioning was successfully completed and ready to be configured
	FailedProvisioningStatus                     // 00000001000 : The provisioning failed, some cluster nodes may noe exists
	FailedConfigurationStatus                    // 00000010000 : The configuration started and failed
	FailedCreationStatus                         // 						: The cluster failed to be created
	CreatedStatus                                // 00000100000 : The configuration was successfully completed
	RunningStatus                                // 00001000000 : The cluster has a Kubernetes cluster up & running
	StoppedStatus                                // 00010000000 : The cluster has a Kubernetes cluster but it's not running. It can go to the Running or Terminated status
	TerminatingStatus                            // 00100000000 : It's in the process to be destroyed
	TerminatedStatus                             // 01000000000 : The cluster is destroyed, it does not exists anymore
	FailedTerminationStatus                      // 10000000000 : The termination process failed
	UnknownStatus
)

All the possible values of a cluster status Pending : The cluster is not created/provisioned yet Provisioned : The cluster is provisioned and ready to be configured Running : The cluster has a Kubernetes cluster running Stopped : The cluster has a Kubernetes cluster but it's not running. It can go to the Running or Terminated status Terminated : The cluster is destroyed, it does not exists anymore

func ParseStatus

func ParseStatus(status string) Status

ParseStatus returns the status from a status name

func (Status) String

func (status Status) String() string

String returns the name of the received status

Jump to

Keyboard shortcuts

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