add a /scratch emptyDir to ark pods to use for restic cache

Signed-off-by: Steve Kriss <steve@heptio.com>
This commit is contained in:
Steve Kriss
2018-06-20 11:46:45 -07:00
parent 4a7457ecfe
commit 25d3597c9a
10 changed files with 72 additions and 4 deletions

View File

@@ -43,12 +43,18 @@ spec:
mountPath: /credentials
- name: plugins
mountPath: /plugins
- name: scratch
mountPath: /scratch
env:
- name: AWS_SHARED_CREDENTIALS_FILE
value: /credentials/cloud
- name: ARK_SCRATCH_DIR
value: /scratch
volumes:
- name: cloud-credentials
secret:
secretName: cloud-credentials
- name: plugins
emptyDir: {}
- name: scratch
emptyDir: {}

View File

@@ -36,6 +36,8 @@ spec:
- name: host-pods
hostPath:
path: /var/lib/kubelet/pods
- name: scratch
emptyDir: {}
containers:
- name: ark
image: gcr.io/heptio-images/ark:latest
@@ -49,6 +51,8 @@ spec:
mountPath: /credentials
- name: host-pods
mountPath: /host_pods
- name: scratch
mountPath: /scratch
env:
- name: NODE_NAME
valueFrom:
@@ -60,3 +64,5 @@ spec:
fieldPath: metadata.namespace
- name: AWS_SHARED_CREDENTIALS_FILE
value: /credentials/cloud
- name: ARK_SCRATCH_DIR
value: /scratch

View File

@@ -44,11 +44,18 @@ spec:
envFrom:
- secretRef:
name: cloud-credentials
env:
- name: ARK_SCRATCH_DIR
value: /scratch
volumeMounts:
- name: plugins
mountPath: /plugins
- name: scratch
mountPath: /scratch
volumes:
- name: plugins
emptyDir: {}
- name: scratch
emptyDir: {}
nodeSelector:
beta.kubernetes.io/os: linux

View File

@@ -33,6 +33,8 @@ spec:
- name: host-pods
hostPath:
path: /var/lib/kubelet/pods
- name: scratch
emptyDir: {}
containers:
- name: ark
image: gcr.io/heptio-images/ark:latest
@@ -44,6 +46,8 @@ spec:
volumeMounts:
- name: host-pods
mountPath: /host_pods
- name: scratch
mountPath: /scratch
envFrom:
- secretRef:
name: cloud-credentials
@@ -66,4 +70,5 @@ spec:
secretKeyRef:
name: cloud-credentials
key: AZURE_STORAGE_KEY
- name: ARK_SCRATCH_DIR
value: /scratch

View File

@@ -46,12 +46,18 @@ spec:
mountPath: /credentials
- name: plugins
mountPath: /plugins
- name: scratch
mountPath: /scratch
env:
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /credentials/cloud
- name: ARK_SCRATCH_DIR
value: /scratch
volumes:
- name: cloud-credentials
secret:
secretName: cloud-credentials
- name: plugins
emptyDir: {}
- name: scratch
emptyDir: {}

View File

@@ -36,6 +36,8 @@ spec:
- name: host-pods
hostPath:
path: /var/lib/kubelet/pods
- name: scratch
emptyDir: {}
containers:
- name: ark
image: gcr.io/heptio-images/ark:latest
@@ -49,6 +51,8 @@ spec:
mountPath: /credentials
- name: host-pods
mountPath: /host_pods
- name: scratch
mountPath: /scratch
env:
- name: NODE_NAME
valueFrom:
@@ -60,3 +64,5 @@ spec:
fieldPath: metadata.namespace
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /credentials/cloud
- name: ARK_SCRATCH_DIR
value: /scratch

View File

@@ -46,12 +46,18 @@ spec:
mountPath: /credentials
- name: plugins
mountPath: /plugins
- name: scratch
mountPath: /scratch
env:
- name: AWS_SHARED_CREDENTIALS_FILE
value: /credentials/cloud
- name: ARK_SCRATCH_DIR
value: /scratch
volumes:
- name: cloud-credentials
secret:
secretName: cloud-credentials
- name: plugins
emptyDir: {}
- name: scratch
emptyDir: {}

View File

@@ -46,12 +46,18 @@ spec:
mountPath: /credentials
- name: plugins
mountPath: /plugins
- name: scratch
mountPath: /scratch
env:
- name: AWS_SHARED_CREDENTIALS_FILE
value: /credentials/cloud
- name: ARK_SCRATCH_DIR
value: /scratch
volumes:
- name: cloud-credentials
secret:
secretName: cloud-credentials
- name: plugins
emptyDir: {}
- name: scratch
emptyDir: {}

View File

@@ -36,6 +36,8 @@ spec:
- name: host-pods
hostPath:
path: /var/lib/kubelet/pods
- name: scratch
emptyDir: {}
containers:
- name: ark
image: gcr.io/heptio-images/ark:latest
@@ -49,6 +51,8 @@ spec:
mountPath: /credentials
- name: host-pods
mountPath: /host_pods
- name: scratch
mountPath: /scratch
env:
- name: NODE_NAME
valueFrom:
@@ -60,3 +64,5 @@ spec:
fieldPath: metadata.namespace
- name: AWS_SHARED_CREDENTIALS_FILE
value: /credentials/cloud
- name: ARK_SCRATCH_DIR
value: /scratch

View File

@@ -18,7 +18,9 @@ package restic
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
)
@@ -48,6 +50,14 @@ func (c *Command) StringSlice() []string {
if c.PasswordFile != "" {
res = append(res, passwordFlag(c.PasswordFile))
}
// If ARK_SCRATCH_DIR is defined, put the restic cache within it. If not,
// allow restic to choose the location. This makes running either in-cluster
// or local (dev) work properly.
if scratch := os.Getenv("ARK_SCRATCH_DIR"); scratch != "" {
res = append(res, cacheDirFlag(filepath.Join(scratch, ".cache", "restic")))
}
res = append(res, c.Args...)
res = append(res, c.ExtraFlags...)
@@ -75,3 +85,7 @@ func repoFlag(repoIdentifier string) string {
func passwordFlag(file string) string {
return fmt.Sprintf("--password-file=%s", file)
}
func cacheDirFlag(dir string) string {
return fmt.Sprintf("--cache-dir=%s", dir)
}