Documentation ¶
Index ¶
- Constants
- Variables
- func Ask(title string, sensitive bool) (string, error)
- func AskDefault(title, defValue string, sensitive bool) (string, error)
- func GetSession(creds map[string]string) (*session.Session, error)
- func InvalidFilterParams(params map[string]string) []string
- func IsValidFilter(params map[string]string) bool
- func ListNames(path string) ([]string, error)
- func NewPath(clustersPath string) (string, error)
- func Path(clusterName, path string) string
- func Unique(clusterName, path string) bool
- func ValidClusterName(clusterName string) (string, error)
- type AwsCredentials
- func (c *AwsCredentials) Ask() error
- func (c *AwsCredentials) AssignFromMap(params map[string]string) error
- func (c *AwsCredentials) Complete() bool
- func (c *AwsCredentials) Empty() bool
- func (c *AwsCredentials) Getenv(force bool) error
- func (c *AwsCredentials) List()
- func (c *AwsCredentials) LoadSharedCredentialsFromProfile(profile string, force bool) error
- func (c *AwsCredentials) LoadSharedRegionFromProfile(profile string, force bool) error
- func (c *AwsCredentials) Read() error
- func (c *AwsCredentials) Refresh(write, reload bool) error
- func (c *AwsCredentials) SetParameters(params ...string) error
- func (c *AwsCredentials) SetPath(path string)
- func (c *AwsCredentials) Validate() error
- func (c *AwsCredentials) Write() error
- type AzureCredentials
- func (c *AzureCredentials) Ask() error
- func (c *AzureCredentials) AssignFromMap(params map[string]string) error
- func (c *AzureCredentials) Complete() bool
- func (c *AzureCredentials) Empty() bool
- func (c *AzureCredentials) Getenv(force bool) error
- func (c *AzureCredentials) List()
- func (c *AzureCredentials) Read() error
- func (c *AzureCredentials) SetParameters(params ...string) error
- func (c *AzureCredentials) SetPath(path string)
- func (c *AzureCredentials) Write() error
- type CACert
- type Cert
- type ClusterInfo
- type ClustersInfo
- func (ci *ClustersInfo) FilterBy(params map[string]string)
- func (ci ClustersInfo) JSON(pp bool) (string, error)
- func (ci ClustersInfo) Names() []string
- func (ci ClustersInfo) Stringf(format string, ppArr ...bool) (result string, err error)
- func (ci ClustersInfo) TOML() (string, error)
- func (ci ClustersInfo) Table(wide bool) string
- func (ci ClustersInfo) Template(format string) (string, error)
- func (ci ClustersInfo) YAML() (string, error)
- type CredentialHandler
- type Kluster
- func CreateCluster(clusterName, platform, path, format string, variables map[string]string, ...) (cluster *Kluster, err error)
- func List(path string, clustersName ...string) ([]*Kluster, error)
- func Load(path string, parentUI *ui.UI) (*Kluster, error)
- func LoadCluster(clusterName, clustersPath string, ui *ui.UI) (*Kluster, error)
- func LoadSummary(path string) (*Kluster, error)
- func New(name, platformName, path, format string, parentUI *ui.UI, ...) (*Kluster, error)
- func NewTemplate(name string, platforms []string, path, format string, parentUI *ui.UI, ...) (*Kluster, error)
- func (k *Kluster) CertsDir() string
- func (k *Kluster) ConfigVariables() (vars map[string]string, err error)
- func (k *Kluster) Configure() error
- func (k *Kluster) Copy(name, platformName, path, format string, parentUI *ui.UI, ...) (*Kluster, error)
- func (k *Kluster) CopyFile(from, to string, nodes []string, pools []string, ...) error
- func (k *Kluster) CopyPackage(source, target string, backupPkg bool) error
- func (k *Kluster) Create() error
- func (k *Kluster) CreateKubeConfigFile() error
- func (k *Kluster) Credentials(params ...string)
- func (k *Kluster) Dir() string
- func (k *Kluster) Exec(command, script string, nodes []string, pools []string, sudoExec bool) (*ssh.CommandResult, error)
- func (k *Kluster) ExportK8s() error
- func (k *Kluster) ExportTF() error
- func (k *Kluster) GenPrivKeyFile(writeFile bool) (string, []byte, error)
- func (k *Kluster) GenPubKeyFile(platform provisioner.Provisioner) (string, []byte, error)
- func (k *Kluster) GenerateCerts(userCACertsFiles tls.KeyPairs, overwrite bool) error
- func (k *Kluster) GenerateKubeConfig() ([]byte, error)
- func (k *Kluster) GetCredentials() ([]string, error)
- func (k *Kluster) GetCredentialsAsMap() (map[string]string, error)
- func (k *Kluster) GetEntrypoint() string
- func (k *Kluster) GetKubeconfig() (string, error)
- func (k *Kluster) HandleKeys() error
- func (k *Kluster) HostsFilterBy(nodes []string, pools []string) configurator.Hosts
- func (k *Kluster) InstallPackage(filename string, forcePkg bool) (result *ssh.CommandResult, failedNodes []string, err error)
- func (k *Kluster) JSON(pp bool) ([]byte, error)
- func (k *Kluster) Load() error
- func (k *Kluster) LoadState() error
- func (k *Kluster) LoadSummary() error
- func (k *Kluster) Lock(name string) (lockfile.Lockfile, error)
- func (k *Kluster) MakeCertDir(platfomName ...string) (string, error)
- func (k *Kluster) Path() string
- func (k *Kluster) Plan(destroy bool) error
- func (k *Kluster) Platform() string
- func (k *Kluster) ReadJSON(b []byte) error
- func (k *Kluster) ReadTOML(b []byte) error
- func (k *Kluster) ReadYAML(b []byte) error
- func (k *Kluster) Save() error
- func (k *Kluster) SaveCredentials(params ...string) error
- func (k *Kluster) SaveState() error
- func (k *Kluster) StartShellTo(nodeName string, in io.Reader, out, e io.Writer) error
- func (k *Kluster) StateDir() string
- func (k *Kluster) StateFile() string
- func (k *Kluster) String() string
- func (k *Kluster) TOML() ([]byte, error)
- func (k *Kluster) Terminate() error
- func (k *Kluster) Update(envConfig map[string]string) error
- func (k *Kluster) UpdateState(platform string)
- func (k *Kluster) WriteKubeConfig(kubeconfigContent []byte) (string, error)
- func (k *Kluster) YAML() ([]byte, error)
- type KubeconfigData
- type PlatformCredentials
- func (c *PlatformCredentials) Ask() error
- func (c *PlatformCredentials) AssignFromMap(params map[string]string) error
- func (c *PlatformCredentials) Complete() bool
- func (c *PlatformCredentials) Empty() bool
- func (c *PlatformCredentials) Getenv(force bool) error
- func (c *PlatformCredentials) List()
- func (c *PlatformCredentials) Read() error
- func (c *PlatformCredentials) SetParameters(params ...string) error
- func (c *PlatformCredentials) SetPath(path string)
- func (c *PlatformCredentials) Write() error
- type State
- type Status
Constants ¶
const ( GenericKeyPairName = "root_ca" APIServerCertName = "node" // TODO: change it in the future to 'kube-node' )
GenericKeyPairName is the name of the generic key pair
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
const CredentialsFileName = ".credentials"
CredentialsFileName is the filename to store the credentials
const KubeconfigEKSTmpl = `` /* 459-byte string literal not displayed */
KubeconfigEKSTmpl is the kubeconfig template for EKS
const KubeconfigTmpl = `` /* 526-byte string literal not displayed */
KubeconfigTmpl is the kubeconfig template
Variables ¶
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 )
var AllStatuses = []Status{ AbsentStatus, CreatingStatus, ProvisionedStatus, FailedProvisioningStatus, FailedConfigurationStatus, FailedCreationStatus, CreatedStatus, RunningStatus, StoppedStatus, TerminatingStatus, TerminatedStatus, FailedTerminationStatus, }
AllStatuses contain all the statuses in one variable
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'
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 AskDefault ¶
AskDefault asks to the user a query proposing a default value
func GetSession ¶
GetSession creates an AWS session from the provided creds
func InvalidFilterParams ¶
InvalidFilterParams return a list of invalid filter parameters for clusters info
func IsValidFilter ¶
IsValidFilter returns true if one of the filter parameters for clusters info is not valid
func Path ¶
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 ¶
Unique checks if the given cluster name does not exists (it's unique) in the given cluster path.
func ValidClusterName ¶
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 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 Load ¶
Load loads a given Kubernetes Cluster config file and dump the settings to a new Kluster which is returned
func LoadCluster ¶
LoadCluster return the cluster loacated in the clustersPath with name clusterName
func LoadSummary ¶
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) ConfigVariables ¶
ConfigVariables returns a map of string with the configuration in form of kubekit input variables
func (*Kluster) Configure ¶
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 ¶
CopyPackage copies a system package (rpm or deb) to every cluster node to a default location `/tmp`
func (*Kluster) CreateKubeConfigFile ¶
CreateKubeConfigFile creates the kubeconfig file for this cluster
func (*Kluster) Credentials ¶
Credentials is used to pass the credential parameters to the provisioner
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 ¶
ExportK8s exports the Kubernetes manifests templates (YAML files) to the cluster directory
func (*Kluster) ExportTF ¶
ExportTF exports to files the Terraform files, the TF code (main.tf) and the TF variables (terraform.tfvars).
func (*Kluster) GenPrivKeyFile ¶
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 ¶
GenerateCerts generates all the certificates self-signed if the CA Key and Cert are not provided.
func (*Kluster) GenerateKubeConfig ¶
GenerateKubeConfig generates the KubeConfig file for a cluster
func (*Kluster) GetCredentials ¶
GetCredentials retrieve the platform credentials from the credentials file
func (*Kluster) GetCredentialsAsMap ¶
GetCredentialsAsMap similar to GetCredentials but returns the credentials in a map of string
func (*Kluster) GetEntrypoint ¶
GetEntrypoint returns the Kubernetes entrypoint or empty string if doesn't exists or invalid/malformed
func (*Kluster) GetKubeconfig ¶
GetKubeconfig returns the content of the KubeConfig file
func (*Kluster) HandleKeys ¶
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) Load ¶
Load loads the Kubernetes Cluster config file and dump the settings to this Kluster
func (*Kluster) LoadSummary ¶
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 ¶
Lock locks the cluster so no action can be done until it's unlocked with lock.Unlock()
func (*Kluster) MakeCertDir ¶
MakeCertDir creates the certificate directory for the given platforms or the base certificates directory if no platform is given
func (*Kluster) SaveCredentials ¶
SaveCredentials saves the Cluster credentials file
func (*Kluster) StartShellTo ¶
StartShellTo opens an interactive shell to the given host name
func (*Kluster) UpdateState ¶
UpdateState creates a new State structure from the given provisioner TF state
func (*Kluster) WriteKubeConfig ¶
WriteKubeConfig saves the kubeconfig content in a file into the cluster directory
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 ¶
ParseStatus returns the status from a status name