Documentation ¶
Index ¶
- Constants
- func RunKubectlApply(ctx context.Context, r plan.Runner, args KubectlApplyArgs, fname string) error
- func RunKubectlRemoteApply(ctx context.Context, remoteURL string, runner plan.Runner) error
- func ToState(v interface{}) plan.State
- func WithoutProxy(script string) string
- func WriteFile(ctx context.Context, content []byte, dstPath string, perm os.FileMode, ...) error
- type Base
- type Deb
- func (d *Deb) Apply(ctx context.Context, runner plan.Runner, diff plan.Diff) (propagate bool, err error)
- func (d *Deb) QueryState(ctx context.Context, runner plan.Runner) (plan.State, error)
- func (d *Deb) State() plan.State
- func (d *Deb) Undo(ctx context.Context, runner plan.Runner, current plan.State) error
- func (d *Deb) WouldChangeState(ctx context.Context, r plan.Runner) (bool, error)
- type Dir
- type File
- type GatherFactFunc
- type KubeSecret
- func (ks *KubeSecret) Apply(ctx context.Context, runner plan.Runner, diff plan.Diff) (bool, error)
- func (ks *KubeSecret) QueryState(ctx context.Context, runner plan.Runner) (plan.State, error)
- func (ks *KubeSecret) State() plan.State
- func (ks *KubeSecret) Undo(ctx context.Context, runner plan.Runner, current plan.State) error
- type KubeadmInit
- type KubeadmJoin
- type KubectlAnnotateSingleNode
- type KubectlApply
- type KubectlApplyArgs
- type KubectlWait
- type OS
- func (p *OS) Apply(ctx context.Context, r plan.Runner, _ plan.Diff) (bool, error)
- func (p *OS) GetSELinuxStatus(ctx context.Context) (SELinuxStatus, SELinuxMode, error)
- func (p *OS) HasCommand(ctx context.Context, cmd string) (bool, error)
- func (p *OS) IsOSInContainerVM(ctx context.Context) (bool, error)
- func (p *OS) IsSELinuxMode(ctx context.Context, mode string) (bool, error)
- func (p *OS) QueryState(ctx context.Context, r plan.Runner) (plan.State, error)
- func (p *OS) State() plan.State
- func (p *OS) Undo(ctx context.Context, r plan.Runner, current plan.State) error
- type PkgType
- type RPM
- func (p *RPM) Apply(ctx context.Context, r plan.Runner, diff plan.Diff) (bool, error)
- func (p *RPM) QueryState(ctx context.Context, r plan.Runner) (plan.State, error)
- func (p *RPM) State() plan.State
- func (p *RPM) Undo(ctx context.Context, r plan.Runner, current plan.State) error
- func (p *RPM) WouldChangeState(ctx context.Context, r plan.Runner) (bool, error)
- type Run
- type SELinuxMode
- type SELinuxStatus
- type SecretData
- type Service
Constants ¶
const ( // ServiceInactive is a non-started service. ServiceInactive = "inactive" // ServiceActivating is a starting service. ServiceActivating = "activating" // ServiceActive is a started service. ServiceActive = "active" // ServiceFailed is a service that failed to start ServiceFailed = "failed" )
Variables ¶
This section is empty.
Functions ¶
func RunKubectlApply ¶ added in v0.0.4
func RunKubectlRemoteApply ¶ added in v0.0.4
func WithoutProxy ¶
Types ¶
type Base ¶
type Base struct{}
Base can be embedded into a struct to provide a default implementation of plan.Resource.
func (*Base) QueryState ¶
QueryState implements plan.Resource.
type Deb ¶
type Deb struct { Name string `structs:"name"` // Suffix is either "=" followed by the version, or "/" followed by the release stream (stable|testing|unstable). // Examples: // Name: "busybox" // Name: "busybox", Suffix: "/stable" // Name: "busybox", Suffix: "=1:1.27.2-2ubuntu3.2" Suffix string `structs:"suffix"` }
Deb represents a .deb package.
func DebResourceFromPackage ¶
func DebResourceFromPackage(p debPkgInfo) *Deb
func (*Deb) QueryState ¶
type Dir ¶
type Dir struct { // Path at which to create directory Path fmt.Stringer `structs:"path,omitempty"` // RecursiveDelete makes the undo operation recursive RecursiveDelete bool }
Dir represents a directory on the file system.
func (*Dir) QueryState ¶
QueryState implements plan.Resource.
type File ¶
type File struct { // Source is a path to a local file. Only of of (Source, Content) can be // specified at once. Source string `structs:"source,omitempty"` // Content is the file content. Only of of (Source, Content) can be specified // at once. Content string `structs:"content,omitempty"` // Destination is the file destination path (required). Destination string `structs:"destination"` // File MD5 checksum. We use md5sum as it's part of coreutils and even part of // the default alpine image. Checksum string `structs:"checksum" plan:"hide"` }
File represents a file on the file system.
func (*File) QueryState ¶
QueryState implements plan.Resource.
type KubeSecret ¶
type KubeSecret struct { Base // SecretName is the name of the secret to read SecretName string `structs:"secretName"` // Checksum contains the sha256 checksum of the secret data Checksum [sha256.Size]byte `structs:"checksum"` // DestinationDirectory is the location in which to write stored file data DestinationDirectory string `structs:"destinationDirectory"` // SecretData holds the actual secret contents -- not serialized SecretData SecretData `structs:"-" plan:"hide"` // FileNameTransform transforms a secret key into the file name for its contents FileNameTransform func(string) string }
KubeSecret writes secrets to the filesystem where they can be picked up by daemons
func NewKubeSecretResource ¶
func NewKubeSecretResource(secretName string, secretData SecretData, destinationDirectory string, fileNameTransform func(string) string) (*KubeSecret, error)
NewKubeSecretResource creates a new object from secret data
func (*KubeSecret) QueryState ¶
type KubeadmInit ¶ added in v0.0.4
type KubeadmInit struct { Base // PublicIP is public IP of the master node we are trying to setup here. PublicIP string `structs:"publicIP"` // PrivateIP is private IP of the master node we are trying to setup here. PrivateIP string `structs:"privateIP"` // NodeName, if non-empty, will override the default node name guessed by kubeadm. NodeName string // KubeletConfig groups all options & flags which need to be passed to kubelet. KubeletConfig *config.KubeletConfig `structs:"kubeletConfig"` // ConntrackMax is the maximum number of NAT connections for kubeproxy to track (0 to leave as-is). ConntrackMax int32 `structs:"conntrackMax"` // UseIPTables controls whether the following command is called or not: // sysctl net.bridge.bridge-nf-call-iptables=1 // prior to running kubeadm init. UseIPTables bool `structs:"useIPTables"` // kubeadmInitScriptPath is the path to the "kubeadm init" script to use. KubeadmInitScriptPath string `structs:"kubeadmInitScriptPath"` // IgnorePreflightErrors is optionally used to skip kubeadm's preflight checks. IgnorePreflightErrors []string `structs:"ignorePreflightErrors"` // SSHKeyPath is the path to the private SSH key used by WKS to SSH into // nodes to add/remove them to/from the Kubernetes cluster. Only one of SSHKeyPath // and SSHKey may be specified SSHKeyPath string `structs:"sshKeyPath"` // SSHKey is the private SSH key used by WKS to SSH into // nodes to add/remove them to/from the Kubernetes cluster. Only one of SSHKeyPath // and SSHKey may be specified SSHKey string `structs:"-" plan:"hide"` // BootstrapToken is the token used by kubeadm init and kubeadm join to // safely form new clusters. BootstrapToken *kubeadmapi.BootstrapTokenString `structs:"bootstrapToken"` // The version of Kubernetes to install KubernetesVersion string `structs:"kubernetesVersion"` // ControlPlaneEndpoint is the IP:port of the control plane load balancer. // Default: localhost:6443 // See also: https://kubernetes.io/docs/setup/independent/high-availability/#stacked-control-plane-and-etcd-nodes ControlPlaneEndpoint string `structs:"controlPlaneEndpoint"` // Cloud provider setting which is needed for kubeadm and kubelet CloudProvider string `structs:"cloudProvider"` // ImageRepository sets the container registry to pull images from. If empty, // `k8s.gcr.io` will be used by default. ImageRepository string `structs:"imageRepository"` // AssetDescriptions specifies the image repository and image tag for each potentially overridden // asset (currently, DNS, Etcd, and Kubernetes) AssetDescriptions map[string]kubeadmutil.AssetDescription `structs:"assetDescriptions"` // AdditionalSANs can hold additional SANs to add to the API server certificate. AdditionalSANs []string // The namespace in which to init kubeadm Namespace fmt.Stringer // Extra arguments to pass to the APIServer ExtraAPIServerArgs map[string]string // The IP range for service VIPs ServiceCIDRBlock string // PodCIDRBlock is the subnet used by pods. PodCIDRBlock string }
KubeadmInit represents an attempt to init a Kubernetes node via kubeadm.
func (*KubeadmInit) Apply ¶ added in v0.0.4
Apply implements plan.Resource. TODO: find a way to make this idempotent. TODO: should such a resource be split into smaller resources?
func (*KubeadmInit) State ¶ added in v0.0.4
func (ki *KubeadmInit) State() plan.State
State implements plan.Resource.
type KubeadmJoin ¶
type KubeadmJoin struct { Base // IsMaster should be true if this node should join as a master, or false otherwise. IsMaster bool `structs:"isMaster"` // NodeIP is the IP of the node trying to join the cluster. NodeIP string `structs:"nodeIP"` // NodeName, if non-empty, will override the default node name guessed by kubeadm. NodeName string // MasterIP is the IP of the master node to connect to in order to join the cluster -- // hidden because the value can change in multi-master configurations but should not make the node plan // appear to have changed. MasterIP string `structs:"masterIP" plan:"hide"` // MasterPort is the port of the master node to connect to in order to join the cluster. MasterPort int `structs:"masterPort"` // Token is used to authenticate with the Kubernetes API server. Token string `structs:"token" plan:"hide"` // DiscoveryTokenCaCertHash is used to validate that the root CA public key of the cluster we are trying to join matches. DiscoveryTokenCaCertHash string `structs:"discoveryTokenCaCertHash" plan:"hide"` // CertificateKey is used to add master nodes to the cluster. CertificateKey string `structs:"certificateKey" plan:"hide"` // IgnorePreflightErrors is optionally used to skip kubeadm's preflight checks. IgnorePreflightErrors []string `structs:"ignorePreflightErrors"` // External Load Balancer name or IP address to be used instead of the master's IP ControlPlaneEndpoint string `structs:"controlPlaneEndpoint"` // Kubernetes Version is used to prepare different parameters KubernetesVersion string `structs:"version"` }
KubeadmJoin represents an attempt to join a Kubernetes node via kubeadm.
func (*KubeadmJoin) Apply ¶
Apply implements plan.Resource. TODO: find a way to make this idempotent. TODO: should such a resource be splitted in smaller resources?
func (*KubeadmJoin) State ¶
func (kj *KubeadmJoin) State() plan.State
State implements plan.Resource.
type KubectlAnnotateSingleNode ¶ added in v0.0.4
type KubectlAnnotateSingleNode struct { Base Key string // Which annotation to apply Value string // Value of annotation }
KubectlAnnotateSingleNode is a resource to apply an annotation to the only node in a cluster
func (*KubectlAnnotateSingleNode) Apply ¶ added in v0.0.4
func (ka *KubectlAnnotateSingleNode) Apply(ctx context.Context, runner plan.Runner, diff plan.Diff) (bool, error)
Apply fetches the node name and performs a "kubectl annotate".
func (*KubectlAnnotateSingleNode) State ¶ added in v0.0.4
func (ka *KubectlAnnotateSingleNode) State() plan.State
State implements plan.Resource.
type KubectlApply ¶ added in v0.0.4
type KubectlApply struct { Base // Filename is the remote manifest file name. // Only provide this if you do NOT provide ManifestPath or ManifestURL. Filename fmt.Stringer `structs:"filename"` // Suffix to append to image tags if required (e.g. EKS-D has a special tag suffix of "-eks-1-18-1") ImageSuffix fmt.Stringer `structs:"imageSuffix:omitempty"` // Manifest is the actual YAML/JSON content of the manifest to apply. // If this is provided, then there is no need to provide ManifestPath, but // Filename should be provided in order to name the remote manifest file. Manifest []byte `structs:"manifest"` // ManifestPath is the path to the manifest to apply. // If this is provided, then there is no need to provide Manifest. ManifestPath fmt.Stringer `structs:"manifestPath"` // ManifestURL is the URL of a remote manifest; if specified, // neither Filename, Manifest, nor ManifestPath should be specified. ManifestURL fmt.Stringer `structs:"manifestURL"` // WaitCondition, if not empty, makes Apply() perform "kubectl wait --for=<value>" on the resource. Namespace fmt.Stringer `structs:"namespace"` // OpaqueManifest is an alternative to Manifest for a resource to // apply whose content should not be exposed in a serialized plan. // If this is provided, then there is no need to provide // ManifestPath, but Filename should be provided in order to name // the remote manifest file. OpaqueManifest []byte `structs:"-" plan:"hide"` // ManifestPath is the path to the manifest to apply. // If this is provided, then there is no need to provide Manifest. // For example, waiting for "condition=established" is required after creating a CRD - see issue #530. WaitCondition string `structs:"afterApplyWaitsFor"` }
KubectlApply is a resource applying the provided manifest. It doesn't realise any state, Apply will always apply the manifest.
func (*KubectlApply) Apply ¶ added in v0.0.4
func (ka *KubectlApply) Apply(ctx context.Context, runner plan.Runner, diff plan.Diff) (bool, error)
Apply performs a "kubectl apply" as specified in the receiver.
func (*KubectlApply) State ¶ added in v0.0.4
func (ka *KubectlApply) State() plan.State
State implements plan.Resource.
type KubectlApplyArgs ¶ added in v0.0.4
type KubectlWait ¶ added in v0.0.4
type KubectlWait struct { Base // Namespace specifies the namespace in which to search for the object being waited on WaitNamespace string `structs:"namespace"` // WaitType specifies the object type to wait for WaitType string `structs:"typeWaitedFor"` // WaitSelector, if not empty, specifies which instances of the type to wait for WaitSelector string `structs:"itemsWaitedFor"` // WaitCondition specifies the condition to wait for WaitCondition string `structs:"waitFor"` // WaitTimeout, if specified, indicates how long to wait for the WaitCondition to become true before failing (default 30s) WaitTimeout string `structs:"waitTimeout"` }
KubectlWait waits for an object to reach a required state
func (*KubectlWait) Apply ¶ added in v0.0.4
Apply performs a "kubectl wait" as specified in the receiver.
func (*KubectlWait) State ¶ added in v0.0.4
func (kw *KubectlWait) State() plan.State
State implements plan.Resource.
type OS ¶
type OS struct { MachineID string `structs:"MachineID"` SystemUUID string `structs:"SystemUUID"` // contains filtered or unexported fields }
OS is a set of OS properties.
func (*OS) GetSELinuxStatus ¶
func (p *OS) GetSELinuxStatus(ctx context.Context) (SELinuxStatus, SELinuxMode, error)
func (*OS) IsSELinuxMode ¶
func (*OS) QueryState ¶
QueryState implements plan.Resource.
type RPM ¶
type RPM struct { Name string `structs:"name"` // Version is optional Version string `structs:"version,omitempty"` Release string `structs:"release,omitempty"` IgnoreOtherVersions bool `structs:"ignoreOtherVersions,omitempty"` DisableExcludes string `structs:"disableExcludes,omitempty"` }
RPM represents an RPM package.
It isn't legal to provide a Release if no Version is specified. TODO: What about epoch?
func (*RPM) QueryState ¶
QueryState implements plan.Resource.
type Run ¶
type Run struct { Base Script fmt.Stringer `structs:"script"` UndoScript fmt.Stringer `structs:"undoScript,omitempty"` UndoResource plan.Resource `structs:"undoResource,omitempty"` Output *string // for later resources to use }
Run is a resource running a script (which can be just a single command). Run doesn't realise any state, Apply will always run the given script.
type SELinuxMode ¶
type SELinuxMode int
const ( SELinuxModeUnknown SELinuxMode = iota SELinuxEnforcing SELinuxPermissive SELinuxDisabled )
func (SELinuxMode) IsDisabled ¶
func (m SELinuxMode) IsDisabled() bool
func (SELinuxMode) IsEnforcing ¶
func (m SELinuxMode) IsEnforcing() bool
func (SELinuxMode) IsPermissive ¶
func (m SELinuxMode) IsPermissive() bool
func (SELinuxMode) IsUnknown ¶
func (m SELinuxMode) IsUnknown() bool
type SELinuxStatus ¶
type SELinuxStatus int
const ( SELinuxUnknown SELinuxStatus = iota SELinuxNotInstalled SELinuxInstalled )
func (SELinuxStatus) IsInstalled ¶
func (s SELinuxStatus) IsInstalled() bool
func (SELinuxStatus) IsNotInstalled ¶
func (s SELinuxStatus) IsNotInstalled() bool
func (SELinuxStatus) IsUnknown ¶
func (s SELinuxStatus) IsUnknown() bool
type SecretData ¶
SecretData maps names to values as in Kubernetes v1.Secret
type Service ¶
type Service struct { // Name of the systemd unit. Name string `structs:"name"` // Status is the desired service status. Only "active" or "inactive" are valid // input. Status string `structs:"status"` // Whether the service is enabled (systemctl enable) or not. Enabled bool `structs:"enabled"` }
Service represents a systemd service.
func (*Service) QueryState ¶
QueryState implements plan.Resource.