configurator

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: 25 Imported by: 0

README

KubeKit Configurator Go Package

This is a KubeKit Go package to bring up Kubernetes on a given set of infrastructure. It is used by the KubeKit CLI and the KubeKit Configurator Microservice.

The Go package encapsulate Ansible code which is executed on every Kubernetes node.

Requirements

  • Go or Docker are required to verify the Go code compile
  • (Optional) Ansible [will be] required to execute Unit Tests to the Ansible code.

This repository/project does not store the vendors or imported Go packages, it will require all the vendors in your system if you would like to compile it using the Go in your system. If Go is not installed or you don't have the vendors in your system, the recomended way to verify the code compile is using the Docker container.

Build

If the changes were done to the Ansible code located in the templates/ directory, the Go code that encapsulate such code has to be generated. Execute make generate or just make:

make generate

If the changes were done to the Go code there are two ways to compile:

  1. If you have Go install in your system and the vendors correctly setup: Execute make install or make test or both make test install.
  2. If Go is not installed but Docker is: Execute make compile

The safest way to proceed is the option #2 but takes more time (2-3 minutes):

make compile

It's recommended to use an IDE such as VSCode or Atom with the Golang plugings to have a well formatted code, otherwise, execute make fmt before compile and push the code to GitHub.

Use

The configurator has a Config struct with all the required parameters to configure Kubernetes in a node or cluster. That Config struct is created with the method New() giving the parameters in a map[string]interface{} map.

To execute the configurator, call the method Configure() to install Ansible on every node (if not already installed) and to send the certificates, manifest and Ansible roles to every Kubernetes node. Then it will execute the Ansible playbook to finally install, configure and start up Kubernetes in every node.

import (
  "github.com/kubekit/configurator"
)

func Configure() error {
  logger.Debugf("starting the configuration of cluster %q", Name)

  configtor, err := configurator.New(Config, state, path, Platform, logger)
  if err != nil {
    return err
  }

  return configtor.Configure()
}

Setup Vendors

IMPORTAT: The execution of these actions may modify the existing Go packages you have in your $GOPATH directory. Use cafefully.

If you don't want to modify the existing vendors, use the compilation in a container. It's safer but takes longer (2-3 minutes).

To quickly and easly setup the required Go packages in your system, execute make vendor. This will get or update the required Go packages (vendors) in your $GOPATH directory. Then will fix some errors that cause the code don't compile.

Go Vendor Problems

The vendor actions, like getting new vendors or updates, sometimes may cause compilation errors. Some possible causes are:

  • Repeated packages: Some packages are inside the vendor directory of a package and in the $GOPATH. To remove the package from the vendor directory may fix this issue.
  • Not vendored packages: Some packages are not added correctly to the project vendor directory by Govendor. If this is the case, copy the package from $GOPATH but make sure to not copy the .git directory and files.
  • Sirupsen: The Sirupsen logging package change to sirupsen but some packages still uses the former. Change the import to use sirupsen.

Documentation

Overview

Code generated automatically by 'go run codegen/ansible/main.go --src ./templates/ansible --dst ./code.go'; DO NOT EDIT.

Index

Constants

View Source
const (
	AnsibleStatusOk     = "ok"
	AnsibleStatusFailed = "failed"
)

Ansible status possible values

View Source
const (
	MaxEmptyTaskRetries   = 5
	MaxFailedTaskRetries  = 10
	MaxFailedStatsRetries = 5

	SecondsTickTasks = 5
	SecondsTickStats = 10
)

Maximum number retries and frecuency to get tasks and status

View Source
const (
	CheckAnsibleCMD   = "test -f /usr/bin/ansible && echo OK || echo NOK"
	AnsibleVersionCMD = "/usr/bin/ansible --version 2>/dev/null | head -1"
	InstallAnsibleCMD = "test -f /usr/bin/ansible || ( sudo easy_install pip && sudo pip install ansible Flask )"
	GetEpochCMD       = "date +%s"
)

Remote commands to check and install Ansible

View Source
const ConfiguratorBaseDir = KubekitBaseDir + "/configurator"

ConfiguratorBaseDir is the home directory to store the configurator files in every node

View Source
const ConfiguratorLogDir = "/var/log/kubekit"

ConfiguratorLogDir is the log directory to store the configurator logs in every node

View Source
const KubeKitConfiguratorPort = 1080

KubeKitConfiguratorPort is the port used by the KubeKit Ansible callback to expose the Ansible playbook logs

View Source
const KubekitBaseDir = "/var/kubekit"

KubekitBaseDir is the kubekit installation directory on every node

View Source
const TLSDirectory = "/etc/pki"

TLSDirectory is the directory to upload the CA root certificates at the nodes

View Source
const ZeroPadLen = 3

ZeroPadLen is the length for the number following the role of the node. i.e. master001

Variables

View Source
var (
	Data       string
	AnsibleCfg string
	Callback   string
	Playbook   string
	Resources  map[string]string
)

variables containing the Ansible files such as the roles (in zip format), configuration and playbook. These variables values are generated by `codegen/ansible/main.go` using the go generate statement above.

