Skip to content

Commit

Permalink
Version kapp-controller documentation
Browse files Browse the repository at this point in the history
Signed-off-by: João Pereira <[email protected]>
  • Loading branch information
joaopapereira committed Jan 25, 2022
1 parent 081a888 commit 7fd66b7
Show file tree
Hide file tree
Showing 52 changed files with 3,131 additions and 22 deletions.
9 changes: 5 additions & 4 deletions site/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,17 @@ params:
name: kapp-controller
short_name: kc
root_link: /kapp-controller/
latest_docs_link: /kapp-controller/docs/latest/
latest_docs_link: /kapp-controller/docs/v0.31.0/
github_url: https://github.com/vmware-tanzu/carvel-kapp-controller
search: true
search_index_name: carvel
search_api_key: 582b1408d7a3fe145c0f84f48ca03755
search_tag: kapp-controller
versioning: false
version_latest: latest
versioning: true
version_latest: v0.31.0
versions:
- latest
- develop
- v0.31.0
vendir:
name: vendir
short_name: vendir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "About kapp-controller"
toc: "false"
cascade:
version: latest
version: develop
toc: "true"
type: docs
layout: docs
Expand Down Expand Up @@ -32,4 +32,4 @@ With its layered approach, kapp-controller can be used as:
Use kapp-controller's Package Management features along with Carvel's imgpkg bundles to distribute Package Repositories that can be added to cluster to provide a catalog of software for users to install. Package Repositries can be automatically updated ensuring users always have access to latest versions of software. Package Repositories and Packages can also be relocated and run in air-gapped environments.

#### Reliable and ready for production!
kapp-controller has been hardened and is in use on production Kubernetes clusters. Learn more through [case studies](/blog/casestudy-modernizing-the-us-army) on our blog.
kapp-controller has been hardened and is in use on production Kubernetes clusters. Learn more through [case studies](/blog/casestudy-modernizing-the-us-army) on our blog.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Full App CR spec can be found [here](app-spec.md).
App CR supports multiple source for fetching configuration and OCI images to give developers flexibility.

