Dagger
Search

kubectl

The goal of this module is to be the one stop shop for interacting with a kubernetes cluster. The main challenge when doing this is how authentication is done against the cluster. Eventually this module should support all most used methods. Each top level method is in charge of creating a container with all the tools and credentials ready to go for kubectl commands to be executed. For an example on how this is implemented you can check out the `KubectlEks` method.

Installation

dagger install github.com/matipan/daggerverse/kubectl@v0.0.2

Entrypoint

Return Type
Kubectl !
Arguments
NameTypeDescription
kubeconfigSecret !No description provided
Example
dagger -m github.com/matipan/daggerverse/kubectl@f126a3392b2a6f7c38d88e12de6e878a071bb484 call \
 --kubeconfig env:MYSECRET
func (m *myModule) example(kubeconfig *Secret) *Kubectl  {
	return dag.
			Kubectl(kubeconfig)
}
@function
def example(kubeconfig: dagger.Secret) -> dag.Kubectl:
	return (
		dag.kubectl(kubeconfig)
	)
@func()
example(kubeconfig: Secret): Kubectl {
	return dag
		.kubectl(kubeconfig)
}

Types

Kubectl 🔗

kubeconfig() 🔗

Return Type
Secret !
Example
dagger -m github.com/matipan/daggerverse/kubectl@f126a3392b2a6f7c38d88e12de6e878a071bb484 call \
 --kubeconfig env:MYSECRET kubeconfig
func (m *myModule) example(kubeconfig *Secret) *Secret  {
	return dag.
			Kubectl(kubeconfig).
			Kubeconfig()
}
@function
def example(kubeconfig: dagger.Secret) -> dagger.Secret:
	return (
		dag.kubectl(kubeconfig)
		.kubeconfig()
	)
@func()
example(kubeconfig: Secret): Secret {
	return dag
		.kubectl(kubeconfig)
		.kubeconfig()
}

kubectlEks() 🔗

KubectlEks returns a KubectlCLI with aws-iam-authenticator and AWS credentials configured to communicate with an EKS cluster.

Return Type
Cli !
Arguments
NameTypeDefault ValueDescription
awsConfigSecret -No description provided
awsCredsSecret !-No description provided
awsProfileString !-No description provided
Example
dagger -m github.com/matipan/daggerverse/kubectl@f126a3392b2a6f7c38d88e12de6e878a071bb484 call \
 --kubeconfig env:MYSECRET kubectl-eks --aws-creds env:MYSECRET --aws-profile string
func (m *myModule) example(kubeconfig *Secret, awsCreds *Secret, awsProfile string) *KubectlCli  {
	return dag.
			Kubectl(kubeconfig).
			KubectlEks(awsCreds, awsProfile)
}
@function
def example(kubeconfig: dagger.Secret, aws_creds: dagger.Secret, aws_profile: str) -> dag.KubectlCli:
	return (
		dag.kubectl(kubeconfig)
		.kubectl_eks(aws_creds, aws_profile)
	)
@func()
example(kubeconfig: Secret, awsCreds: Secret, awsProfile: string): KubectlCli {
	return dag
		.kubectl(kubeconfig)
		.kubectlEks(awsCreds, awsProfile)
}

Cli 🔗

KubectlCLI is a child module that holds a Container that should already be configured to talk to a k8s cluster.

container() 🔗

Return Type
Container !
Example
dagger -m github.com/matipan/daggerverse/kubectl@f126a3392b2a6f7c38d88e12de6e878a071bb484 call \
 kubectl-eks --aws-creds env:MYSECRET --aws-profile string \
 container
func (m *myModule) example(awsCreds *Secret, awsProfile string) *Container  {
	return dag.
			Kubectl().
			KubectlEks(awsCreds, awsProfile).
			Container()
}
@function
def example(aws_creds: dagger.Secret, aws_profile: str) -> dagger.Container:
	return (
		dag.kubectl()
		.kubectl_eks(aws_creds, aws_profile)
		.container()
	)
@func()
example(awsCreds: Secret, awsProfile: string): Container {
	return dag
		.kubectl()
		.kubectlEks(awsCreds, awsProfile)
		.container()
}

exec() 🔗

Exec runs the specified kubectl command. NOTE: kubectl should be specified as part of the cmd variable. For example, to list pods: [“get”, “pods”, “-n”, “namespace”]

Return Type
String !
Arguments
NameTypeDefault ValueDescription
cmd[String ! ] !-No description provided
Example
dagger -m github.com/matipan/daggerverse/kubectl@f126a3392b2a6f7c38d88e12de6e878a071bb484 call \
 kubectl-eks --aws-creds env:MYSECRET --aws-profile string \
 exec --cmd string1 --cmd string2
func (m *myModule) example(ctx context.Context, awsCreds *Secret, awsProfile string, cmd []string) string  {
	return dag.
			Kubectl().
			KubectlEks(awsCreds, awsProfile).
			Exec(ctx, cmd)
}
@function
async def example(aws_creds: dagger.Secret, aws_profile: str, cmd: List[str]) -> str:
	return await (
		dag.kubectl()
		.kubectl_eks(aws_creds, aws_profile)
		.exec(cmd)
	)
@func()
async example(awsCreds: Secret, awsProfile: string, cmd: string[]): Promise<string> {
	return dag
		.kubectl()
		.kubectlEks(awsCreds, awsProfile)
		.exec(cmd)
}

debugSh() 🔗

DebugSh is a helper function that developers can use to get a terminal into the container where the commands are run and troubleshoot potential misconfigurations. For example: dagger call –kubeconfig kubeconfig.yaml kubectl-eks –aws-creds ~/.aws/credentials –aws-profile “example” –aws-config ~/.aws/config debug-sh terminal

Return Type
Container !
Example
dagger -m github.com/matipan/daggerverse/kubectl@f126a3392b2a6f7c38d88e12de6e878a071bb484 call \
 kubectl-eks --aws-creds env:MYSECRET --aws-profile string \
 debug-sh
func (m *myModule) example(awsCreds *Secret, awsProfile string) *Container  {
	return dag.
			Kubectl().
			KubectlEks(awsCreds, awsProfile).
			DebugSh()
}
@function
def example(aws_creds: dagger.Secret, aws_profile: str) -> dagger.Container:
	return (
		dag.kubectl()
		.kubectl_eks(aws_creds, aws_profile)
		.debug_sh()
	)
@func()
example(awsCreds: Secret, awsProfile: string): Container {
	return dag
		.kubectl()
		.kubectlEks(awsCreds, awsProfile)
		.debugSh()
}