View Source
var ValidAddressInventoryFields = map[string]struct{}{
	"ansible_host":   struct{}{},
	"private_ip":     struct{}{},
	"public_ip":      struct{}{},
	"private_dns":    struct{}{},
	"public_dns":     struct{}{},
	"fqdn":           struct{}{},
	"hostname":       struct{}{},
	"hostname_short": struct{}{},
	"kubelet_taints": struct{}{},
	"kubelet_labels": struct{}{},
}

ValidAddressInventoryFields is a lookup for valid InventoryHost address fields the key names must match the values given in the yaml tag for the InventoryHost fields used for addressing

Functions

func GetPrivateKey

func GetPrivateKey(platformConfig map[string]interface{}) (string, error)

GetPrivateKey return the private key from the cluster platform configuration

Types

type AllInventory

type AllInventory struct {
	Variables InventoryVariables `json:"vars,omitempty" yaml:"vars" mapstructure:"vars"`
	Children  Children           `json:"children,omitempty" yaml:"children" mapstructure:"children"`
}

AllInventory contain all the variables and childrens of the Ansible inventory

type AnsibleClient

type AnsibleClient struct {
	Hostname string
	Tasks    []AnsibleTask
	Stats    *AnsibleStats
	// contains filtered or unexported fields
}

AnsibleClient handle the Ansible connection with the Ansible Callback API

func (*AnsibleClient) PrintLogs

func (a *AnsibleClient) PrintLogs()

PrintLogs prints to a given logger the ansible

type AnsibleHostStat

type AnsibleHostStat struct {
	Changed     int `json:"changed"`
	Failures    int `json:"failures"`
	Ok          int `json:"ok"`
	Skipped     int `json:"skipped"`
	Unreachable int `json:"unreachable"`
}

AnsibleHostStat contain the Ansible stats per host

func (AnsibleHostStat) Log

func (hstats AnsibleHostStat) Log(host string, duration float32, logger *log.Logger)

Log print the stats of a host to a logger. Really rare situation, but here just in case

type AnsibleStats

type AnsibleStats struct {
	Duration float32                    `json:"duration"`
	Status   string                     `json:"status"`
	Stats    map[string]AnsibleHostStat `json:"stats"`
}

AnsibleStats encapsulate all the stats

func (*AnsibleStats) Empty

func (stats *AnsibleStats) Empty() bool

Empty returns true if this stats hasn't been collected

func (*AnsibleStats) Log

func (stats *AnsibleStats) Log(failedTasks []AnsibleTask, logger *log.Logger)

Log print the stats to a logger

func (*AnsibleStats) Ok

func (stats *AnsibleStats) Ok() bool

Ok returns true if the status is OK

func (*AnsibleStats) String

func (stats *AnsibleStats) String() string

type AnsibleStatsMap

type AnsibleStatsMap struct {
	sync.RWMutex
	Results map[string]*AnsibleStats
}

AnsibleStatsMap is a type safe map wrapped with mutex locks around get/set calls where the keys are the role name and values are references to AnsibleStats

func NewAnsibleStatsMap

func NewAnsibleStatsMap(size int) AnsibleStatsMap

NewAnsibleStatsMap initializes/makes the AnsibleStatsMap map

func (*AnsibleStatsMap) GetSnapshot

func (asm *AnsibleStatsMap) GetSnapshot() map[string]*AnsibleStats

GetSnapshot returns a snapshot of the given AnsibleStatsMap

func (*AnsibleStatsMap) Store

func (asm *AnsibleStatsMap) Store(key string, value *AnsibleStats)

Store updates the value at the given key in the given AnsibleStatsMap

type AnsibleTask

type AnsibleTask struct {
	Name    string            `json:"name"`
	UUID    string            `json:"uuid"`
	Status  string            `json:"status"`
	Changed bool              `json:"changed"`
	Node    string            `json:"node"`
	Items   []AnsibleTaskItem `json:"items"`
}

AnsibleTask contain the results of a task execution

func (AnsibleTask) Ok

func (t AnsibleTask) Ok() bool

Ok returns true if the status is OK

func (AnsibleTask) Report

func (t AnsibleTask) Report(uI *ui.UI)

Report prints the task to the UI and Logs

func (AnsibleTask) String

func (t AnsibleTask) String() string

type AnsibleTaskItem

type AnsibleTaskItem struct {
	Name    string `json:"name"`
	Status  string `json:"status"`
	Changed bool   `json:"changed"`
	Node    string `json:"node"`
}

AnsibleTaskItem contain the results of the items in a tasks (if any)

func (AnsibleTaskItem) Log

func (i AnsibleTaskItem) Log(logger *log.Logger)

Log print the task item to a logger

func (AnsibleTaskItem) Ok

func (i AnsibleTaskItem) Ok() bool

Ok returns true if the status is OK

func (AnsibleTaskItem) String

func (i AnsibleTaskItem) String() string

type Children

type Children struct {
	KubeCluster KubeCluster `json:"kube_cluster,omitempty" yaml:"kube_cluster" mapstructure:"kube_cluster"`
}