- `inline`: specify one or more files within resource
- `imgpkgBundle`: download [imgpkg bundle](https://carvel.dev/imgpkg/docs/latest/resources/#bundle) from registry (available in v0.17.0+)
- `imgpkgBundle`: download [imgpkg bundle](/imgpkg/docs/latest/resources/#bundle) from registry (available in v0.17.0+)
- `image`: download Docker image from registry
- `http`: download file at URL
- `git`: clone Git repository
Expand Down Expand Up @@ -69,4 +69,4 @@ App CR supports multiple templating, overlaying, and data transformation tools t

App CR uses Carvel's `kapp` CLI to deploy.

- `kapp`: uses [kapp](/kapp) to deploy resources
- `kapp`: uses [kapp](/kapp) to deploy resources
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ This is the recommended workflow:
For more details, see:
- [ytt: Export Schema in OpenAPI Format](../../../ytt/docs/latest/how-to-export-schema.md).
- [ytt: Configuring Data Values via command line flags](../../../ytt/docs/latest/ytt-data-values.md#configuring-data-values-via-command-line-flags)
- [@ytt:yaml module](../../../ytt/docs/latest/lang-ref-ytt.md#yaml)
- [@ytt:yaml module](../../../ytt/docs/latest/lang-ref-ytt.md#yaml)
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ rules:
- use
```
3. Set the `IMGPKG_ENABLE_IAAS_AUTH` [environment
variable](https://carvel.dev/imgpkg/docs/latest/auth/#via-iaas) to false.
variable](/imgpkg/docs/latest/auth/#via-iaas) to false.


### Kubernetes versions < 1.20
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ EOF
```

## Creating a Package: Structuring our contents
We'll create an [imgpkg bundle](https://carvel.dev/imgpkg/docs/latest/resources/#bundle)
We'll create an [imgpkg bundle](/imgpkg/docs/latest/resources/#bundle)
that contains the package contents: the configuration (config.yml and values.yml from the previous step) and a reference to the greeter app image (docker.io/dkalinin/k8s-simple-app@sha256:...).

The [package bundle format](https://carvel.dev/kapp-controller/docs/latest/packaging-artifact-formats/#package-contents-bundle) describes the purpose of each directory
The [package bundle format](packaging-artifact-formats.md#package-contents-bundle) describes the purpose of each directory
used in this section of the tutorial as well as general recommendations.

Let's create a directory with our configuration files:
Expand All @@ -190,7 +190,7 @@ mkdir -p package-contents/.imgpkg
kbld -f package-contents/config/ --imgpkg-lock-output package-contents/.imgpkg/images.yml
```

For more on using kbld to populate the .imgpkg directory with an ImagesLock, and why it is useful, see the [imgpkg docs on the subject](https://carvel.dev/imgpkg/docs/latest/resources/#imageslock-configuration).
For more on using kbld to populate the .imgpkg directory with an ImagesLock, and why it is useful, see the [imgpkg docs on the subject](/imgpkg/docs/latest/resources/#imageslock-configuration).

Once these files have been added, our package contents bundle is ready to be pushed!

Expand Down Expand Up @@ -299,17 +299,17 @@ EOF
This Package contains some metadata fields specific to the version, such as releaseNotes and a valuesSchema. The valuesSchema shows what configurable properties exist for the version. This will help when users want to install this package and want to know what can be configured.

The other main component of this CR is the template section.
This section informs kapp-controller of the actions required to install the packaged software, so take a look at the [app-spec](https://carvel.dev/kapp-controller/docs/latest/app-spec/) section to learn more about each of the template sections. For this example, we have chosen a basic setup that will fetch the imgpkg bundle we created in the previous section, run the templates stored inside through ytt, apply kbld transformations, and then deploy the resulting manifests with kapp.
This section informs kapp-controller of the actions required to install the packaged software, so take a look at the [app-spec](app-spec.md) section to learn more about each of the template sections. For this example, we have chosen a basic setup that will fetch the imgpkg bundle we created in the previous section, run the templates stored inside through ytt, apply kbld transformations, and then deploy the resulting manifests with kapp.

There will also be validations run on the Package CR, so ensure that spec.refName and spec.version are not empty and that metadata.name is `<spec.refName>.<spec.version>`.
These validations are done to encourage a naming scheme that keeps package version names unique.
## Creating a Package Repository

A [package repository](https://carvel.dev/kapp-controller/docs/latest/packaging/#package-repository)
A [package repository](packaging.md#package-repository)
is a collection of packages (more specifically a collection of Package and PackageMetadata CRs).
Our recommended way to make a package repository is via an [imgpkg bundle](https://carvel.dev/imgpkg/docs/latest/resources/#bundle).
Our recommended way to make a package repository is via an [imgpkg bundle](/imgpkg/docs/latest/resources/#bundle).

The [PackageRepository bundle format](https://carvel.dev/kapp-controller/docs/latest/packaging-artifact-formats/#package-repository-bundle) describes purpose of each directory and general recommendations.
The [PackageRepository bundle format](packaging-artifact-formats.md#package-repository-bundle) describes purpose of each directory and general recommendations.

Lets start by creating the needed directories:

Expand Down Expand Up @@ -371,7 +371,7 @@ EOF
```

(See our
[demo video](https://www.youtube.com/watch?v=PmwkicgEKQE) and [website](https://carvel.dev/kapp-controller/docs/latest/private-registry-auth) for more typical usage with an external repository.)
[demo video](https://www.youtube.com/watch?v=PmwkicgEKQE) and [website](private-registry-auth.md) for more typical usage with an external repository.)

This PackageRepository CR will allow kapp-controller to install any of the
packages found within the `${REPO_HOST}/packages/my-pkg-repo:1.0.0` imgpkg bundle, which we
Expand Down Expand Up @@ -446,11 +446,11 @@ EOF

This CR references the Package we created in the previous sections using the package’s `refName` and `version` fields (see yaml from step 7).
Do note, the `versionSelection` property has a constraints subproperty to give more control over which versions are chosen for installation.
More information on PackageInstall versioning can be found [here](https://carvel.dev/kapp-controller/docs/latest/packaging/#versioning-packageinstalls).
More information on PackageInstall versioning can be found [here](packaging.md#versioning-packageinstalls).

This yaml snippet also contains a Kubernetes secret, which is referenced by the PackageInstall. This secret is used to provide customized values to the package installation’s templating steps. Consumers can discover more details on the configurable properties of a package by inspecting the Package CR’s valuesSchema.

Finally, to install the above package, we will also need to create `default-ns-sa` service account (refer to [Security model](https://carvel.dev/kapp-controller/docs/latest/security-model/)
Finally, to install the above package, we will also need to create `default-ns-sa` service account (refer to [Security model](security-model.md)
for explanation of how service accounts are used) that give kapp-controller privileges to create resources in the default namespace:
```bash
kapp deploy -a default-ns-rbac -f https://raw.githubusercontent.com/vmware-tanzu/carvel-kapp-controller/develop/examples/rbac/default-ns.yml -y
Expand Down Expand Up @@ -480,4 +480,4 @@ curl localhost:3000

Visit [carvel.dev](https://carvel.dev/) to learn more about Carvel tools.

See the full docs for [Package Management with kapp-controller](https://carvel.dev/kapp-controller/docs/latest/packaging/)
See the full docs for [Package Management with kapp-controller](packaging.md)
35 changes: 35 additions & 0 deletions site/content/kapp-controller/docs/v0.31.0/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
title: "About kapp-controller"
toc: "false"
cascade:
version: v0.31.0
toc: "true"
type: docs
layout: docs
---

kapp-controller provides declarative APIs to customize, install, and update your Kubernetes applications and packages. It is a part of the Carvel toolkit and follows core Carvel design principles. Get started with the [tutorial](packaging-tutorial.md)!

#### Choice for authors; consistency for consumers
Kubernetes configuration takes many forms -- plain YAML configurations, Helm charts, ytt templates, jsonnet templates, etc.
Software running on Kubernetes lives in many different places: a Git repository, an archive over HTTP, a Helm repository, etc.

kapp-controller provides software authors flexibility to choose their own configuration tools, while providing software consumers with consistent declarative APIs to customize, install, and update software on Kubernetes from various sources.

#### Lightweight and composable
kapp-controller breaks down the installation of applications and packages into three easy to understand steps:
- Fetch: get configuration and OCI images from various sources including a Git repository, a local ConfigMap, a Helm chart, an OCI registry, etc.
- Template: take user provided values to customize software using ytt templates, helm templates, and more
- Deploy: create/update resources on the cluster

#### GitOps and Continuous Delivery
With its layered approach, kapp-controller can be used as:
- Continuous delivery for Kubernetes applications using [App CR](app-spec.md)
- Kubernetes Package Management using [Package CR and supplementary CRs](packaging.md)
- Managing applications and packages using GitOps

#### Share software and build distributions
Use kapp-controller's Package Management features along with Carvel's imgpkg bundles to distribute Package Repositories that can be added to cluster to provide a catalog of software for users to install. Package Repositries can be automatically updated ensuring users always have access to latest versions of software. Package Repositories and Packages can also be relocated and run in air-gapped environments.

#### Reliable and ready for production!
kapp-controller has been hardened and is in use on production Kubernetes clusters. Learn more through [case studies](/blog/casestudy-modernizing-the-us-army) on our blog.
74 changes: 74 additions & 0 deletions site/content/kapp-controller/docs/v0.31.0/air-gapped-workflow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
title: Install Packages in an air-gapped (offline) environment
---

The documentation below covers topics from the [imgpkg air-gapped workflow docs](/imgpkg/docs/latest/air-gapped-workflow)
more concisely in order to focus on applying these workflows to kapp-controller package repositories.

## Scenario

You have a [PackageRepository](packaging#packagerepository-cr) in an [imgpkg bundle format](/imgpkg/docs/latest/resources/#bundle)
in an external OCI registry that you would like to move into an OCI registry in an air-gapped environment. Once relocated, you would
like to deploy the bundle as part of a PackageRepository to a Kubernetes cluster.

## Prerequisites

In order to go through this process of moving an imgpkg bundle to an air-gapped environment, you will need to have [imgpkg](/imgpkg)
installed. More information on installing Carvel tools, including `imgpkg`, can be found [here](/#whole-suite).

## Copy PackageRepository bundle to new location

Most of the steps documented for the [imgpkg air-gapped workflow docs](/imgpkg/docs/latest/air-gapped-workflow#step-1-finding-bundle-in-source-registry)
still apply in the case of working with kapp-controller package repositories. A summary of these docs is that you will need to copy your package repository
bundle with `imgpkg` via one of the following options:

- Option 1: From a common location connected to both registries. This option is more efficient because only changed image layers will be transfered between registries.
- Option 2: With intermediate tarball. This option works best when registries have no common network access.

More detailed documents for [`Option 1`](/imgpkg/docs/latest/air-gapped-workflow/#option-1-from-a-location-connected-to-both-registries) and
[`Option 2`](/imgpkg/docs/latest/air-gapped-workflow/#option-2-with-intermediate-tarball) can be found at the attached links.

A summary of steps for relocating a package repository bundle to an air-gapped environment are documented for both options below:

For `Option 1`:
* Get to a location that can access both registries. If there is no such location, you will have to use `Option 2` steps.
* [Authenticate](/imgpkg/docs/latest/auth.md) with both source and destination registries
* Run `imgpkg copy -b index.docker.io/user1/simple-app-bundle:v1.0.0 --to-repo final-registry.corp.com/apps/simple-app-bundle`

For `Option 2`:
* Get to a location that can access the source registry
* [Authenticate](/imgpkg/docs/latest/auth.md) with the source registry
* Run `imgpkg copy -b index.docker.io/user1/simple-app-bundle:v1.0.0 --to-tar /tmp/my-image.tar`
* Make sure the tar file is in a location that has access to the destination registry
* Authenticate with the destination registry
* Run `imgpkg copy --tar /tmp/my-image.tar --to-repo final-registry.corp.com/apps/simple-app-bundle`

## Use Relocated Bundle or Image with PackageRepository

Once you have relocated the package repository bundle into the destination OCI registry in your air-gapped environment, you can
now reference the relocated bundle in a PackageRepository definition:

```yaml
---
apiVersion: install.package.carvel.dev/v1alpha1
kind: PackageRepository
metadata:
name: simple-package-repository
spec:
fetch:
imgpkgBundle:
image: final-registry.corp.com/apps/simple-app-bundle
```
In the event your PackageRepository needs authentication to pull the bundle, you can read more about kapp-controller's
[private authentication workflows using secretgen-controller](private-registry-auth.md) or [without secretgen-controller](private-registry-auth.md#packagerepository-authentication-without-secretgen-controller).
After applying the PackageRepository definition above to your Kubernetes cluster, you will be able to check that the PackageRepository and
its associated Packages were successfully deployed by checking the PackageRepository status:
```bash
$ kubectl get packagerepository/simple-package-repository
```

You will see a message of `Reconcile Succeeded` in the `DESCRIPTION` column of the output from `kubectl` if the PackageRepository was deloyed
successfully. You can also run `kubectl get packages` to see that all Packages were introduced successfully.
107 changes: 107 additions & 0 deletions site/content/kapp-controller/docs/v0.31.0/app-examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
title: Example Usage
---

Below are some example App CRs showing common ways our users have used App CRs. Full App CR spec can be found [here](app-spec.md).

## Gitops with an app
In this example a user wants to keep their app up to date with changes to the source Git repo

```yaml
apiVersion: kappctrl.k14s.io/v1alpha1
kind: App
metadata:
name: simple-app
spec:
serviceAccountName: default
fetch:
- git:
url: https://github.com/k14s/k8s-simple-app-example
ref: origin/develop
subPath: config-step-2-template

template:
- ytt: {}

deploy:
- kapp: {}
```
## Gitops with a Helm chart
In this example a user wants to keep their cluster up to date with the latest version of a Helm chart fetched from a Git repo
```yaml
apiVersion: kappctrl.k14s.io/v1alpha1
kind: App
metadata:
name: nginx-helm
pec:
fetch:
- git:
url: https://github.com/bitnami/charts
ref: origin/master
subPath: bitnami/nginx

template:
- helmTemplate:
valuesFrom:
- secretRef:
name: nginx-values

deploy:
- kapp: {}
```
## Install a Helm chart
In this example a user wants to keep their cluster up to date with the latest version of a Helm chart
```yaml
apiVersion: kappctrl.k14s.io/v1alpha1
kind: App
metadata:
name: concourse-helm
spec:
fetch:
- helmChart:
name: stable/concourse

template:
- helmTemplate:
valuesFrom:
- secretRef:
name: concourse-values

deploy:
- kapp: {}
```
## Customize a Helm chart by adding an overlay
In this example a user wants to use `helm template`, but then modify the resulting YAML by adding their own add their own `ytt overlay`
```yaml
apiVersion: kappctrl.k14s.io/v1alpha1
kind: App
metadata:
name: concourse-helm
spec:
fetch:
- git:
url: https://github.com/bitnami/charts
ref: origin/master
subPath: bitnami/nginx
template:
- helmTemplate: {}
- ytt:
ignoreUnknownComments: true
inline:
paths:
remove-lb.yml: |
#@ load("@ytt:overlay", "overlay")
#@overlay/match by=overlay.subset({"kind":"Service","metadata":{"name":"nginx"}})
---
spec:
type: ClusterIP
#@overlay/remove
externalTrafficPolicy:
deploy:
- kapp: {}
```
Loading

0 comments on commit 7fd66b7

Please sign in to comment.