Part of k14s.io: ytt | kbld | kapp | kwt

kapp is a simple deployment tool focused on the concept of
"Kubernetes application" — a set of resources with the same label.

Github Docs Download Binary Try Online

Basic Usage

# Configurations picked up from a directory
$ kapp deploy -a cass1 -f examples/cassandra/

# Can be used with helm charts, removing need for Tiller
$ helm template my-chart --values my-vals.yml | kapp -y deploy -a my-chart -f -

# ... and with kustomize
$ kustomize build ./some-app | kapp -y deploy -a some-app -f -

# ... or templated with ytt
$ ytt -f ./some-app | kapp -y deploy -a some-app -f -

Features

  • Works with standard Kubernetes YAMLs
  • Focuses exclusively on deployment workflow, not packaging or templating
  • Converges application resources (creates, updates and/or deletes resources) in each deploy
    • based on comparison between provided files and live objects in the cluster
  • Separates calculation of changes (diff stage) from application of changes (apply stage)
  • Works without admin privileges and does not depend on any custom CRDs
    • making it possible to use kapp as a regular user in a single namespace
  • Records application deployment history
  • Opt-in resource version management
    • for example, to trigger Deployment rollout when ConfigMap changes
  • Works with any group of labeled resources (kapp -a label:tier=web inspect -t)
  • Works without server side components
  • GitOps friendly (kapp app-group deploy -g all-apps --directory .)

Playground

Try out kapp in Katacoda Kubernetes interactive playground or check out example workflow below:

Start Katacoda Playground

After launching playground, follow these steps to install kapp and Kubernetes Guestbook example:

$ wget -O- https://get-kapp.io/install-katacoda.sh | bash
$ cd kapp/
$ kapp version
$ kapp deploy -a gb -f examples/gitops/guestbook/all-in-one.yml
$ kapp inspect -a gb -t

Example Workflow

In this example, we are installing app called Knative (v0.2.1).
$ kapp deploy -a knative -f examples/knative-v0.2.1/release-no-mon.yml
Changes summary shows that all resources are new.
Changes

Namespace        Name                              Kind                      Conditions  Age  Changed  Ignored Reason
-                build-controller-admin            ClusterRoleBinding        -           -    add      -
~                builds.build.knative.dev          CustomResourceDefinition  -           -    add      -
...
~                knative-build                     Namespace                 -           -    add      -
~                knative-build-admin               ClusterRole               -           -    add      -
~                knative-serving                   Namespace                 -           -    add      -
~                knative-serving-admin             ClusterRole               -           -    add      -
~                knative-serving-autoscaler-write  ClusterRoleBinding        -           -    add      -
~                knative-serving-controller-admin  ClusterRoleBinding        -           -    add      -
~                knative-serving-write             ClusterRole               -           -    add      -
...
~                services.serving.knative.dev      CustomResourceDefinition  -           -    add      -
istio-system     knative-ingressgateway            Deployment                -           -    add      -
~                knative-ingressgateway            HorizontalPodAutoscaler   -           -    add      -
~                knative-ingressgateway            Service                   -           -    add      -
knative-build    build-controller                  Deployment                -           -    add      -
~                build-controller                  Service                   -           -    add      -
~                build-controller                  ServiceAccount            -           -    add      -
~                build-webhook                     Deployment                -           -    add      -
~                build-webhook                     Service                   -           -    add      -
~                config-logging                    ConfigMap                 -           -    add      -
~                creds-init                        Image                     -           -    add      -
~                gcs-fetcher                       Image                     -           -    add      -
~                git-init                          Image                     -           -    add      -
~                nop                               Image                     -           -    add      -
knative-serving  activator                         Deployment                -           -    add      -
~                activator-service                 Service                   -           -    add      -
~                autoscaler                        Deployment                -           -    add      -
~                autoscaler                        Service                   -           -    add      -
~                autoscaler                        ServiceAccount            -           -    add      -
~                config-autoscaler                 ConfigMap                 -           -    add      -
~                config-controller                 ConfigMap                 -           -    add      -
~                config-domain                     ConfigMap                 -           -    add      -
~                config-gc                         ConfigMap                 -           -    add      -
~                config-logging                    ConfigMap                 -           -    add      -
~                config-network                    ConfigMap                 -           -    add      -
~                config-observability              ConfigMap                 -           -    add      -
~                controller                        Deployment                -           -    add      -
~                controller                        Service                   -           -    add      -
~                controller                        ServiceAccount            -           -    add      -
~                fluentd-sidecar                   Image                     -           -    add      -
~                knative-shared-gateway            Gateway                   -           -    add      -
~                queue-proxy                       Image                     -           -    add      -
~                webhook                           Deployment                -           -    add      -
~                webhook                           Service                   -           -    add      -

51 add, 0 delete, 0 update, 0 keep

51 changes
Let's confirm to continue, and follow deployment progress.
Continue? [yN]: y

10:23:53AM: --- applying changes
10:23:53AM: add customresourcedefinition/builds.build.knative.dev (apiextensions.k8s.io/v1beta1) cluster
10:23:53AM: add customresourcedefinition/buildtemplates.build.knative.dev (apiextensions.k8s.io/v1beta1) cluster
...
10:23:54AM: waiting on add customresourcedefinition/builds.build.knative.dev (apiextensions.k8s.io/v1beta1) cluster
10:23:55AM: waiting on add customresourcedefinition/buildtemplates.build.knative.dev (apiextensions.k8s.io/v1beta1) cluster
...
10:23:59AM: add namespace/knative-build (v1) cluster
10:23:59AM: add namespace/knative-serving (v1) cluster
10:23:59AM: waiting on add namespace/knative-build (v1) cluster
10:24:00AM: waiting on add namespace/knative-serving (v1) cluster
10:24:00AM: add clusterrole/knative-build-admin (rbac.authorization.k8s.io/v1) cluster
...
10:24:00AM: add configmap/config-observability (v1) namespace: knative-serving
10:24:00AM: add deployment/controller (apps/v1) namespace: knative-serving
...
10:24:16AM: waiting on add deployment/webhook (apps/v1) namespace: knative-serving
10:24:17AM:  L waiting on replicaset/webhook-5d4768c744 (extensions/v1beta1) namespace: knative-serving ... done
10:24:17AM:  L waiting on pod/webhook-5d4768c744-9zc4f (v1) namespace: knative-serving ... done
...
10:24:41AM: ---  waiting on 1 changes
10:24:41AM: waiting on add service/knative-ingressgateway (v1) namespace: istio-system
10:24:41AM:  L waiting on endpoints/knative-ingressgateway (v1) namespace: istio-system ... done
10:24:41AM: --- changes applied

Succeeded
ls command shows list of all apps stored in current namespace. Apps themselves can span multiple namespaces and cluster.
$ kapp ls

Apps in namespace 'default'

Name     Label                                 Namespaces                                            Last Change Successful  Last Change Age
istio    kapp.k14s.io/app=1551818002314622000  (cluster),istio-system                                true                    1d
knative  kapp.k14s.io/app=1551819837136481000  (cluster),istio-system,knative-build,knative-serving  true                    1d

2 apps

Succeeded
Now let's update Knative to v0.4.0 from v0.2.1 using deploy command.

Since --diff-changes is used, kapp will show detailed diff against versions of resources in the cluster.
$ kapp deploy -a knative -f examples/knative-v0.4.0/release-no-mon.yml --diff-changes
This resource will be created.
...
--- add gateway/cluster-local-gateway (networking.istio.io/v1alpha3) namespace: knative-serving
      0 + apiVersion: networking.istio.io/v1alpha3
      1 + kind: Gateway
      2 + metadata:
      3 +   labels:
      4 +     kapp.k14s.io/app: "1551986249395299000"
      5 +     kapp.k14s.io/association: v1.e7bcfd8c4517005ad00db9a1e77b9025
      6 +     serving.knative.dev/release: devel
      7 +   name: cluster-local-gateway
      8 +   namespace: knative-serving
      9 + spec:
     10 +   selector:
     11 +     istio: cluster-local-gateway
     12 +   servers:
     13 +   - hosts:
     14 +     - '*'
     15 +     port:
     16 +       name: http
     17 +       number: 80
     18 +       protocol: HTTP
     19 +
This resource will be updated.
--- update service/activator-service (v1) namespace: knative-serving
  ...
  8,  8       kapp.k14s.io/association: v1.95eeff0c313a389c06b371a05fc2ea61
      9 +     serving.knative.dev/release: devel
  9, 10     name: activator-service
 10, 11     namespace: knative-serving
  ...
 17, 18     - name: http
     19 +     nodePort: null
 18, 20       port: 80
 19, 21       protocol: TCP
 20, 22       targetPort: 8080
 21, 23 +   - name: http2
     24 +     port: 81
     25 +     protocol: TCP
     26 +     targetPort: 8081
     27     - name: metrics
 22, 28 +     nodePort: null
 22, 29       port: 9090
 23, 30       protocol: TCP
  ...
 26, 33       app: activator
 27, 34 -   type: NodePort
 28, 34 +   type: ClusterIP
 28, 35   status:
 29, 36     loadBalancer: {}
This resource is will be deleted.
--- delete image/creds-init (caching.internal.knative.dev/v1alpha1) namespace: knative-build
  0     - apiVersion: caching.internal.knative.dev/v1alpha1
  1     - kind: Image
  2     - metadata:
  3     -   annotations: {}
  4     -   clusterName: ""
  5     -   creationTimestamp: "2019-03-07T19:17:41Z"
  6     -   generation: 1
  7     -   labels:
  8     -     kapp.k14s.io/app: "1551986249395299000"
  9     -     kapp.k14s.io/association: v1.2bb2c5b4ed8235697a866d7a9d287361
 10     -   name: creds-init
 11     -   namespace: knative-build
 12     -   resourceVersion: "26738314"
 13     -   selfLink: /apis/caching.internal.knative.dev/v1alpha1/namespaces/knative-build/images/creds-init
 14     -   uid: adc75788-410d-11e9-9fb1-42010a8001ed
 15     - spec:
 16     -   image: gcr.io/knative-releases/github.com/knative/build/cmd/creds-init@sha256:c1c11fafd337f62eea18a1f02b78e6ae6949779bed72d53d19b2870723a8f104
 17     -
...
Changes summary is presented before deploy will continue. In this example, there were quite a few changes between Knative v0.2.1 and v0.4.0.
Changes

Namespace        Name                              Kind                      Conditions  Age  Changed  Ignored Reason
-                build-controller-admin            ClusterRoleBinding        -           6m   del      -
~                builds.build.knative.dev          CustomResourceDefinition  2 OK / 2    6m   del      -
...
~                knative-build                     Namespace                 -           6m   del      -
~                knative-build-admin               ClusterRole               -           6m   del      -
~                knative-serving                   Namespace                 -           6m   mod      -
~                knative-serving-admin             ClusterRole               -           6m   mod      -
~                knative-serving-autoscaler-write  ClusterRoleBinding        -           6m   del      -
~                knative-serving-controller-admin  ClusterRoleBinding        -           6m   mod      -
~                knative-serving-core              ClusterRole               -           -    add      -
~                knative-serving-write             ClusterRole               -           6m   del      -
...
istio-system     knative-ingressgateway            Deployment                2 OK / 2    6m   del      -
~                knative-ingressgateway            HorizontalPodAutoscaler   3 OK / 3    6m   del      -
~                knative-ingressgateway            Service                   -           6m   del      -
knative-build    build-controller                  Deployment                2 OK / 2    6m   del      -
~                build-controller                  Service                   -           6m   del      -
~                build-controller                  ServiceAccount            -           6m   del      -
~                build-webhook                     Deployment                2 OK / 2    6m   del      -
~                build-webhook                     Service                   -           6m   del      -
~                config-logging                    ConfigMap                 -           6m   del      -
~                creds-init                        Image                     -           6m   del      -
~                gcs-fetcher                       Image                     -           6m   del      -
~                git-init                          Image                     -           6m   del      -
~                nop                               Image                     -           6m   del      -
knative-serving  activator                         Deployment                2 OK / 2    6m   mod      -
~                activator-service                 Service                   -           6m   mod      -
~                autoscaler                        Deployment                2 OK / 2    6m   mod      -
~                autoscaler                        Service                   -           6m   mod      -
~                autoscaler                        ServiceAccount            -           6m   del      -
~                cluster-local-gateway             Gateway                   -           -    add      -
...
~                config-observability              ConfigMap                 -           6m   mod      -
~                controller                        Deployment                2 OK / 2    6m   mod      -
~                controller                        Service                   -           6m   mod      -
~                controller                        ServiceAccount            -           6m   mod      -
~                fluentd-sidecar                   Image                     -           6m   del      -
~                knative-ingress-gateway           Gateway                   -           -    add      -
~                knative-shared-gateway            Gateway                   -           6m   del      -
~                queue-proxy                       Image                     -           6m   mod      -
~                webhook                           Deployment                2 OK / 2    6m   mod      -
~                webhook                           Service                   -           6m   mod      -