Children is a children structure in an Ansible inventory

type Command

type Command struct {
	Hosts Hosts
	// contains filtered or unexported fields
}

Command is a command to execute in a cluster node or to/from it

func NewCommand

func NewCommand(hosts Hosts, platformConfig interface{}, ui *ui.UI) (*Command, error)

NewCommand returns a new command

func (*Command) Copy

func (c *Command) Copy(from, to string, forceFiles, backupFiles, sudoFiles bool, owner, group, mode string) error

Copy copies files from/to the cluster hosts

func (*Command) CopyFrom

func (c *Command) CopyFrom(from, to string, forceFiles, backupFiles, sudoFiles bool, owner, group, mode string) error

CopyFrom copies files from the cluster hosts to localhost

func (*Command) CopyTo

func (c *Command) CopyTo(from, to string, forceFiles, backupFiles, sudoFiles bool, owner, group, mode string) error

CopyTo copies files from the cluster hosts to localhost

func (*Command) Exec

func (c *Command) Exec(command, script string, sudoExec bool) (*ssh.CommandResult, error)

Exec executes a script file or command line on every command host

type Config

type Config struct {
	ShellEditingMode                        string      `json:"shell_editing_mode,omitempty" yaml:"shell_editing_mode,omitempty" mapstructure:"shell_editing_mode,omitempty"`
	AddressInventoryField                   string      `json:"address_inventory_field" yaml:"address_inventory_field" mapstructure:"address_inventory_field"`
	EtcdInitialClusterToken                 string      `json:"etcd_initial_cluster_token" yaml:"etcd_initial_cluster_token" mapstructure:"etcd_initial_cluster_token"`
	KubeletMaxPods                          int         `json:"kubelet_max_pods" yaml:"kubelet_max_pods" mapstructure:"kubelet_max_pods"`
	KubeletSerializeImagePulls              bool        `` /* 148-byte string literal not displayed */
	KubeProxyMode                           string      `json:"kube_proxy_mode,omitempty" yaml:"kube_proxy_mode,omitempty" mapstructure:"kube_proxy_mode,omitempty"`
	KubeClusterCidr                         string      `json:"kube_cluster_cidr" yaml:"kube_cluster_cidr" mapstructure:"kube_cluster_cidr"`
	KubeServicesCidr                        string      `json:"kube_services_cidr" yaml:"kube_services_cidr" mapstructure:"kube_services_cidr"`
	KubeServiceIP                           string      `json:"kube_service_ip" yaml:"kube_service_ip" mapstructure:"kube_service_ip"`
	KubeAdvertiseAddress                    string      `json:"kube_advertise_address" yaml:"kube_advertise_address" mapstructure:"kube_advertise_address"`
	MasterSchedulableEnabled                bool        `json:"master_schedulable_enabled" yaml:"master_schedulable_enabled" mapstructure:"master_schedulable_enabled"`
	EtcdLocalProxyEnabled                   bool        `json:"enable_etcd_local_proxy" yaml:"enable_etcd_local_proxy" mapstructure:"enable_etcd_local_proxy"`
	DockerMaxConcurrentUploads              int         ``                                                                                                                /* 148-byte string literal not displayed */
	DockerMaxConcurrentDownloads            int         ``                                                                                                                /* 154-byte string literal not displayed */
	DockerLogMaxFiles                       string      `json:"docker_log_max_files,omitempty" yaml:"docker_log_max_files,omitempty" mapstructure:"docker_log_max_files"` // docker config takes it as a string
	DockerLogMaxSize                        string      `json:"docker_log_max_size,omitempty" yaml:"docker_log_max_size,omitempty" mapstructure:"docker_log_max_size"`
	DockerRegistryPort                      int         `json:"registry_port" yaml:"registry_port" mapstructure:"registry_port"`
	DockerRegistryPath                      string      `json:"docker_registry_path" yaml:"docker_registry_path" mapstructure:"docker_registry_path"`
	DownloadImagesIfMissing                 bool        `json:"download_images_if_missing" yaml:"download_images_if_missing" mapstructure:"download_images_if_missing"`
	HAProxyClientTimeout                    string      `json:"haproxy_client_timeout,omitempty" yaml:"haproxy_client_timeout,omitempty" mapstructure:"haproxy_client_timeout"`
	HAProxyServerTimeout                    string      `json:"haproxy_server_timeout,omitempty" yaml:"haproxy_server_timeout,omitempty" mapstructure:"haproxy_server_timeout"`
	DNSAAAADelayEnabled                     *bool       `json:"dns_aaaa_delay_enabled,omitempty" yaml:"dns_aaaa_delay_enabled,omitempty" mapstructure:"dns_aaaa_delay_enabled"`
	DNSArgs                                 string      `json:"dns_args" yaml:"dns_args" mapstructure:"dns_args"`
	EtcdDefragCrontabHour                   string      `json:"etcd_defrag_crontab_hour,omitempty" yaml:"etcd_defrag_crontab_hour,omitempty" mapstructure:"etcd_defrag_crontab_hour"`
	EtcdLogsCrontabHour                     string      `json:"etcd_logs_crontab_hour" yaml:"etcd_logs_crontab_hour" mapstructure:"etcd_logs_crontab_hour"`
	EtcdLogsCrontabMinute                   string      `json:"etcd_logs_crontab_minute" yaml:"etcd_logs_crontab_minute" mapstructure:"etcd_logs_crontab_minute"`
	EtcdLogsDaysToKeep                      int         `json:"etcd_logs_days_to_keep" yaml:"etcd_logs_days_to_keep" mapstructure:"etcd_logs_days_to_keep"`
	EtcdSnapshotsDirectory                  string      `json:"etcd_snapshots_directory,omitempty" yaml:"etcd_snapshots_directory,omitempty" mapstructure:"etcd_snapshots_directory"`
	UseLocalImages                          bool        `json:"use_local_images" yaml:"use_local_images" mapstructure:"use_local_images"`
	ClusterIfaceName                        string      `json:"cluster_iface_name" yaml:"cluster_iface_name" mapstructure:"cluster_iface_name"`
	ClusterIface                            string      `json:"cluster_iface" yaml:"cluster_iface" mapstructure:"cluster_iface"`
	CniIface                                string      `json:"cni_iface" yaml:"cni_iface" mapstructure:"cni_iface"`
	KubeAuditLogMaxAge                      int         `json:"kube_audit_log_max_age" yaml:"kube_audit_log_max_age" mapstructure:"kube_audit_log_max_age"`
	KubeAuditLogMaxBackup                   int         `json:"kube_audit_log_max_backup" yaml:"kube_audit_log_max_backup" mapstructure:"kube_audit_log_max_backup"`
	KubeAuditLogMaxSize                     int         `json:"kube_audit_log_max_size" yaml:"kube_audit_log_max_size" mapstructure:"kube_audit_log_max_size"`
	NginxIngressEnabled                     bool        `json:"nginx_ingress_enabled" yaml:"nginx_ingress_enabled" mapstructure:"nginx_ingress_enabled"`
	NginxIngressControllerProxyBodySize     string      `` /* 151-byte string literal not displayed */
	NginxIngressControllerErrorLogLevel     string      `` /* 151-byte string literal not displayed */
	NginxIngressControllerSslProtocols      string      `` /* 145-byte string literal not displayed */
	NginxIngressControllerProxyReadTimeout  string      `` /* 160-byte string literal not displayed */
	NginxIngressControllerProxySendTimeout  string      `` /* 160-byte string literal not displayed */
	NginxIngressControllerTLSCertLocalPath  string      `` /* 163-byte string literal not displayed */
	NginxIngressControllerTLSKeyLocalPath   string      `` /* 160-byte string literal not displayed */
	NginxIngressControllerBasicAuthUsername string      `` /* 163-byte string literal not displayed */
	NginxIngressControllerBasicAuthPassword string      `` /* 163-byte string literal not displayed */
	DefaultIngressHost                      string      `json:"default_ingress_host" yaml:"default_ingress_host" mapstructure:"default_ingress_host"`
	RookEnabled                             bool        `json:"rook_enabled,omitempty" yaml:"rook_enabled" mapstructure:"rook_enabled"`
	RookCephStorageDeviceDirectories        []string    `` /* 128-byte string literal not displayed */
	RookCephStorageDeviceFilter             string      `` /* 134-byte string literal not displayed */
	RookDashboardEnabled                    bool        `json:"rook_dashboard_enabled,omitempty" yaml:"rook_dashboard_enabled" mapstructure:"rook_dashboard_enabled"`
	RookDashboardExternalEnabled            bool        `` /* 134-byte string literal not displayed */
	RookDashboardPort                       int         `json:"rook_dashboard_port,omitempty" yaml:"rook_dashboard_port" mapstructure:"rook_dashboard_port"`
	RookObjectStoreEnabled                  bool        `json:"rook_object_store_enabled,omitempty" yaml:"rook_object_store_enabled" mapstructure:"rook_object_store_enabled"`
	RookObjectStoreRadosGatewayEnabled      bool        `` /* 158-byte string literal not displayed */
	RookFileStoreEnabled                    bool        `json:"rook_file_store_enabled,omitempty" yaml:"rook_file_store_enabled" mapstructure:"rook_file_store_enabled"`
	DefaultStorageclass                     string      `json:"default_storageclass,omitempty" yaml:"default_storageclass" mapstructure:"default_storageclass"`
	HostTimeZone                            string      `json:"host_timezone,omitempty" yaml:"host_timezone" mapstructure:"host_timezone"`
	ControlPlaneTimeZone                    string      `json:"controlplane_timezone,omitempty" yaml:"controlplane_timezone" mapstructure:"controlplane_timezone"`
	CloudProviderEnabled                    bool        `json:"cloud_provider_enabled,omitempty" yaml:"cloud_provider_enabled" mapstructure:"cloud_provider_enabled"`
	PodEvictionTimeout                      string      `json:"pod_eviction_timeout" yaml:"pod_eviction_timeout" mapstructure:"pod_eviction_timeout"`
	TerminatedPodGCThreshold                int         `json:"terminated_pod_gc_threshold" yaml:"terminated_pod_gc_threshold" mapstructure:"terminated_pod_gc_threshold"`
	AdditionalRSharedMountPoints            []string    `` /* 144-byte string literal not displayed */
	WaitForReady                            int         `json:"wait_for_ready" yaml:"wait_for_ready" mapstructure:"wait_for_ready"`
	SysctlSettings                          interface{} `json:"sysctl_settings,omitempty" yaml:"sysctl_settings,omitempty" mapstructure:"sysctl_settings"`
}

