From b0576b227bbe5f86662b647968054ab96fa5ac4e Mon Sep 17 00:00:00 2001 From: Moritz Graf Date: Thu, 9 Apr 2020 22:53:18 +0200 Subject: [PATCH] Adding redeploy for corona-api --- k8s/README.md | 10 +++++ k8s/datalab/redeploy-corona-api.yaml | 56 ++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 k8s/datalab/redeploy-corona-api.yaml diff --git a/k8s/README.md b/k8s/README.md index c4cb607..19ae93f 100644 --- a/k8s/README.md +++ b/k8s/README.md @@ -6,6 +6,16 @@ This folder holds all the services required for my private infrastructure. Follo * Every namespace has a subfolder within this subdirectory. * helm3 +# Operations + +Cleanup `Error` pods. + +```sh +kubectl get pods | grep Error | cut -d' ' -f 1 | xargs kubectl delete pod +``` + +# Deployment + ## namespaces ```sh diff --git a/k8s/datalab/redeploy-corona-api.yaml b/k8s/datalab/redeploy-corona-api.yaml new file mode 100644 index 0000000..61af801 --- /dev/null +++ b/k8s/datalab/redeploy-corona-api.yaml @@ -0,0 +1,56 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + creationTimestamp: null + name: redeploy + namespace: datalab +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + namespace: datalab + name: redeploy +rules: +- apiGroups: ["apps"] + resources: ["deployments"] + verbs: ["get",list","patch"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +# This role binding allows "jane" to read pods in the "default" namespace. +# You need to already have a Role named "pod-reader" in that namespace. +kind: RoleBinding +metadata: + name: redeploy-pods + namespace: datalab +subjects: +# You can specify more than one "subject" +- kind: ServiceAccount + name: redeploy +roleRef: + # "roleRef" specifies the binding to a Role / ClusterRole + kind: Role #this must be Role or ClusterRole + name: redeploy + apiGroup: rbac.authorization.k8s.io + +--- +apiVersion: batch/v1beta1 +kind: CronJob +metadata: + name: redeploy-corona-api + namespace: datalab +spec: + schedule: "0 1 * * *" + jobTemplate: + spec: + template: + spec: + serviceAccountName: redeploy + imagePullSecrets: + - name: "hub-moritzgraf-de" + containers: + - name: redeploy-corona-api + image: hub.moritzgraf.de:5000/redeploy:latest + env: + - name: DEPLOYMENT + value: "corona-api" + restartPolicy: Never \ No newline at end of file