4 add, 24 delete (27 hidden), 27 update, 0 keep

55 changes
Detailed progress log shows kapp waiting for associated resources to be ready. Readiness checks are specific to resource types.
Continue? [yN]:

11:48:37AM: --- applying changes
11:48:37AM: update customresourcedefinition/clusteringresses.networking.internal.knative.dev (apiextensions.k8s.io/v1beta1) cluster
...
11:48:41AM: waiting on update customresourcedefinition/services.serving.knative.dev (apiextensions.k8s.io/v1beta1) cluster
11:48:41AM: update namespace/knative-serving (v1) cluster
11:48:41AM: waiting on update namespace/knative-serving (v1) cluster
11:48:42AM: update clusterrole/knative-serving-admin (rbac.authorization.k8s.io/v1) cluster
...
11:48:55AM: ---  waiting on 4 changes
11:48:55AM: waiting on update deployment/activator (apps/v1) namespace: knative-serving
11:48:56AM:  L waiting on replicaset/activator-754fc557ff (apps/v1) namespace: knative-serving ... done
11:48:56AM:  L waiting on replicaset/activator-6b4c4b55dd (apps/v1) namespace: knative-serving ... done
11:48:56AM:  L waiting on podmetrics/activator-6b4c4b55dd-g8jjg (metrics.k8s.io/v1beta1) namespace: knative-serving ... done
11:48:56AM:  L waiting on pod/activator-754fc557ff-kpjkj (v1) namespace: knative-serving ... in progress: Condition Ready is not True (False)
11:48:56AM:  L waiting on pod/activator-6b4c4b55dd-vbdr9 (v1) namespace: knative-serving ... done
11:48:56AM:  L waiting on pod/activator-6b4c4b55dd-g8jjg (v1) namespace: knative-serving ... in progress: Deleting
11:48:56AM:  L waiting on pod/activator-6b4c4b55dd-8zfdq (v1) namespace: knative-serving ... in progress: Deleting
11:48:56AM: waiting on update deployment/autoscaler (apps/v1) namespace: knative-serving
11:48:56AM:  L waiting on replicaset/autoscaler-84cfcc9f4b (extensions/v1beta1) namespace: knative-serving ... done
...
11:49:32AM: --- changes applied

Succeeded
inspect command shows list of live objects associated with given app. --tree view optionally shows simple parent-child resource relationships.
$ kapp inspect -a knative --tree

Resources in app 'knative'

Namespace        Name                              Kind        Conditions  Age
...
knative-serving  controller                        Deployment  2 OK / 2    1d
knative-serving   L controller-74449bc6fc          ReplicaSet  -           1d
knative-serving   L.. controller-74449bc6fc-q76fx  Pod         3 OK / 3    1d
knative-serving  activator                         Deployment  2 OK / 2    1d
knative-serving   L activator-79495f6bdb           ReplicaSet  -           1d
knative-serving   L.. activator-79495f6bdb-9cs59   Pod         3 OK / 3    1d
knative-serving   L.. activator-79495f6bdb-lp7dp   Pod         3 OK / 3    1d
knative-serving   L.. activator-79495f6bdb-2zt98   Pod         3 OK / 3    1d
knative-serving  fluentd-sidecar                   Image       -           1d
...

75 resources

Succeeded
logs command starts streaming logs from all Pods associated with given app.
$ kapp logs -f -a knative

# starting tailing 'controller-74449bc6fc-q76fx > controller' logs
# starting tailing 'autoscaler-77fd694cf7-tlzrg > autoscaler' logs
controller-74449bc6fc-q76fx > controller | E0307 01:42:36.464925       1 reflector.go:205] github.com/knative/serving/pkg/client/informers/externalversions/factory.go:116: Failed to list *v1alpha1.PodAutoscaler: Get https://10.23.240.169:443/apis/autoscaling.internal.knative.dev/v1alpha1/podautoscalers?limit=500&resourceVersion=0: dial tcp 10.23.240.169:443: i/o timeout
autoscaler-77fd694cf7-tlzrg > autoscaler | E0307 01:42:49.219897       1 reflector.go:205] github.com/knative/serving/vendor/k8s.io/client-go/informers/factory.go:130: Failed to list *v1.ConfigMap: Get https://10.23.240.169:443/api/v1/namespaces/knative-serving/configmaps?limit=500&resourceVersion=0: EOF
...
delete command finds all resources in the cluster associated with given app, issues delete operation and waits for them be be deleted.
$ kapp delete -a knative

Changes

Namespace        Name                                              Kind                      Conditions  Age  Changed  Ignored Reason
-                build-controller-admin                            ClusterRoleBinding        -           1d   del      -
~                builds.build.knative.dev                          CustomResourceDefinition  2 OK / 2    1d   del      -
~                buildtemplates.build.knative.dev                  CustomResourceDefinition  2 OK / 2    1d   del      -
~                clusterbuildtemplates.build.knative.dev           CustomResourceDefinition  2 OK / 2    1d   del      -
~                clusteringresses.networking.internal.knative.dev  CustomResourceDefinition  2 OK / 2    1d   del      -
~                configurations.serving.knative.dev                CustomResourceDefinition  2 OK / 2    1d   del      -
~                images.caching.internal.knative.dev               CustomResourceDefinition  2 OK / 2    1d   del      -
~                knative-build                                     Namespace                 -           1d   del      -
~                knative-build-admin                               ClusterRole               -           1d   del      -
~                knative-serving                                   Namespace                 -           1d   del      -
~                knative-serving-admin                             ClusterRole               -           1d   del      -
~                knative-serving-autoscaler-write                  ClusterRoleBinding        -           1d   del      -
~                knative-serving-controller-admin                  ClusterRoleBinding        -           1d   del      -
~                knative-serving-write                             ClusterRole               -           1d   del      -
~                podautoscalers.autoscaling.internal.knative.dev   CustomResourceDefinition  2 OK / 2    1d   del      -
~                revisions.serving.knative.dev                     CustomResourceDefinition  2 OK / 2    1d   del      -
~                routes.serving.knative.dev                        CustomResourceDefinition  2 OK / 2    1d   del      -
~                services.serving.knative.dev                      CustomResourceDefinition  2 OK / 2    1d   del      -
istio-system     knative-ingressgateway                            Deployment                2 OK / 2    1d   del      -
~                knative-ingressgateway                            HorizontalPodAutoscaler   2 OK / 3    1d   del      -
~                knative-ingressgateway                            Service                   -           1d   del      -
knative-build    build-controller                                  Deployment                2 OK / 2    1d   del      -
~                build-controller                                  Service                   -           1d   del      -
~                build-controller                                  ServiceAccount            -           1d   del      -
...

0 add, 51 delete (24 hidden), 0 update, 0 keep

51 changes

Continue? [yN]:

...