Config are all the settings to configure Kubernetes no matter the platform

func DefaultConfig

func DefaultConfig(envConfig map[string]string) (*Config, error)

DefaultConfig returns the default configuration of the configurator based on the default inventory

func (*Config) LoadNilDefault

func (c *Config) LoadNilDefault()

LoadNilDefault will load assigned defaults when the current value is nil this is usually for dealing with omitted values for backwards compatibility

func (*Config) Map

func (c *Config) Map() (map[string]interface{}, error)

Map converts the current configuration to a map of string of strings

func (*Config) UpdateHosts

func (c *Config) UpdateHosts(tfStateFile string) error

UpdateHosts get the hosts from a Terraform state file TODO: Complete this function

type Configurator

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

Configurator store all the settings from the cluster related to the Configurator

func New

func New(clusterName, platform, address string, port int, hosts Hosts, stateData map[string]interface{}, platformConfig interface{}, config *Config, res []string, basePath string, ui *ui.UI) (*Configurator, error)

New creates a configurator

func (*Configurator) ApplyResources

func (c *Configurator) ApplyResources(export bool) error

ApplyResources applies the Kubernetes manifests after rendering the templates. It may only export the rendered manifests if `export` is true.

func (*Configurator) Configure

func (c *Configurator) Configure() error

Configure will start the process to configure the hosts to have Kubernetes up and running

func (*Configurator) Inventory

func (c *Configurator) Inventory() (*Inventory, error)

Inventory creates an Ansible inventory from the Configurator information

func (*Configurator) RunPlaybook

func (c *Configurator) RunPlaybook() error

RunPlaybook will execute ansible remotely to configure the host to have Kubernetes up and running.

func (*Configurator) Setup

func (c *Configurator) Setup() error

Setup installs and configures Ansible and upload the Ansible roles and inventory

func (*Configurator) UploadCerts

func (c *Configurator) UploadCerts()

UploadCerts uploads the certificate files located in the 'certificates/' directory in the cluster configuration dir

type Host

type Host struct {
	PublicIP   string `json:"public_ip" yaml:"public_ip" mapstructure:"public_ip"`
	PrivateIP  string `json:"private_ip" yaml:"private_ip" mapstructure:"private_ip"`
	PublicDNS  string `json:"public_dns" yaml:"public_dns" mapstructure:"public_dns"`
	PrivateDNS string `json:"private_dns" yaml:"private_dns" mapstructure:"private_dns"`
	RoleName   string `json:"role" yaml:"role" mapstructure:"role"`
	Pool       string `json:"pool" yaml:"pool" mapstructure:"pool"`
	// contains filtered or unexported fields
}

Host is the host configuration

func (*Host) Config

func (h *Host) Config(roleName, username, privateKey, password string) error

Config configures a host

func (*Host) StartShell

func (h *Host) StartShell(in io.Reader, out, err io.Writer) error

StartShell initiate an interactive remote shell to this host

type Hosts

type Hosts []Host

Hosts is a slice of Host

func (Hosts) Config

func (hs Hosts) Config(username, privateKey, password string, applyRoleNameFormat bool) error

Config configures the hosts

func (Hosts) FilterByNode

func (hs Hosts) FilterByNode(ipOrDNS ...string) Hosts

FilterByNode returns all the hosts that contain an IP or DNS from the given list

func (Hosts) FilterByRole

func (hs Hosts) FilterByRole(roles ...string) Hosts

FilterByRole returns all the hosts with the given roles

type Inventory

type Inventory struct {
	All AllInventory `json:"all,omitempty" yaml:"all" mapstructure:"all"`
}

Inventory contain all the variables and childrens of the Ansible inventory

func (*Inventory) JSON

func (i *Inventory) JSON() ([]byte, error)

JSON returns the Inventory structure in JSON format

func (*Inventory) Yaml

func (i *Inventory) Yaml() ([]byte, error)

Yaml returns the Inventory structure in YAML format

type InventoryHost

