Image solver for your configuration

kbld seamlessly incorporates image building, pushing, and resolution into your development and deployment workflows. Result is configuration with immutable image references.

See Examples Download Binary

Features

Why Digest References?

Docker images can be referenced by their name (nginx), name-tag pair (nginx:1.14), or a digest (nginx@sha256:c398dc3f2...). One can avoid potential deployment inconsistencies by using digest references as they are immutable, and therefore always points to an exact image. kbld helps Kubernetes users convert image references to their digest form to make sure exact image is used during deploys.

Basic Usage

# Configurations picked up from a directory
$ kbld -f examples/cassandra/ | kubectl apply -f -
# Can be used with helm charts
$ helm template my-chart --values my-vals.yml | kbld -f - | kubectl apply -f -
# ... and with kustomize
$ kustomize build ./some-app | kbld -f - | kubectl apply -f -
# ... or templated with ytt and deployed with kapp
$ ytt -f ./some-app | kbld -f - | kapp -y deploy -a some-app -f -

Examples

Resolves name-tag pair reference (nginx:1.17) into digest reference (index.docker.io/library/nginx@sha256:2539d4344...)

Input:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.17
        ports:
        - containerPort: 80

Output:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
  annotations:
    kbld.k14s.io/images: |
      - Metas:
        - Tag: 1.17
          Type: resolved
          URL: nginx:1.17
        URL: index.docker.io/library/nginx@sha256:2539d4344...
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: index.docker.io/library/nginx@sha256:2539d4344...
        ports:
        - containerPort: 80

Builds app from local directory (configured via Sources), pushes image as docker.io/hk/simple-app (configured via ImageDestinations), and finally resolves it to a digest reference index.docker.io/hk/simple-app@sha256:e932e46fd....

Input:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: app1-deployment
  labels:
    app: app1
spec:
  replicas: 3
  selector:
    matchLabels:
      app: app1
  template:
    metadata:
      labels:
        app: app1
    spec:
      containers:
      - name: app1
        image: app1
        ports:
        - containerPort: 80

#! where to find app1 source
---
apiVersion: kbld.k14s.io/v1alpha1
kind: Sources
sources:
- image: app1
  path: .

#! where to push app1 image
---
apiVersion: kbld.k14s.io/v1alpha1
kind: ImageDestinations
destinations:
- image: app1
  newImage: docker.io/hk/simple-app

Output:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: app1-deployment
  labels:
    app: app1
  annotations:
    kbld.k14s.io/images: |
      - Metas:
        - Path: /Users/pivotal/workspace/simple-app
          Type: local
        - Dirty: false
          RemoteURL: git@github.com:k14s/super-secret-simple-app
          SHA: e877718521f7ccea0ab0844db0f86fe123a8d8ef
          Type: git
        URL: index.docker.io/hk/simple-app@sha256:e932e46fd...
spec:
  replicas: 3
  selector:
    matchLabels:
      app: app1
  template:
    metadata:
      labels:
        app: app1
    spec:
      containers:
      - name: app1
        image: index.docker.io/hk/simple-app@sha256:e932e46fd...
        ports:
        - containerPort: 80

Carvel Team

kbld is released as open source software and provides community support through our GitHub project page.

The Carvel project team welcomes contributions from the community, please see the contributing documentation for more details.