Dagger
Search

k3s

Runs a k3s server than can be accessed both locally and in your pipelines

Installation

dagger install github.com/marcosnils/daggerverse/k3s@v0.1.1

Entrypoint

Return Type
K3S !
Arguments
NameTypeDefault ValueDescription
nameString !-No description provided
imageString "rancher/k3s:latest"No description provided
Example
dagger -m github.com/marcosnils/daggerverse/k3s@3f6a5bda9b2268a74f85b77597c840053442e792 call \
 --name string
func (m *myModule) example(name string) *K3S  {
	return dag.
			K3s(name)
}
@function
def example(name: str, ) -> dag.K3S:
	return (
		dag.k3s(name)
	)
@func()
example(name: string, ): K3S {
	return dag
		.k3s(name)
}

Types

K3S 🔗

container() 🔗

Return Type
Container !
Example
dagger -m github.com/marcosnils/daggerverse/k3s@3f6a5bda9b2268a74f85b77597c840053442e792 call \
 --name string container
func (m *myModule) example(name string) *Container  {
	return dag.
			K3s(name).
			Container()
}
@function
def example(name: str, ) -> dagger.Container:
	return (
		dag.k3s(name)
		.container()
	)
@func()
example(name: string, ): Container {
	return dag
		.k3s(name)
		.container()
}

server() 🔗

Returns a newly initialized kind cluster

Return Type
Service !
Example
no available example in current language
// starts a k3s server with a local registry and a pre-loaded alpine image
func (m *Examples) K3SServer(ctx context.Context) (*Service, error) {
	regSvc := dag.Container().From("registry:2.8").
		WithExposedPort(5000).AsService()

	_, err := dag.Container().From("quay.io/skopeo/stable").
		WithServiceBinding("registry", regSvc).
		WithEnvVariable("BUST", time.Now().String()).
		WithExec([]string{"copy", "--dest-tls-verify=false", "docker://docker.io/alpine:latest", "docker://registry:5000/alpine:latest"}).Sync(ctx)
	if err != nil {
		return nil, err
	}

	return dag.K3S("test").With(func(k *K3S) *K3S {
		return k.WithContainer(
			k.Container().
				WithEnvVariable("BUST", time.Now().String()).
				WithExec([]string{"sh", "-c", `
cat <<EOF > /etc/rancher/k3s/registries.yaml
mirrors:
  "registry:5000":
    endpoint:
      - "http://registry:5000"
EOF`}, ContainerWithExecOpts{SkipEntrypoint: true}).
				WithServiceBinding("registry", regSvc),
		)
	}).Server(), nil
}
no available example in current language
no available example in current language

withContainer() 🔗

Returns a newly initialized kind cluster

Return Type
K3S !
Arguments
NameTypeDefault ValueDescription
cContainer !-No description provided
Example
dagger -m github.com/marcosnils/daggerverse/k3s@3f6a5bda9b2268a74f85b77597c840053442e792 call \
 --name string with-container --c IMAGE:TAG
func (m *myModule) example(name string, c *Container) *K3S  {
	return dag.
			K3s(name).
			WithContainer(c)
}
@function
def example(name: str, c: dagger.Container) -> dag.K3S:
	return (
		dag.k3s(name)
		.with_container(c)
	)
@func()
example(name: string, c: Container): K3S {
	return dag
		.k3s(name)
		.withContainer(c)
}

config() 🔗

returns the config file for the k3s cluster

Return Type
File !
Arguments
NameTypeDefault ValueDescription
localBoolean falseNo description provided
Example
dagger -m github.com/marcosnils/daggerverse/k3s@3f6a5bda9b2268a74f85b77597c840053442e792 call \
 --name string config
func (m *myModule) example(name string) *File  {
	return dag.
			K3s(name).
			Config()
}
@function
def example(name: str, ) -> dagger.File:
	return (
		dag.k3s(name)
		.config()
	)
@func()
example(name: string, ): File {
	return dag
		.k3s(name)
		.config()
}

kubectl() 🔗

runs kubectl on the target k3s cluster

Return Type
String !
Arguments
NameTypeDefault ValueDescription
argsString !-No description provided
Example
no available example in current language
func (m *Examples) K3SKubectl(ctx context.Context, args string) (string, error) {
	return dag.K3S("test").Kubectl(ctx, args)
}
no available example in current language
no available example in current language

kns() 🔗

runs k9s on the target k3s cluster

Return Type
Container !
Example
dagger -m github.com/marcosnils/daggerverse/k3s@3f6a5bda9b2268a74f85b77597c840053442e792 call \
 --name string kns
func (m *myModule) example(name string) *Container  {
	return dag.
			K3s(name).
			Kns()
}
@function
def example(name: str, ) -> dagger.Container:
	return (
		dag.k3s(name)
		.kns()
	)
@func()
example(name: string, ): Container {
	return dag
		.k3s(name)
		.kns()
}