type InventoryHost struct {
	AnsibleHost   string   `json:"ansible_host,omitempty" yaml:"ansible_host" mapstructure:"ansible_host"`
	PrivateIP     string   `json:"private_ip,omitempty" yaml:"private_ip" mapstructure:"private_ip"`
	PublicIP      string   `json:"public_ip,omitempty" yaml:"public_ip" mapstructure:"public_ip"`
	PrivateDNS    string   `json:"private_dns,omitempty" yaml:"private_dns" mapstructure:"private_dns"`
	PublicDNS     string   `json:"public_dns,omitempty" yaml:"public_dns" mapstructure:"public_dns"`
	FQDN          string   `json:"fqdn,omitempty" yaml:"fqdn" mapstructure:"fqdn"`
	Hostname      string   `json:"hostname,omitempty" yaml:"hostname" mapstructure:"hostname"`
	HostnameShort string   `json:"hostname_short,omitempty" yaml:"hostname_short" mapstructure:"hostname_short"`
	KubeletTaints []string `json:"kubelet_taints,omitempty" yaml:"kubelet_taints" mapstructure:"kubelet_taints"`
	KubeletLabels []string `json:"kubelet_labels,omitempty" yaml:"kubelet_labels" mapstructure:"kubelet_labels"`
}

InventoryHost is a host structure in an Ansible inventory Note: update var ValidAddressInventoryFields if a new field is added

type InventoryHosts

type InventoryHosts struct {
	Hosts map[string]*InventoryHost `json:"hosts,omitempty" yaml:"hosts" mapstructure:"hosts"`
}

InventoryHosts is a hosts structure in an Ansible inventory

type InventoryVariables

