-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
06e5201
commit d0ef74b
Showing
15 changed files
with
262 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
set -e | ||
set -u | ||
set -o pipefail | ||
source ../setup.sh | ||
|
||
# deploy | ||
echo "deploying [item-monitor] ..." | ||
sops -d ../secrets.sops | | ||
ytt --ignore-unknown-comments -f templates -f values.yml -f ../configuration.yml -f - | | ||
kbld -f - -f image.lock.yml | | ||
kapp deploy -a item-monitor -c -y -f - | ||
kapp app-change garbage-collect -a item-monitor --max 5 -y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
set -e | ||
set -u | ||
set -o pipefail | ||
source ../setup.sh | ||
|
||
# diff | ||
kapp app-change list -a item-monitor | ||
sops -d ../secrets.sops | | ||
ytt --ignore-unknown-comments -f templates -f values.yml -f ../configuration.yml -f - | | ||
kbld -f - -f image.lock.yml | | ||
kapp deploy -a item-monitor -c --diff-run -f - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: kbld.k14s.io/v1alpha1 | ||
kind: Config | ||
minimumRequiredVersion: 0.32.0 | ||
overrides: | ||
- image: jamesclonk/item-monitor:9353f75 | ||
newImage: index.docker.io/jamesclonk/item-monitor@sha256:d42091cc41289c3f113d80a021a3b059d8b6ffdd211c40522a5b541ff083fc8e | ||
preresolved: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
set -e | ||
set -u | ||
set -o pipefail | ||
source ../setup.sh | ||
|
||
# lock image | ||
echo "locking images for [item-monitor] ..." | ||
sops -d ../secrets.sops | | ||
ytt --ignore-unknown-comments -f templates -f values.yml -f ../configuration.yml -f - | | ||
kbld -f - --lock-output "image.lock.yml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
set -e | ||
set -u | ||
set -o pipefail | ||
source ../setup.sh | ||
|
||
# status | ||
kapp app-change list -a item-monitor | ||
kapp inspect -a item-monitor --tree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#@ def labels(component): | ||
app: item-monitor | ||
app.kubernetes.io/name: item-monitor | ||
app.kubernetes.io/instance: item-monitor | ||
app.kubernetes.io/component: #@ component | ||
#@ end | ||
|
||
#@ def labelSelector(component): | ||
matchExpressions: | ||
- key: app | ||
operator: In | ||
values: | ||
- item-monitor | ||
- key: app.kubernetes.io/name | ||
operator: In | ||
values: | ||
- item-monitor | ||
- key: app.kubernetes.io/instance | ||
operator: In | ||
values: | ||
- item-monitor | ||
- key: app.kubernetes.io/component | ||
operator: In | ||
values: | ||
- #@ component | ||
#@ end | ||
|
||
#@ def podAntiAffinity(component): | ||
podAntiAffinity: | ||
preferredDuringSchedulingIgnoredDuringExecution: | ||
- weight: 100 | ||
podAffinityTerm: | ||
topologyKey: kubernetes.io/hostname | ||
labelSelector: #@ labelSelector(component) | ||
#@ end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#@ load("@ytt:data", "data") | ||
#@ load("_ytt.lib.yml", "labels", "podAntiAffinity") | ||
|
||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: item-monitor | ||
namespace: item-monitor | ||
labels: #@ labels("monitor") | ||
spec: | ||
selector: | ||
matchLabels: #@ labels("monitor") | ||
replicas: 1 | ||
revisionHistoryLimit: 5 | ||
template: | ||
metadata: | ||
labels: #@ labels("monitor") | ||
annotations: | ||
prometheus.io/path: "/metrics" | ||
prometheus.io/port: "8080" | ||
prometheus.io/scrape: "true" | ||
spec: | ||
serviceAccountName: item-monitor | ||
securityContext: | ||
runAsUser: 1000 | ||
runAsGroup: 1000 | ||
fsGroup: 1000 | ||
affinity: #@ podAntiAffinity("monitor") | ||
containers: | ||
- name: item-monitor | ||
image: #@ data.values.item_monitor.image | ||
securityContext: | ||
privileged: false | ||
allowPrivilegeEscalation: false | ||
env: | ||
- name: PORT | ||
value: "8080" | ||
- name: TZ | ||
value: "Europe/Zurich" | ||
resources: | ||
requests: | ||
memory: "32Mi" | ||
cpu: "50m" | ||
limits: | ||
memory: "64Mi" | ||
cpu: "100m" | ||
volumeMounts: | ||
- mountPath: /item-monitor/app/config.yaml | ||
name: config | ||
subPath: config.yaml | ||
volumes: | ||
- name: config | ||
secret: | ||
secretName: item-monitor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#@ load("@ytt:overlay", "overlay") | ||
#@ load("_ytt.lib.yml", "labels") | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: item-monitor | ||
labels: #@ labels("namespace") | ||
|
||
#@overlay/match by=overlay.all, expects="1+" | ||
--- | ||
#@overlay/match missing_ok=True | ||
metadata: | ||
#@overlay/match missing_ok=True | ||
namespace: item-monitor | ||
|
||
#@overlay/match by=overlay.subset({"kind":"Namespace", "metadata":{"name":"item-monitor"}}), expects=1 | ||
--- | ||
metadata: | ||
#@overlay/match missing_ok=True | ||
labels: | ||
#@overlay/match missing_ok=True | ||
namespace.kubernetes.io/name: item-monitor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#@ load("@ytt:data", "data") | ||
#@ load("@ytt:assert", "assert") | ||
#@ load("_ytt.lib.yml", "labels") | ||
|
||
#@ if len(data.values.secrets.item_monitor.teams.webhook_url) == 0 or data.values.secrets.item_monitor.teams.webhook_url == "http://example/deadbeef": | ||
#@ assert.fail("secrets.item_monitor.teams.webhook_url is missing or invalid") | ||
#@ end | ||
--- | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: item-monitor | ||
namespace: item-monitor | ||
labels: #@ labels("secret") | ||
annotations: | ||
kapp.k14s.io/versioned: "" | ||
type: Opaque | ||
#@yaml/text-templated-strings | ||
stringData: | ||
config.yaml: | | ||
log_level: debug | ||
log_timestamp: true | ||
interval: 4h | ||
monitors: | ||
(@ for midx in range(len(data.values.configuration.item_monitor.monitors)): -@) | ||
(@ monitor = data.values.configuration.item_monitor.monitors[midx] @) | ||
- name: (@= monitor.name @) | ||
items: | ||
(@ for idx in range(len(monitor.items)): @) | ||
(@ item = monitor.items[idx] @) | ||
- name: (@= item.name @) | ||
url: (@= item.url @) | ||
value: (@= str(item.value) @) | ||
regex: (@= item.regex @) | ||
(@ end @) | ||
(@ end @) | ||
webhooks: | ||
- url: (@= data.values.secrets.item_monitor.teams.webhook_url @) | ||
template: | | ||
{ | ||
"@type": "MessageCard", | ||
"@context": "https://schema.org/extensions", | ||
"summary": "{{ .Name }} has current price of {{ .CurrentValue }}", | ||
"themeColor": "1188dd", | ||
"title": "{{ .Name }}", | ||
"sections": [ | ||
{ | ||
"text": "{{ .Name }} has current price of {{ .CurrentValue }}" | ||
} | ||
], | ||
"potentialAction": [ | ||
{ | ||
"@type": "OpenUri", | ||
"name": "{{ .URL }}", | ||
"targets": [ | ||
{ | ||
"os": "default", | ||
"uri": "{{ .URL }}" | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#@ load("_ytt.lib.yml", "labels") | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: item-monitor | ||
namespace: item-monitor | ||
labels: #@ labels("sa") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#@data/values | ||
--- | ||
item_monitor: | ||
image: "jamesclonk/item-monitor:9353f75" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters