add restart ability - wip
This commit is contained in:
parent
a00b4e2732
commit
67acfef563
7 changed files with 96 additions and 0 deletions
src
main
cljc/dda/c4k_jitsi
resources/jitsi
test/cljc/dda/c4k_jitsi
|
@ -40,6 +40,7 @@
|
||||||
(jitsi/web-config resolved-config)
|
(jitsi/web-config resolved-config)
|
||||||
(jitsi/jvb-config resolved-config)
|
(jitsi/jvb-config resolved-config)
|
||||||
(jitsi/jibri-config resolved-config)
|
(jitsi/jibri-config resolved-config)
|
||||||
|
(jitsi/restart-config resolved-config)
|
||||||
(jitsi/etherpad-config resolved-config)
|
(jitsi/etherpad-config resolved-config)
|
||||||
(jitsi/excalidraw-config resolved-config)
|
(jitsi/excalidraw-config resolved-config)
|
||||||
(jitsi/moderator-elector-config resolved-config)
|
(jitsi/moderator-elector-config resolved-config)
|
||||||
|
|
|
@ -117,6 +117,15 @@
|
||||||
(load-and-adjust-namespace "jitsi/jibri-config-service.yaml" namespace)
|
(load-and-adjust-namespace "jitsi/jibri-config-service.yaml" namespace)
|
||||||
(load-and-adjust-namespace "jitsi/jibri-config-deployment.yaml" namespace)]))
|
(load-and-adjust-namespace "jitsi/jibri-config-deployment.yaml" namespace)]))
|
||||||
|
|
||||||
|
(defn-spec restart-config cp/map-or-seq?
|
||||||
|
[config config?]
|
||||||
|
(let [{:keys [namespace]} config]
|
||||||
|
[(load-and-adjust-namespace "jitsi/restart-config-serviceaccount.yaml" namespace)
|
||||||
|
(load-and-adjust-namespace "jitsi/restart-config-rolebinding.yaml" namespace)
|
||||||
|
(->
|
||||||
|
(load-and-adjust-namespace "jitsi/restart-config-authorization.yaml" namespace)
|
||||||
|
(cm/replace-key-value :resourceNames ["etherpad", "excalidraw"]))]))
|
||||||
|
|
||||||
(defn-spec etherpad-config cp/map-or-seq?
|
(defn-spec etherpad-config cp/map-or-seq?
|
||||||
[config config?]
|
[config config?]
|
||||||
(let [{:keys [namespace]} config]
|
(let [{:keys [namespace]} config]
|
||||||
|
|
11
src/main/resources/jitsi/restart-config-authorization.yaml
Normal file
11
src/main/resources/jitsi/restart-config-authorization.yaml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: Role
|
||||||
|
metadata:
|
||||||
|
name: deployment-restart
|
||||||
|
namespace: NAMESPACE
|
||||||
|
rules:
|
||||||
|
- apiGroups: ["apps", "extensions"]
|
||||||
|
resources: ["deployments"]
|
||||||
|
resourceNames: REPLACE_ME
|
||||||
|
verbs: ["get", "patch", "list", "watch"] # "list" and "watch" are only needed
|
||||||
|
# if you want to use `rollout status
|
25
src/main/resources/jitsi/restart-config-cron.yaml
Normal file
25
src/main/resources/jitsi/restart-config-cron.yaml
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: CronJob
|
||||||
|
metadata:
|
||||||
|
name: deployment-restart
|
||||||
|
namespace: NAMESPACE
|
||||||
|
spec:
|
||||||
|
concurrencyPolicy: Forbid
|
||||||
|
schedule: SCHEDULE_REPLACE_Me
|
||||||
|
jobTemplate:
|
||||||
|
spec:
|
||||||
|
backoffLimit: 2
|
||||||
|
activeDeadlineSeconds: 600
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
serviceAccountName: deployment-restart
|
||||||
|
restartPolicy: Never
|
||||||
|
containers:
|
||||||
|
- name: kubectl
|
||||||
|
image: bitnami/kubectl
|
||||||
|
command:
|
||||||
|
- bash
|
||||||
|
- -c
|
||||||
|
- >-
|
||||||
|
kubectl rollout restart deployment/<YOUR DEPLOYMENT NAME> &&
|
||||||
|
kubectl rollout status deployment/<YOUR DEPLOYMENT NAME>
|
13
src/main/resources/jitsi/restart-config-rolebinding.yaml
Normal file
13
src/main/resources/jitsi/restart-config-rolebinding.yaml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: RoleBinding
|
||||||
|
metadata:
|
||||||
|
name: deployment-restart
|
||||||
|
namespace: NAMESPACE
|
||||||
|
roleRef:
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
kind: Role
|
||||||
|
name: deployment-restart
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: deployment-restart
|
||||||
|
namespace: NAMESPACE
|
|
@ -0,0 +1,5 @@
|
||||||
|
kind: ServiceAccount
|
||||||
|
apiVersion: v1
|
||||||
|
metadata:
|
||||||
|
name: deployment-restart
|
||||||
|
namespace: NAMESPACE
|
|
@ -110,3 +110,35 @@
|
||||||
(count (cut/moderator-elector-config
|
(count (cut/moderator-elector-config
|
||||||
{:fqdn "xy.xy.xy"
|
{:fqdn "xy.xy.xy"
|
||||||
:namespace "jitsi"})))))
|
:namespace "jitsi"})))))
|
||||||
|
|
||||||
|
(deftest should-generate-restart
|
||||||
|
(is (= {:apiVersion "rbac.authorization.k8s.io/v1",
|
||||||
|
:kind "RoleBinding",
|
||||||
|
:metadata {:name "deployment-restart", :namespace "jitsi"},
|
||||||
|
:roleRef
|
||||||
|
{:apiGroup "rbac.authorization.k8s.io",
|
||||||
|
:kind "Role",
|
||||||
|
:name "deployment-restart"},
|
||||||
|
:subjects
|
||||||
|
[{:kind "ServiceAccount",
|
||||||
|
:name "deployment-restart",
|
||||||
|
:namespace "jitsi"}]}
|
||||||
|
(second (cut/restart-config
|
||||||
|
{:fqdn "xy.xy.xy"
|
||||||
|
:namespace "jitsi"}))))
|
||||||
|
(is (= {:apiVersion "rbac.authorization.k8s.io/v1",
|
||||||
|
:kind "Role",
|
||||||
|
:metadata {:name "deployment-restart", :namespace "jitsi"},
|
||||||
|
:rules
|
||||||
|
[{:apiGroups ["apps" "extensions"],
|
||||||
|
:resources ["deployments"],
|
||||||
|
:resourceNames ["etherpad" "excalidraw"],
|
||||||
|
:verbs ["get" "patch" "list" "watch"]}]}
|
||||||
|
(nth (cut/restart-config
|
||||||
|
{:fqdn "xy.xy.xy"
|
||||||
|
:namespace "jitsi"})
|
||||||
|
2)))
|
||||||
|
(is (= 3
|
||||||
|
(count (cut/restart-config
|
||||||
|
{:fqdn "xy.xy.xy"
|
||||||
|
:namespace "jitsi"})))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue