Documentation
¶
Overview ¶
Package utils -- Utility functions to be used throughout cmd. Kind of decided that this was a pretty decent way of doing shared logic for
cmd.
Basically the same as for pkg, so nothing too special there, but since cmd
has a bit of nesting, it brings up some more questions.
It seems like golang itself does a pattern like this for `base` cmd units,
so this is probably not too shabby.
Index ¶
- Constants
- Variables
- func CopySSHKeyToAuthorizedKeys(log *logrus.Entry, keyPath string, node *Node) error
- func CreateClusterMaster(log *logrus.Entry, node *Node, podNetworkCidr string, loadBalancer *Node, ...) error
- func CreateClusterNode(log *logrus.Entry, node *Node, masters *[]Node, force bool) error
- func DisableSelinuxOnRemote(node *Node) error
- func DisableSwapOnRemote(node *Node) error
- func EnsureSSHWithoutPassword(log *logrus.Entry, node *Node) error
- func FetchKubeconfig(log *logrus.Entry, node *Node, merge bool) error
- func FollowLogsAndPollUntilJobComplete(log *logrus.Entry, kubectl *kubeutil.Kubectl, job string, maxAttempts int, ...) error
- func FollowLogsIfContainersRunning(kubectl *kubeutil.Kubectl, job string) error
- func GetPodsForJob(kubectl *kubeutil.Kubectl, job string) (*[]string, error)
- func InitLoadBalancer(log *logrus.Entry, node *Node) error
- func KubeadmGetClusterCertificateKey(log *logrus.Entry, node *Node) (string, error)
- func KubeadmResetRemote(log *logrus.Entry, kubectl *kubeutil.Kubectl, node *Node, deleteLocalData bool, ...) error
- func KubectlApplyF(kubectl *kubeutil.Kubectl, path string) error
- func KubectlApplyStdIn(kubectl *kubeutil.Kubectl, stdin string) error
- func KubectlCreateStdIn(kubectl *kubeutil.Kubectl, stdin string) error
- func KubectlDeleteF(kubectl *kubeutil.Kubectl, path string) error
- func KubectlDeleteStdIn(kubectl *kubeutil.Kubectl, stdin string) error
- func KubectlGetCreateStdIn(kubectl *kubeutil.Kubectl, stdin string) (string, error)
- func ReplaceParametersInDirectoryCopy(dir string, parameters []string) (string, error)
- func ReplaceParametersInFile(path string, parameters []string) (string, error)
- func ReplaceParametersInString(str string, parameters []string) (string, error)
- func ReplaceParametersWithSubstitutor(t *TextSubstitutor, parameters []string) (string, error)
- func SetHostname(log *logrus.Entry, node *Node, hostname string, force bool) error
- func SetLoadBalancerHosts(log *logrus.Entry, node *Node, masters *[]Node) error
- func TaintNodeByHost(kubectl *kubeutil.Kubectl, node *Node, taint string) error
- func TestCanSSHWithoutPassword(node *Node) error
- func TryConfigureSSH(log *logrus.Entry, node *Node) error
- type BuildSpec
- type ExecSpec
- type Job
- type JobStatus
- type Node
- func (node *Node) ConnectionString() string
- func (node *Node) IsHypervisor() bool
- func (node *Node) IsKubernetesNode() bool
- func (node *Node) IsLoadBalancer() bool
- func (node *Node) IsMaster() bool
- func (node *Node) IsMasterAndNode() bool
- func (node *Node) IsNode() bool
- func (node *Node) IsRoleValid() bool
- type NodeRole
- type NodeStatus
- type Resource
- type ResourceType
- type TextSubstitutor
- type VMImageSpec
- type VMs
Constants ¶
const ( JobStatusUnknown JobStatus = 0 JobStatusRunning = 1 JobStatusComplete = 2 JobStatusFailed = 3 )
Variables ¶
var DockerDaemonJson = `` /* 259-byte string literal not displayed */
var IpForward = `1
`
var K8SConf = `net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
`
var NginxConfig = `` /* 450-byte string literal not displayed */
Functions ¶
func CreateClusterMaster ¶
func CreateClusterNode ¶
func DisableSelinuxOnRemote ¶
func DisableSwapOnRemote ¶
func InitLoadBalancer ¶ added in v0.17.0
Just forwards to `SetLoadBalancerHosts`. There may be a time where this does more.
func KubeadmGetClusterCertificateKey ¶ added in v0.17.0
func KubeadmResetRemote ¶
func KubectlDeleteF ¶ added in v0.10.0
func KubectlDeleteStdIn ¶ added in v0.10.0
func KubectlGetCreateStdIn ¶
func ReplaceParametersInDirectoryCopy ¶ added in v0.21.0
ReplaceParametersInDirectoryCopy - Copy the provided directory, and replace
parameters in the files.
Returns the temp path to the copied directory, and the caller must clean up
that directory itself, unless an error occurs.
func ReplaceParametersInFile ¶ added in v0.21.0
func ReplaceParametersInString ¶ added in v0.21.0
func ReplaceParametersWithSubstitutor ¶ added in v0.21.0
func ReplaceParametersWithSubstitutor(t *TextSubstitutor, parameters []string) (string, error)
func SetHostname ¶
func SetLoadBalancerHosts ¶ added in v0.17.0
func TaintNodeByHost ¶
func TestCanSSHWithoutPassword ¶
Attempt to SSH into a machine without allowing password authentication. Also disables strict host checking to prevent the unattended nature of the
execution from causing the script to fail.
Types ¶
type Job ¶ added in v0.14.0
Job - Properties that can appear in any ephemeral job definition. TODO: Allow jobs to define max retry parameters, or accept them on the
command line.
type Node ¶ added in v0.14.0
type Node struct { Name string Role string Host string Hypervisor string Engine string User string Datastore string Network string Cpu int Memory int }
Node - Defines a networked resource on which operations will typically be
executed.
Datastore is really only used for Hypervisors, but whatever; it's not
incredibly intuitive how to have non-homogenous types in viper lists.
If a more concrete type is eventually used, the Role property should become
an enum/bitfield.
func (*Node) ConnectionString ¶ added in v0.14.0
ConnectionString - Get the node's connection string
func (*Node) IsHypervisor ¶ added in v0.15.0
IsHypervisor - Whether or not this node is a hypervisor node.
func (*Node) IsKubernetesNode ¶ added in v0.15.0
IsKubernetesNode - Whether or not this node has one of the Kubernetes
roles.
func (*Node) IsLoadBalancer ¶ added in v0.17.0
IsLoadBalancer - Whether or not this node is a load-balancer node.
func (*Node) IsMaster ¶ added in v0.14.0
IsMaster - Whether or not this node is a control plane node.
func (*Node) IsMasterAndNode ¶ added in v0.14.0
IsMasterAndNode - Whether or not this node plays the roles of both control
plane and worker node.
func (*Node) IsRoleValid ¶ added in v0.14.0
IsRoleValid - Whether or not the node has a role that has been implemented.
type NodeRole ¶ added in v0.18.1
type NodeRole int
const ( // NodeRoleHypervisor - Host that manages the other nodes listed. NodeRoleHypervisor NodeRole = iota // NodeRoleLoadBalancer - API Server load balancer VM that runs an // instance of NGINX pointing at the Master nodes' API servers. NodeRoleLoadBalancer // NodeRoleMaster - Control plane nodes NodeRoleMaster // NodeRoleMasterAndNode - For small clusters, a machine that acts as both // master and node. // Master node with the master:NoSchedule taint removed. NodeRoleMasterAndNode // NodeRoleNode - Plain Kubernetes node. NodeRoleNode )
type NodeStatus ¶ added in v0.23.0
type NodeStatus int
const ( // be determined what the state of this node is. // Maybe the node exists, but it isn't serving properly, but in general, // the node was found, but isn't but isn't doing what it's supposed to. NodeStatusUnavailable NodeStatus = iota // NodeStatusHealthy - Node is doing exactly what it should be doing. NodeStatusHealthy // NodeStatusDoesNotExist - Node is not available on Kubernetes, and not // visible on its hypervisor. NodeStatusDoesNotExist )
func (NodeStatus) String ¶ added in v0.23.0
func (ns NodeStatus) String() string
type Resource ¶ added in v0.14.0
type Resource struct { Name string File string Inline string Parameters []string FileParameters []string Build BuildSpec Job string Exec ExecSpec Tags []string }
Resource - Properties that can appear in any resources. There may be a better way of doing this, but with a pretty generic list of
items appearing in a yaml file, maybe not.
func (*Resource) GetType ¶ added in v0.14.0
func (resource *Resource) GetType() (ResourceType, error)
GetType - Scan through defined properties, and return the resource type
that the resource appears to implement.
type ResourceType ¶ added in v0.14.0
type ResourceType int
ResourceType enum to differentiate the types of resource definitions that
can appear in the hope yaml file.
const ( // ResourceTypeUnknown - No resource type could be determined for the // resource being evaluated. ResourceTypeUnknown ResourceType = iota // ResourceTypeFile - Provide a path to a local file/URL to a remote file // to apply. ResourceTypeFile // ResourceTypeInline - Provide an inline yaml definition of resources to // apply. ResourceTypeInline // ResourceTypeDockerBuild - Build a docker image with the given context // path, and push it to the specified repository. ResourceTypeDockerBuild // ResourceTypeJob - Wait for a job with the given name to finish // executing. ResourceTypeJob // ResourceTypeExec - Execute a script in a running pod/container. ResourceTypeExec )
func (ResourceType) String ¶ added in v0.14.0
func (rt ResourceType) String() string
Not using stringer generation because of user-provided strings. Not using arrays to prevent ordering issues.
type TextSubstitutor ¶
type TextSubstitutor struct {
Bytes *[]byte
}
func NewTextSubstitutorFromBytes ¶
func NewTextSubstitutorFromBytes(bytes []byte) *TextSubstitutor
func NewTextSubstitutorFromString ¶
func NewTextSubstitutorFromString(str string) *TextSubstitutor
func TextSubstitutorFromFilepath ¶
func TextSubstitutorFromFilepath(filepath string) (*TextSubstitutor, error)
func (*TextSubstitutor) SubstituteTextFromEnv ¶
func (t *TextSubstitutor) SubstituteTextFromEnv(envVarsNames []string) error
func (*TextSubstitutor) SubstituteTextFromMap ¶
func (t *TextSubstitutor) SubstituteTextFromMap(variables map[string]string) error
type VMImageSpec ¶ added in v0.15.0
VMImageSpec - Defines the structure needed to populate a Packer job to
build a VM Image.