kubernetes-microservice
This module provides a high-level abstraction for working with container imagestailored 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.0Entrypoint
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
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | String ! | - | No description provided |
| target | String ! | - | No description provided |
| sourceRegistry | String | - | No description provided |
| sourceUsername | String | - | No description provided |
| sourcePassword | Secret | - | No description provided |
| targetRegistry | String | - | No description provided |
| targetUsername | String | - | No description provided |
| targetPassword | Secret | - | No description provided |
| insecure | Boolean | false | No description provided |
| platform | String | "linux/amd64" | No description provided |
| dockerConfigSecret | Secret | - | No description provided |
Example
dagger -m github.com/stuttgart-things/blueprints/kubernetes-microservice@f722bf98c795802581d767d8068d9f687f207111 call \
stage-image --source string --target stringfunc (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
| Name | Type | Default Value | Description |
|---|---|---|---|
| src | Directory ! | - | The source directory |
| repositoryName | String ! | - | The repository name |
| tag | String ! | - | tag |
| registryUsername | Secret | - | The registry username |
| registryPassword | Secret | - | The registry password |
| registryUrl | String ! | - | The registry URL |
| dockerfile | String | "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 stringfunc (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
| Name | Type | Default Value | Description |
|---|---|---|---|
| imageRef | String ! | - | Fully qualified image reference (e.g., "ttl.sh/my-repo:1.0.0") |
| registryUser | Secret | - | No description provided |
| registryPassword | Secret | - | No description provided |
| severity | String | "HIGH,CRITICAL" | No description provided |
| trivyVersion | String | "0.64.1" | No description provided |
Example
dagger -m github.com/stuttgart-things/blueprints/kubernetes-microservice@f722bf98c795802581d767d8068d9f687f207111 call \
scan-image --image-ref stringfunc (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)
}