Dagger
Search

kubernetes-microservice

This module provides a high-level abstraction for working with container images
tailored for Kubernetes microservices, using Dagger as the execution engine.

It offers two primary functions:
- BakeImage: Builds and optionally pushes a Docker image from source code
with support for extra build directories and custom Dockerfile paths.
- StageImage: Stages (copies) an existing image between registries, optionally
using Docker config authentication or username/password pairs.
Supports insecure registries and custom platforms.

Typical usage scenarios include:
- Building a microservice image in CI/CD pipelines and pushing directly to a registry
- Promoting (staging) images between registries (e.g., dev -> staging -> prod)
- Supporting custom build contexts through additional directories

Internally, this module delegates to the 'Docker' module for building/pushing images,
and the 'Crane' module for staging images between registries.

Example workflows:
- Bake a microservice image and push to a dev registry
- Stage a built image to a production registry using secure or insecure connections

This module is designed for integration in CI pipelines, platform automation, or
developer tooling around Kubernetes microservices.

Installation

dagger install github.com/stuttgart-things/blueprints/kubernetes-microservice@v1.8.0

Entrypoint

Return Type
KubernetesMicroservice
Example
dagger -m github.com/stuttgart-things/blueprints/kubernetes-microservice@f722bf98c795802581d767d8068d9f687f207111 call \
func (m *MyModule) Example() *dagger.KubernetesMicroservice  {
	return dag.
			KubernetesMicroservice()
}
@function
def example() -> dagger.KubernetesMicroservice:
	return (
		dag.kubernetes_microservice()
	)
@func()
example(): KubernetesMicroservice {
	return dag
		.kubernetesMicroservice()
}

Types

KubernetesMicroservice 🔗

stageImage() 🔗

Return Type
String !
Arguments
NameTypeDefault ValueDescription
sourceString !-No description provided
targetString !-No description provided
sourceRegistryString -No description provided
sourceUsernameString -No description provided
sourcePasswordSecret -No description provided
targetRegistryString -No description provided
targetUsernameString -No description provided
targetPasswordSecret -No description provided
insecureBoolean falseNo description provided
platformString "linux/amd64"No description provided
dockerConfigSecretSecret -No description provided
Example
dagger -m github.com/stuttgart-things/blueprints/kubernetes-microservice@f722bf98c795802581d767d8068d9f687f207111 call \
 stage-image --source string --target string
func (m *MyModule) Example(ctx context.Context, source string, target string) string  {
	return dag.
			KubernetesMicroservice().
			StageImage(ctx, source, target)
}
@function
async def example(source: str, target: str) -> str:
	return await (
		dag.kubernetes_microservice()
		.stage_image(source, target)
	)
@func()
async example(source: string, target: string): Promise<string> {
	return dag
		.kubernetesMicroservice()
		.stageImage(source, target)
}

bakeImage() 🔗

Return Type
String !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-The source directory
repositoryNameString !-The repository name
tagString !-tag
registryUsernameSecret -The registry username
registryPasswordSecret -The registry password
registryUrlString !-The registry URL
dockerfileString "Dockerfile"The Dockerfile path
withDirectories[Directory ! ] -Set extra directories
Example
dagger -m github.com/stuttgart-things/blueprints/kubernetes-microservice@f722bf98c795802581d767d8068d9f687f207111 call \
 bake-image --src DIR_PATH --repository-name string --tag string --registry-url string
func (m *MyModule) Example(ctx context.Context, src *dagger.Directory, repositoryName string, tag string, registryUrl string) string  {
	return dag.
			KubernetesMicroservice().
			BakeImage(ctx, src, repositoryName, tag, registryUrl)
}
@function
async def example(src: dagger.Directory, repository_name: str, tag: str, registry_url: str) -> str:
	return await (
		dag.kubernetes_microservice()
		.bake_image(src, repository_name, tag, registry_url)
	)
@func()
async example(src: Directory, repositoryName: string, tag: string, registryUrl: string): Promise<string> {
	return dag
		.kubernetesMicroservice()
		.bakeImage(src, repositoryName, tag, registryUrl)
}

scanImage() 🔗

Return Type
File !
Arguments
NameTypeDefault ValueDescription
imageRefString !-Fully qualified image reference (e.g., "ttl.sh/my-repo:1.0.0")
registryUserSecret -No description provided
registryPasswordSecret -No description provided
severityString "HIGH,CRITICAL"No description provided
trivyVersionString "0.64.1"No description provided
Example
dagger -m github.com/stuttgart-things/blueprints/kubernetes-microservice@f722bf98c795802581d767d8068d9f687f207111 call \
 scan-image --image-ref string
func (m *MyModule) Example(imageRef string) *dagger.File  {
	return dag.
			KubernetesMicroservice().
			ScanImage(imageRef)
}
@function
def example(image_ref: str) -> dagger.File:
	return (
		dag.kubernetes_microservice()
		.scan_image(image_ref)
	)
@func()
example(imageRef: string): File {
	return dag
		.kubernetesMicroservice()
		.scanImage(imageRef)
}