resource

package
v0.10.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2021 License: Apache-2.0 Imports: 25 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunKubectlApply added in v0.10.0

func RunKubectlApply(ctx context.Context, r plan.Runner, args KubectlApplyArgs, fname string) error

func RunKubectlRemoteApply added in v0.10.0

func RunKubectlRemoteApply(ctx context.Context, remoteURL string, runner plan.Runner) error

Types

type KubeadmInit

type KubeadmInit struct {
	capeiresource.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.
	SSHKeyPath string `structs:"sshKeyPath"`
	// 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"`
	// 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

func (ki *KubeadmInit) Apply(ctx context.Context, runner plan.Runner, diff plan.Diff) (bool, error)

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

func (ki *KubeadmInit) State() plan.State

State implements plan.Resource.

func (*KubeadmInit) Undo

func (ki *KubeadmInit) Undo(ctx context.Context, runner plan.Runner, current plan.State) error

Undo implements plan.Resource.

type KubectlAnnotateSingleNode added in v0.10.0

type KubectlAnnotateSingleNode struct {
	resource.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.10.0

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.10.0

func (ka *KubectlAnnotateSingleNode) State() plan.State

State implements plan.Resource.

type KubectlApply

type KubectlApply struct {
	resource.Base

	// Filename is the remote manifest file name.
	// Only provide this if you do NOT provide ManifestPath or ManifestURL.
	Filename fmt.Stringer `structs:"filename"`
	// 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

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

func (ka *KubectlApply) State() plan.State

State implements plan.Resource.

type KubectlApplyArgs added in v0.10.0

type KubectlApplyArgs struct {
	// Content is the YAML manifest to be applied. Must be non-empty.
	Content []byte
	// WaitCondition, if non-empty, makes RunKubectlApply do "kubectl wait --for=<value>" on the applied resource.
	WaitCondition string
}

type KubectlWait

type KubectlWait struct {
	resource.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

func (kw *KubectlWait) Apply(ctx context.Context, runner plan.Runner, diff plan.Diff) (bool, error)

Apply performs a "kubectl wait" as specified in the receiver.

func (*KubectlWait) State

func (kw *KubectlWait) State() plan.State

State implements plan.Resource.

Jump to

Keyboard shortcuts

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