Documentation
¶
Index ¶
- Constants
- Variables
- func GetWorkdirFromConfig(config kkcorev1.Config) string
- func Getenv(env Environment) string
- func Host2ProviderID(clusterName, host string) *string
- func NewTestPlaybook(hosts []string) (ctrlclient.Client, *kkcorev1.Playbook, error)
- func ProviderID2Host(clusterName string, providerID *string) string
- type Environment
Constants ¶
const ( // VariableLocalHost is the default local host name in inventory. VariableLocalHost = "localhost" // VariableIPv4 is the ipv4 in inventory. VariableIPv4 = "internal_ipv4" // VariableIPv6 is the ipv6 in inventory. VariableIPv6 = "internal_ipv6" // VariableGroups the value is a host_name slice VariableGroups = "groups" // VariableConnector is connector parameter in inventory. VariableConnector = "connector" // VariableConnectorType is connected type for VariableConnector. VariableConnectorType = "type" // VariableConnectorHost is connected address for VariableConnector. VariableConnectorHost = "host" // VariableConnectorURL is connected port for VariableConnectorURL. VariableConnectorURL = "url" // VariableConnectorPort is connected address for VariableConnector. VariableConnectorPort = "port" // VariableConnectorUser is connected user for VariableConnector. VariableConnectorUser = "user" // VariableConnectorUserName is connected username for VariableConnector. VariableConnectorUserName = "username" // VariableConnectorPassword is connected type for VariableConnector. VariableConnectorPassword = "password" // VariableConnectorPrivateKey is connected auth key for VariableConnector. VariableConnectorPrivateKey = "private_key" // VariableConnectorPrivateKeyContent is connected auth key content for VariableConnector. VariableConnectorPrivateKeyContent = "private_key_content" // VariableConnectorKubeconfig is connected auth key for VariableConnector. VariableConnectorKubeconfig = "kubeconfig" // VariableConnectorToken is connected auth key for VariableConnector. VariableConnectorToken = "token" // VariableGatherFactsCache type in runtimedir. support jsonfile, yamlfile, memory. VariableGatherFactsCache = "fact_caching" )
variable specific key in system
const ( // VariableInventoryName the value which defined in inventory.spec.host. VariableInventoryName = "inventory_hostname" // VariableHostName the value is node hostname, default VariableInventoryName. // If VariableInventoryName is "localhost". try to set the actual name. VariableHostName = "hostname" // VariableGlobalHosts the value is host_var which defined in inventory. VariableGlobalHosts = "hostvars" // VariableGroupsAll the value is a all host_name slice of VariableGroups. VariableGroupsAll = "all" // VariableUnGrouped the value is a all host_name slice of VariableGroups. VariableUnGrouped = "ungrouped" )
const ( // VariableOS the value is os information. VariableOS = "os" // VariableOSRelease the value is os-release of VariableOS. VariableOSRelease = "release" // VariableOSKernelVersion the value is kernel version of VariableOS. VariableOSKernelVersion = "kernel_version" // VariableOSHostName the value is hostname of VariableOS. VariableOSHostName = "hostname" // VariableOSArchitecture the value is architecture of VariableOS. VariableOSArchitecture = "architecture" // VariableProcess the value is process information. VariableProcess = "process" // VariableProcessCPU the value is cpu info of VariableProcess. VariableProcessCPU = "cpuInfo" // VariableProcessMemory the value is memory info of VariableProcess. VariableProcessMemory = "memInfo" )
const ( // CAPKKWorkdir is the work dir for capkk playbook. CAPKKWorkdir = "/kubekey/" // CAPKKProjectdir is the project dir for capkk playbook. CAPKKProjectdir = "/capkk/project/" // CAPKKBinarydir is the path of binary. CAPKKBinarydir = "/capkk/kubekey/" // CAPKKCloudConfigPath is the cloud-config path. CAPKKCloudConfigPath = "/capkk/cloud/cloud-config" // CAPKKCloudKubeConfigPath is the cloud-config path. CAPKKCloudKubeConfigPath = "/capkk/cloud/kubeconfig" // CAPKKPlaybookHostCheck is the playbook for host check. CAPKKPlaybookHostCheck = "playbooks/host_check.yaml" // CAPKKPlaybookAddNode is the playbook for add node. CAPKKPlaybookAddNode = "playbooks/add_node.yaml" // CAPKKPlaybookDeleteNode is the playbook for delete node. CAPKKPlaybookDeleteNode = "playbooks/delete_node.yaml" )
const ( // SSHVerifyStatusSuccess means ssh connect success SSHVerifyStatusSuccess = "success" // SSHVerifyStatusFailed means ssh connect failed SSHVerifyStatusFailed = "ssh_failed" // SSHVerifyStatusOffline means ssh target offline SSHVerifyStatusOffline = "offline" // SSHVerifyStatusSSHIncomplete means ssh connect information incomplete SSHVerifyStatusSSHIncomplete = "ssh_incomplete" // SSHVerifyStatusUnreachable means host server cannot connect to target ssh SSHVerifyStatusUnreachable = "unreachable" )
const BinaryDir = "binary_dir"
BinaryDir refers to a portable software package that can typically be bundled into an offline package. By default, its path is set to {{ .work_dir/kubekey }}.
const BinaryImagesDir = "images"
BinaryImagesDir stores image files, including blobs and manifests.
const KubernetesDir = "kubernetes"
KubernetesDir represents the remote host directory for each Kubernetes connection created during playbook execution.
const ( // PermDirPublic means public permission of directory, something like os.ModePerm PermDirPublic os.FileMode = 0755 )
const ProjectPlaybooksDir = "playbooks"
ProjectPlaybooksDir is a fixed directory name under a project, used to store executable playbook files.
const ProjectRolesDefaultsDir = "defaults"
ProjectRolesDefaultsDir is a fixed directory name under a role, used to set default variables for the role.
const ProjectRolesDir = "roles"
ProjectRolesDir is a fixed directory name under a project, used to store roles required by playbooks.
const ProjectRolesFilesDir = "files"
ProjectRolesFilesDir is a fixed directory name under a role, used to store files required by tasks.
const ProjectRolesMetaDir = "meta"
ProjectRolesMetaDir is a fixed directory name under a role, used to store meta information such as dependencies.
const ProjectRolesTasksDir = "tasks"
ProjectRolesTasksDir is a fixed directory name under a role, used to store tasks required by the role.
const ProjectRolesTemplateDir = "templates"
ProjectRolesTemplateDir is a fixed directory name under a role, used to store templates required by tasks.
const ProjectsDir = "projects_dir"
ProjectsDir stores runnable projects. By default, its path is set to {{ .work_dir/projects }}.
const RuntimeDir = "runtime"
RuntimeDir used to store runtime data for the current task execution. By default, its path is set to {{ .work_dir/runtime }}.
const RuntimeGatherFactsCacheDir = "gather_facts_caches"
RuntimeGatherFactsCacheDir is a fixed directory name under runtime, used to store cached host facts gathered during execution.
const RuntimePlaybookDir = "playbooks"
RuntimePlaybookDir stores playbook resources created during playbook execution.
const RuntimePlaybookVariableDir = "variable"
RuntimePlaybookVariableDir is a fixed directory name under runtime, used to store task execution parameters.
const ScriptsDir = "scripts_dir"
ScriptsDir stores custom scripts. By default, its path is set to {{ .work_dir/scripts }}.
const (
// VariableItem for "loop" argument when run a task.
VariableItem = "item"
)
const VarsDir = "vars"
VarsDir is a directory name for vars
const Workdir = "work_dir"
Workdir is the user-specified working directory. By default, it is the same as the directory where the KubeKey command is executed.
Variables ¶
var ( // Shell specifies which shell operator uses in local connector Shell = Environment{/* contains filtered or unexported fields */} // ExecutorVerbose specifies the verbosity level used in playbook pod ExecutorVerbose = Environment{/* contains filtered or unexported fields */} // ExecutorImage specifies the container image used in playbook pod ExecutorImage = Environment{/* contains filtered or unexported fields */} // ExecutorImagePullPolicy specifies the image pull policy used in playbook pod ExecutorImagePullPolicy = Environment{/* contains filtered or unexported fields */} // ExecutorClusterRole specifies the cluster role used in playbook pod ExecutorClusterRole = Environment{/* contains filtered or unexported fields */} // CapkkGroupControlPlane specifies the control plane groups for capkk playbook CapkkGroupControlPlane = Environment{/* contains filtered or unexported fields */} // CapkkGroupWorker specifies the worker groups for capkk playbook CapkkGroupWorker = Environment{/* contains filtered or unexported fields */} // CapkkVolumeBinary specifies a persistent volume containing the CAPKKBinarydir for capkk playbook, used in offline installer CapkkVolumeBinary = Environment{/* contains filtered or unexported fields */} // CapkkVolumeProject specifies a persistent volume containing the CAPKKProjectdir for capkk playbook CapkkVolumeProject = Environment{/* contains filtered or unexported fields */} // CapkkVolumeWorkdir specifies the working directory for capkk playbook CapkkVolumeWorkdir = Environment{/* contains filtered or unexported fields */} )
var ( // Scheme is the default instance of runtime.Scheme to which types in the Kubernetes API are already registered. // NOTE: If you are copying this file to start a new api group, STOP! Copy the // extensions group instead. This Scheme is special and should appear ONLY in // the api group, unless you really know what you're doing. Scheme = newScheme() // CodecFactory provides access to encoding and decoding for the scheme CodecFactory = serializer.NewCodecFactory(Scheme) // ParameterCodec handles versioning of objects that are converted to query parameters. ParameterCodec = runtime.NewParameterCodec(Scheme) )
Functions ¶
func GetWorkdirFromConfig ¶
GetWorkdirFromConfig retrieves the working directory from the provided configuration. If the 'workdir' value is set in the configuration and is a string, it returns that value. If the 'workdir' value is not set or is not a string, it logs an informational message and attempts to get the current working directory of the process. If it fails to get the current working directory, it logs another informational message and returns a default directory path "/opt/kubekey".
func Getenv ¶
func Getenv(env Environment) string
Getenv retrieves the value of the environment variable. If the environment variable is not set, it returns the default value specified in the Environment struct.
func Host2ProviderID ¶
Host2ProviderID converts a cluster name and host into a provider ID string. It returns a pointer to a string in the format "kk://<cluster_name>/<host>".
func NewTestPlaybook ¶
NewTestPlaybook creates a fake controller-runtime client, an Inventory resource with the given hosts, and returns the client and a Playbook resource referencing the created Inventory. This is intended for use in unit tests.
func ProviderID2Host ¶
ProviderID2Host extracts the host name from a provider ID string. It takes a cluster name and provider ID pointer, and returns the host portion by trimming off the "kk://<cluster_name>/" prefix. If providerID is nil, returns an empty string.
Types ¶
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
Environment represents an environment variable with its name and default value