type InventoryVariables struct {
	ShellEditingMode                        string      `json:"shell_editing_mode,omitempty" yaml:"shell_editing_mode,omitempty" mapstructure:"shell_editing_mode,omitempty"`
	AddressInventoryField                   string      `json:"address_inventory_field" yaml:"address_inventory_field" mapstructure:"address_inventory_field"`
	AlbDNSName                              string      `json:"alb_dns_name,omitempty" yaml:"alb_dns_name" mapstructure:"alb_dns_name"`                   // Just for AWS.     From provisioner
	VsphereDatacenter                       string      `json:"vsphere_datacenter,omitempty" yaml:"vsphere_datacenter" mapstructure:"vsphere_datacenter"` // Just for vSphere. From provisioner
	VsphereFolder                           string      `json:"vsphere_folder,omitempty" yaml:"vsphere_folder" mapstructure:"vsphere_folder"`             // Just for vSphere. From provisioner
	VsphereDatastore                        string      `json:"vsphere_datastore,omitempty" yaml:"vsphere_datastore" mapstructure:"vsphere_datastore"`    // Just for vSphere. From provisioner
	VsphereNet                              string      `json:"vsphere_net" yaml:"vsphere_net" mapstructure:"vsphere_net"`                                // Just for vSphere. From provisioner
	VsphereServer                           string      `json:"vsphere_server,omitempty" yaml:"vsphere_server" mapstructure:"vsphere_server"`             // Just for vSphere. From environment
	VsphereResourcePool                     string      `json:"vsphere_resource_pool,omitempty" yaml:"vsphere_resource_pool,omitempty" mapstructure:"vsphere_resource_pool"`
	ClusterName                             string      `json:"cluster_name,omitempty" yaml:"cluster_name" mapstructure:"cluster_name"`                               // From top in config file.
	AnsibleUser                             string      `json:"ansible_user,omitempty" yaml:"ansible_user" mapstructure:"ansible_user"`                               // Calculated, depend of platform
	CloudProvider                           string      `json:"cloud_provider,omitempty" yaml:"cloud_provider" mapstructure:"cloud_provider"`                         // Calculated, depend of platform
	CloudProviderEnabled                    bool        `json:"cloud_provider_enabled,omitempty" yaml:"cloud_provider_enabled" mapstructure:"cloud_provider_enabled"` // Calculated, depend of platform
	KubeAPISslPort                          int         `json:"kube_api_ssl_port,omitempty" yaml:"kube_api_ssl_port" mapstructure:"kube_api_ssl_port"`                // From provisioner
	DisableMasterHA                         bool        `json:"disable_master_ha,omitempty" yaml:"disable_master_ha" mapstructure:"disable_master_ha"`                // From provisioner
	KubeVirtualIPApi                        string      `json:"kube_virtual_ip_api,omitempty" yaml:"kube_virtual_ip_api" mapstructure:"kube_virtual_ip_api"`          // From provisioner
	KubeVipAPISslPort                       int         `json:"kube_vip_api_ssl_port,omitempty" yaml:"kube_vip_api_ssl_port" mapstructure:"kube_vip_api_ssl_port"`    // From provisioner
	EtcdLocalProxyEnabled                   bool        `json:"enable_etcd_local_proxy" yaml:"enable_etcd_local_proxy" mapstructure:"enable_etcd_local_proxy"`
	EtcdInitialClusterToken                 string      `json:"etcd_initial_cluster_token,omitempty" yaml:"etcd_initial_cluster_token" mapstructure:"etcd_initial_cluster_token"` // From configurator in config file. This and the following fields
	KubeletMaxPods                          int         `json:"kubelet_max_pods,omitempty" yaml:"kubelet_max_pods" mapstructure:"kubelet_max_pods"`
	KubeletSerializeImagePulls              bool        `` /* 148-byte string literal not displayed */
	KubeProxyMode                           string      `json:"kube_proxy_mode,omitempty" yaml:"kube_proxy_mode,omitempty" mapstructure:"kube_proxy_mode,omitempty"`
	KubeClusterCidr                         string      `json:"kube_cluster_cidr,omitempty" yaml:"kube_cluster_cidr" mapstructure:"kube_cluster_cidr"`
	KubeServicesCidr                        string      `json:"kube_services_cidr,omitempty" yaml:"kube_services_cidr" mapstructure:"kube_services_cidr"`
	KubeServiceIP                           string      `json:"kube_service_ip,omitempty" yaml:"kube_service_ip" mapstructure:"kube_service_ip"`
	KubeAdvertiseAddress                    string      `json:"kube_advertise_address,omitempty" yaml:"kube_advertise_address" mapstructure:"kube_advertise_address"`
	MasterSchedulableEnabled                bool        `json:"master_schedulable_enabled,omitempty" yaml:"master_schedulable_enabled" mapstructure:"master_schedulable_enabled"`
	DockerMaxConcurrentUploads              int         ``                                                                                                                /* 148-byte string literal not displayed */
	DockerMaxConcurrentDownloads            int         ``                                                                                                                /* 154-byte string literal not displayed */
	DockerLogMaxFiles                       string      `json:"docker_log_max_files,omitempty" yaml:"docker_log_max_files,omitempty" mapstructure:"docker_log_max_files"` // docker config takes it as a string
	DockerLogMaxSize                        string      `json:"docker_log_max_size,omitempty" yaml:"docker_log_max_size,omitempty" mapstructure:"docker_log_max_size"`
	DockerRegistryPath                      string      `json:"docker_registry_path,omitempty" yaml:"docker_registry_path" mapstructure:"docker_registry_path"`
	DockerRegistryPort                      int         `json:"registry_port" yaml:"registry_port" mapstructure:"registry_port"`
	DownloadImagesIfMissing                 bool        `json:"download_images_if_missing,omitempty" yaml:"download_images_if_missing" mapstructure:"download_images_if_missing"`
	HAProxyClientTimeout                    string      `json:"haproxy_client_timeout,omitempty" yaml:"haproxy_client_timeout,omitempty" mapstructure:"haproxy_client_timeout"`
	HAProxyServerTimeout                    string      `json:"haproxy_server_timeout,omitempty" yaml:"haproxy_server_timeout,omitempty" mapstructure:"haproxy_server_timeout"`
	DNSAAAADelayEnabled                     bool        `json:"dns_aaaa_delay_enabled,omitempty" yaml:"dns_aaaa_delay_enabled,omitempty" mapstructure:"dns_aaaa_delay_enabled"`
	DNSArgs                                 string      `json:"dns_args,omitempty" yaml:"dns_args" mapstructure:"dns_args"`
	DNSServers                              []string    `json:"dns_servers,omitempty" yaml:"dns_servers" mapstructure:"dns_servers"`
	DNSSearch                               []string    `json:"dns_search,omitempty" yaml:"dns_search" mapstructure:"dns_search"`
	EtcdDefragCrontabHour                   string      `json:"etcd_defrag_crontab_hour,omitempty" yaml:"etcd_defrag_crontab_hour,omitempty" mapstructure:"etcd_defrag_crontab_hour"`
	EtcdLogsCrontabHour                     string      `json:"etcd_logs_crontab_hour,omitempty" yaml:"etcd_logs_crontab_hour" mapstructure:"etcd_logs_crontab_hour"`
	EtcdLogsCrontabMinute                   string      `json:"etcd_logs_crontab_minute,omitempty" yaml:"etcd_logs_crontab_minute" mapstructure:"etcd_logs_crontab_minute"`
	EtcdLogsDaysToKeep                      int         `json:"etcd_logs_days_to_keep,omitempty" yaml:"etcd_logs_days_to_keep" mapstructure:"etcd_logs_days_to_keep"`
	EtcdSnapshotsDirectory                  string      `json:"etcd_snapshots_directory,omitempty" yaml:"etcd_snapshots_directory,omitempty" mapstructure:"etcd_snapshots_directory"`
	UseLocalImages                          bool        `json:"use_local_images,omitempty" yaml:"use_local_images" mapstructure:"use_local_images"`
	ClusterIfaceName                        string      `json:"cluster_iface_name,omitempty" yaml:"cluster_iface_name" mapstructure:"cluster_iface_name"`
	ClusterIface                            string      `json:"cluster_iface,omitempty" yaml:"cluster_iface" mapstructure:"cluster_iface"`
	CniIface                                string      `json:"cni_iface,omitempty" yaml:"cni_iface" mapstructure:"cni_iface"`
	TimeServers                             []string    `json:"time_servers,omitempty" yaml:"time_servers" mapstructure:"time_servers"`
	KubeAuditLogMaxAge                      int         `json:"kube_audit_log_max_age,omitempty" yaml:"kube_audit_log_max_age" mapstructure:"kube_audit_log_max_age"`
	KubeAuditLogMaxBackup                   int         `json:"kube_audit_log_max_backup,omitempty" yaml:"kube_audit_log_max_backup" mapstructure:"kube_audit_log_max_backup"`
	KubeAuditLogMaxSize                     int         `json:"kube_audit_log_max_size,omitempty" yaml:"kube_audit_log_max_size" mapstructure:"kube_audit_log_max_size"`
	NginxIngressEnabled                     bool        `json:"nginx_ingress_enabled,omitempty" yaml:"nginx_ingress_enabled" mapstructure:"nginx_ingress_enabled"`
	NginxIngressControllerProxyBodySize     string      `` /* 161-byte string literal not displayed */
	NginxIngressControllerErrorLogLevel     string      `` /* 161-byte string literal not displayed */
	NginxIngressControllerSslProtocols      string      `` /* 155-byte string literal not displayed */
	NginxIngressControllerProxyReadTimeout  string      `` /* 170-byte string literal not displayed */
	NginxIngressControllerProxySendTimeout  string      `` /* 170-byte string literal not displayed */
	NginxIngressControllerTLSCertLocalPath  string      `` /* 173-byte string literal not displayed */
	NginxIngressControllerTLSKeyLocalPath   string      `` /* 170-byte string literal not displayed */
	NginxIngressControllerBasicAuthUsername string      `` /* 173-byte string literal not displayed */
	NginxIngressControllerBasicAuthPassword string      `` /* 173-byte string literal not displayed */
	DefaultIngressHost                      string      `json:"default_ingress_host,omitempty" yaml:"default_ingress_host" mapstructure:"default_ingress_host"`
	RookEnabled                             bool        `json:"rook_enabled,omitempty" yaml:"rook_enabled" mapstructure:"rook_enabled"`
	RookCephStorageDeviceDirectories        []string    `` /* 128-byte string literal not displayed */
	RookCephStorageDeviceFilter             string      `` /* 134-byte string literal not displayed */
	RookDashboardEnabled                    bool        `json:"rook_dashboard_enabled,omitempty" yaml:"rook_dashboard_enabled" mapstructure:"rook_dashboard_enabled"`
	RookDashboardExternalEnabled            bool        `` /* 134-byte string literal not displayed */
	RookDashboardPort                       int         `json:"rook_dashboard_port,omitempty" yaml:"rook_dashboard_port" mapstructure:"rook_dashboard_port"`
	RookObjectStoreEnabled                  bool        `json:"rook_object_store_enabled,omitempty" yaml:"rook_object_store_enabled" mapstructure:"rook_object_store_enabled"`
	RookObjectStoreRadosGatewayEnabled      bool        `` /* 158-byte string literal not displayed */
	RookFileStoreEnabled                    bool        `json:"rook_file_store_enabled,omitempty" yaml:"rook_file_store_enabled" mapstructure:"rook_file_store_enabled"`
	DefaultStorageclass                     string      `json:"default_storageclass,omitempty" yaml:"default_storageclass" mapstructure:"default_storageclass"`
	HostTimeZone                            string      `json:"host_timezone,omitempty" yaml:"host_timezone,omitempty" mapstructure:"host_timezone"`
	ControlPlaneTimeZone                    string      `json:"controlplane_timezone,omitempty" yaml:"controlplane_timezone,omitempty" mapstructure:"controlplane_timezone"`
	PodEvictionTimeout                      string      `json:"pod_eviction_timeout,omitempty" yaml:"pod_eviction_timeout" mapstructure:"pod_eviction_timeout"`
	TerminatedPodGCThreshold                int         `json:"terminated_pod_gc_threshold,omitempty" yaml:"terminated_pod_gc_threshold" mapstructure:"terminated_pod_gc_threshold"`
	AdditionalRSharedMountPoints            []string    `` /* 144-byte string literal not displayed */
	SysctlSettings                          interface{} `json:"sysctl_settings,omitempty" yaml:"sysctl_settings,omitempty" mapstructure:"sysctl_settings"`
}

InventoryVariables contain all the variables required for the Ansible inventory

func (*InventoryVariables) JSON

func (iv *InventoryVariables) JSON() ([]byte, error)

JSON returns the Inventory Variables structure in JSON format

func (*InventoryVariables) Map

func (iv *InventoryVariables) Map() (map[string]interface{}, error)

Map returns the Inventory Variables structure as a map of strings

type KubeCluster

type KubeCluster struct {
	Children map[string]InventoryHosts `json:"children,omitempty" yaml:"children" mapstructure:"children"`
}

KubeCluster is a kube_cluster structure in an Ansible inventory

type PodsPhaseCount

type PodsPhaseCount struct {
	Total     uint32 // kubernetes doesn't even support as many pods as uint32 max
	Pending   uint32
	Running   uint32
	Succeeded uint32
	Failed    uint32
	Unknown   uint32
}

PodsPhaseCount tracks the count of the phases of the pods

Directories

Path Synopsis
codegen
ansible
This program generates 'code.go' with the Ansible code located in `templates/` and `templates/roles`.
This program generates 'code.go' with the Ansible code located in `templates/` and `templates/roles`.

Jump to

Keyboard shortcuts

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