Skip to content

Commit 45975b9

Browse files
author
edgar sarkisian
committed
add oracle-updater install script
1 parent d643a05 commit 45975b9

File tree

5 files changed

+134
-17
lines changed

5 files changed

+134
-17
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
apiVersion: v2
2+
name: oracle-updater
3+
description: A Helm chart for the Switchboard Oracle Updater
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.0.2
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "0.0.1"
25+
26+
icon: "https://raw.githubusercontent.com/switchboard-xyz/switchboard/main/website/static/img/icons/switchboard/avatar.png"
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
4+
metadata:
5+
name: oracle-updater
6+
namespace: {{ $.Values.oracle_updater.namespace | quote }}
7+
8+
labels:
9+
app: oracle-updater
10+
11+
spec:
12+
replicas: 1
13+
14+
selector:
15+
matchLabels:
16+
app: oracle-updater
17+
18+
strategy:
19+
rollingUpdate:
20+
maxSurge: 1
21+
maxUnavailable: 0
22+
23+
template:
24+
metadata:
25+
annotations:
26+
labels:
27+
app: oracle-updater
28+
29+
spec:
30+
serviceAccountName: oracle-updater
31+
containers:
32+
- image: {{ printf "%s:%s" $.Values.oracle_updater.image $.Values.oracle_updater.image_tag | quote }}
33+
imagePullPolicy: IfNotPresent
34+
name: oracle-updater
35+
36+
resources:
37+
limits:
38+
cpu: {{ $.Values.oracle_updater.resources.limits.cpu }}
39+
memory: {{ $.Values.oracle_updater.resources.limits.memory }}
40+
requests:
41+
cpu: {{ $.Values.oracle_updater.resources.requests.cpu }}
42+
memory: {{ $.Values.oracle_updater.resources.requests.memory }}
43+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: oracle-updater
6+
namespace: {{ $.Values.oracle_updater.namespace | quote }}
7+
---
8+
apiVersion: rbac.authorization.k8s.io/v1
9+
kind: ClusterRole
10+
metadata:
11+
name: oracle-updater
12+
rules:
13+
- apiGroups: ["apps"]
14+
resources: ["deployments"]
15+
verbs: ["get", "list", "watch", "patch"]
16+
---
17+
apiVersion: rbac.authorization.k8s.io/v1
18+
kind: ClusterRoleBinding
19+
metadata:
20+
name: oracle-updater
21+
roleRef:
22+
apiGroup: rbac.authorization.k8s.io
23+
kind: ClusterRole
24+
name: oracle-updater
25+
subjects:
26+
- kind: ServiceAccount
27+
name: oracle-updater
28+
namespace: {{ $.Values.oracle_updater.namespace | quote }}
29+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
oracle_updater:
2+
image: "docker.io/switchboardlabs/oracle-updater"
3+
image_tag: "0.0.2"
4+
namespace: "oracle-updater"
5+
command: ""
6+
resources:
7+
limits:
8+
cpu: "250m"
9+
memory: "256Mi"
10+
requests:
11+
cpu: "100m"
12+
memory: "128Mi"
Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
#!/usr/bin/env bash
22
set -u -e
33

4-
echo "HELM: adding Watchtower (Keel) repo"
5-
helm repo add keel https://charts.keel.sh >/dev/null
6-
helm repo update >/dev/null
7-
echo "HELM: Watchtower (Keel) repo added"
4+
echo "HELM: Checking for existing watchtower releases (replaced in favour of oracle-updater)"
85

9-
WATCHTOWER_NS="watchtower"
10-
if [[ "$(kubectl get ns | grep -e '^'${WATCHTOWER_NS}'\W')" == "" ]]; then
11-
echo "KUBECTL: creating Namespace ${WATCHTOWER_NS}"
12-
kubectl create namespace "${WATCHTOWER_NS}" >/dev/null
13-
echo "KUBECTL: Namespace ${WATCHTOWER_NS} created"
6+
if read -r WATCHTOWER_RELEASE WATCHTOWER_NS _ < <(helm list -A -f "^watchtower$" --no-headers 2>/dev/null); then
7+
echo "HELM: Deleting installed Watchtower release in ${WATCHTOWER_NS}"
8+
helm uninstall -n "${WATCHTOWER_NS}" "${WATCHTOWER_RELEASE}" >/dev/null
9+
echo "HELM: Deleted existing Watchtower release"
10+
kubectl delete ns $WATCHTOWER_NS >/dev/null
11+
echo "KUBECTL: Deleted watchtower namespace"
1412
fi
1513

16-
echo "HELM: Installing Watchtower (keel)"
17-
helm upgrade -i "watchtower" \
18-
-n "${WATCHTOWER_NS}" \
19-
--set debug="false" \
20-
--set helmProvider.enabled="false" \
21-
--set polling.defaultSchedule="@every $((74 + RANDOM % 46))s" \
22-
keel/keel >/dev/null
23-
echo "HELM: Watchtower (keel) installed"
14+
ORACLE_UPDATER_NS="oracle-updater"
15+
if [[ "$(kubectl get ns | grep -e '^'${ORACLE_UPDATER_NS}'\W')" == "" ]]; then
16+
echo "KUBECTL: creating Namespace ${ORACLE_UPDATER_NS}"
17+
kubectl create namespace "${ORACLE_UPDATER_NS}" >/dev/null
18+
echo "KUBECTL: Namespace ${ORACLE_UPDATER_NS} created"
19+
fi
20+
21+
helm_dir="${repo_dir}/.scripts/helm/"
22+
helm_charts_dir="${helm_dir}/charts/"
23+
helm_oracle_updater_chart_dir="${helm_charts_dir}/oracle-updater/"
24+
25+
echo "HELM: Installing oracle-updater"
26+
helm upgrade -i "oracle-updater" \
27+
-n "${ORACLE_UPDATER_NS}" \
28+
"${helm_oracle_updater_chart_dir}" >/dev/null
29+
30+
echo "HELM: oracle-updater installed"

0 commit comments

Comments
 (0)