Convert to git clone init container in syringe pod
@@ -4,6 +4,26 @@ kind: ServiceAccount
metadata:
name: syringesa
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: git-clone
+data:
+ git-clone.sh: |
+ #!/bin/sh -e
+ REPO=$1
+ REF=$2
+ DIR=$3
+ # Init Containers will re-run on Pod restart. Remove the directory's contents
+ # and reprovision when this happens.
+ if [ -d "$DIR" ]; then
+ rm -rf $( find $DIR -mindepth 1 )
+ fi
+ git clone $REPO $DIR
+ cd $DIR
+ git reset --hard $REF
+
---
# TODO(mierdin): This could probably use some pruning
apiVersion: rbac.authorization.k8s.io/v1
@@ -62,6 +82,20 @@ metadata:
app: syringe
antidote_role: infra
spec:
+ initContainers:
+ - name: git-clone
+ image: alpine/git # Any image with git will do
+ command:
+ - /usr/local/git/git-clone.sh
+ args:
+ - "https://github.com/nre-learning/antidote.git"
+ - "master"
+ - "/antidote"
+ volumeMounts:
+ - name: git-clone
+ mountPath: /usr/local/git
+ - name: git-volume #?
+ mountPath: /antidote
# Might need an admission controller for this
serviceAccount: syringesa
@@ -71,17 +105,20 @@ spec:
imagePullPolicy: Always
env:
- name: SYRINGE_LESSONS
- value: "/lessons"
+ value: "/antidote/lessons"
ports:
- - containerPort: 50099
- - containerPort: 8086
+ - containerPort: 50099 # GRPC
+ - containerPort: 8086 # REST/HTTP
volumeMounts:
- - name: lessons
- mountPath: /lessons
+ - mountPath: /antidote
+ name: git-volume
volumes:
- - name: lessons
- hostPath:
- path: /home/mierdin/antidote/lessons
+ - name: git-volume
+ emptyDir: {}
+ - name: git-clone
+ configMap:
+ name: git-clone
+ defaultMode: 0755
# /var/run/secrets/kubernetes.io/serviceaccount
