Skip to content

Narrow down interfaces required in kustomize and kubectl helpers functions and provide envtest cluster wrapper to work with these #1262

@pmalek

Description

@pmalek

Problem statement

KTF provides several functions which allow to interact with kubectl (and kustomize via kubetl -k) in

// KustomizeDeployForCluster applies a given kustomizeURL to the provided cluster
func KustomizeDeployForCluster(ctx context.Context, cluster Cluster, kustomizeURL string, flags ...string) error {
return kubectlWithArgs(ctx, cluster, append([]string{"-v9", "apply", "-k", kustomizeURL}, flags...)...)
}
// KustomizeDeleteForCluster deletes the provided kustomize manafests from the cluster
func KustomizeDeleteForCluster(ctx context.Context, cluster Cluster, kustomizeURL string, flags ...string) error {
return kubectlWithArgs(ctx, cluster, append([]string{"-v9", "delete", "-k", kustomizeURL}, flags...)...)
}
// ApplyManifestByURL applies a given manifest URL to the cluster provided
func ApplyManifestByURL(ctx context.Context, cluster Cluster, url string) error {
return kubectlWithArgs(ctx, cluster, "apply", "-f", url)
}
// DeleteManifestByURL deletes a given manifest URL on the cluster provided
func DeleteManifestByURL(ctx context.Context, cluster Cluster, url string) error {
return kubectlWithArgs(ctx, cluster, "delete", "-f", url)
}
// ApplyManifestByYAML applies a given YAML manifest to the cluster provided
func ApplyManifestByYAML(ctx context.Context, cluster Cluster, yaml string) error {
return kubectlSubcommandWithYAML(ctx, cluster, "apply", yaml)
}
// DeleteManifestByYAML deletes a given YAML manifest on the cluster provided
func DeleteManifestByYAML(ctx context.Context, cluster Cluster, yaml string) error {
return kubectlSubcommandWithYAML(ctx, cluster, "delete", yaml)
}
.

These functions access cluster.Cluster which is an interface with numerous methods which not all clusters might provide

In several projects like KIC or KGO, envtest is used to create clusters on the fly. These clusters are not yet supported.

This task tracks the effort to:

  • narrow down the interface accepted by kustomize and kubectl helper funcs linked above
  • provide a wrapper type for envtest so that these funcs can be utilized with envtest clusters

Acceptance criteria

  • ktf kustomize and kubectl helpers funcs can be used with envtest clusters

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions