Example Usage
Install and update your application declaratively
kapp-controller's App CRD provides a declarative way to install, manage, and upgrade applications on a Kubernetes cluster
apiVersion: kappctrl.k14s.io/v1alpha1
kind: App
metadata:
name: simple-app
namespace: default
spec:
serviceAccountName: default-ns-sa
fetch:
- git:
url: https://github.com/carvel-dev/simple-app-on-kubernetes
ref: origin/develop
subPath: config-step-2-template
template:
- ytt: {}
deploy:
- kapp: {}
Install our default-ns-rbac example. It creates the default-ns-sa service account that allows us to change any resource in the default namespace. It used as the serviceAccountName in the app spec above.
$ kapp deploy -a default-ns-rbac -f https://raw.githubusercontent.com/carvel-dev/kapp-controller/develop/examples/rbac/default-ns.yml
Apply the App CR to your cluster and verify the deployment was successful:
$ kubectl apply -f simple-app.yml
$ kubectl get app simple-app
NAME DESCRIPTION SINCE-DEPLOY AGE
simple-app Reconcile succeeded 9s 10s
Discover more in the App CR documentation.
Create a Package
kapp-controller's Package CRD provides a way for you to write and share software as Packages so that Kubernetes users can easily discover and install them.
apiVersion: data.packaging.carvel.dev/v1alpha1
kind: Package
metadata:
name: simple-app.corp.com.1.0.0
spec:
refName: simple-app.corp.com
version: 1.0.0
releaseNotes: |
Initial release of the simple app package
template:
spec:
fetch:
- imgpkgBundle:
image: index.docker.io/k8slt/kctrl-example-pkg@sha256:8ffa7f9352149dba1d539d0006b38eda357917edcdd39b82497a61dab2c27b75
template:
- ytt:
paths:
- config/
- kbld:
paths:
- .imgpkg/images.yml
- '-'
deploy:
- kapp: {}
valuesSchema:
openAPIv3:
title: simple-app.corp.com values schema
examples:
- svc_port: 80
app_port: 80
hello_msg: stranger
properties:
svc_port:
type: integer
description: Port number for the service.
default: 80
examples:
- 80
app_port:
type: integer
description: Target port for the application.
default: 80
examples:
- 80
hello_msg:
type: string
description: Name used in hello message from app when app is pinged.
default: stranger
examples:
- stranger
Install a Package
kapp-controller's PackageRepository CRD allows you to easily discover a collection of Packages.
apiVersion: packaging.carvel.dev/v1alpha1
kind: PackageRepository
metadata:
name: simple-package-repository
namespace: default
spec:
fetch:
imgpkgBundle:
image: k8slt/corp-com-pkg-repo:1.0.0
Apply the PackageRepository to your cluster and view available software packages with kubectl:
$ kubectl apply -f repository.yml
$ kubectl get packages
NAME PACKAGEMETADATA NAME VERSION AGE
simple-app.corp.com.1.0.0 simple-app.corp.com 1.0.0 1m50s
simple-app.corp.com.2.0.0 simple-app.corp.com 2.0.0 1m50s
simple-app.corp.com.3.0.0-rc.1 simple-app.corp.com 3.0.0-rc.1 1m50s
kapp-controller's PackageInstall CR provides users a way to install Packages on a Kubernetes cluster.
apiVersion: packaging.carvel.dev/v1alpha1
kind: PackageInstall
metadata:
name: pkg-demo
namespace: default
spec:
serviceAccountName: default-ns-sa
packageRef:
refName: simple-app.corp.com
versionSelection:
constraints: 1.0.0
Apply the PackageInstall to your cluster and verify the Package was installed successfully:
$ kubectl apply -f packageinstall.yml
$ kubectl get packageinstall pkg-demo
NAME PACKAGE NAME PACKAGE VERSION DESCRIPTION AGE
pkg-demo simple-app.corp.com 1.0.0 Reconcile succeeded 1m50s
View the App CR created as a result of the PackageInstall creation:
$ kubectl get app pkg-demo
NAME DESCRIPTION SINCE-DEPLOY AGE
pkg-demo Reconcile succeeded 9s 1m45s
Discover more about creating and installing Packages in the docs