Skip to content

Commit

Permalink
add running kapp in cluster example
Browse files Browse the repository at this point in the history
  • Loading branch information
cppforlife committed Mar 21, 2019
1 parent ec78b70 commit 3c045a8
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/kapp-on-cluster/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Kapp on cluster

This example shows how to run `kapp` continiously in cluster, and converge a set of apps available in a repositiory.

To install perform:

```bash
$ ytt t -R -f examples/kapp-on-cluster/ | kapp --yes deploy -a kapp-on-cluster -f - --diff-changes
```

See `cron.yml` for details on what this script does every 1m.
37 changes: 37 additions & 0 deletions examples/kapp-on-cluster/cron.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#@ load("@ytt:data", "data")

apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: kapp-on-cluster
namespace: #@ data.values.namespace
spec:
schedule: "*/1 * * * *"
suspend: #@ data.values.suspend
jobTemplate:
spec:
template:
spec:
serviceAccount: kapp-on-cluster-sa
restartPolicy: Never
containers:
- name: deploy
image: ubuntu:xenial
args:
- /bin/bash
- -c
- |
set -e -x
apt-get update
apt-get -y install wget git
echo "Installing kapp..."
wget -O- ??? > /tmp/kapp
mv /tmp/kapp /usr/local/bin/kapp
chmod +x /usr/local/bin/kapp
echo "Installed kapp"
git clone https://github.com/k14s/kapp
cd kapp
kapp --tty --yes app-group -g gitops deploy --directory examples/gitops
5 changes: 5 additions & 0 deletions examples/kapp-on-cluster/defaults.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#@data/values
---
#! namespace indicates where kapp will be installed
namespace: default
suspend: false
31 changes: 31 additions & 0 deletions examples/kapp-on-cluster/rbac-cluster-admin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#@ load("@ytt:data", "data")

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: kapp-on-cluster-admin
rules:
- apiGroups: ['*']
resources: ['*']
verbs: ['*']
- nonResourceURLs: ['*']
verbs: ['*']
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: kapp-on-cluster-admin-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: kapp-on-cluster-admin
subjects:
- kind: ServiceAccount
name: kapp-on-cluster-sa
namespace: #@ data.values.namespace
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: kapp-on-cluster-sa
namespace: #@ data.values.namespace

0 comments on commit 3c045a8

Please sign in to comment.