Skip to content

Instantly share code, notes, and snippets.

@Tim-Schwalbe
Last active November 18, 2018 11:37
Show Gist options
  • Save Tim-Schwalbe/e66089a48b8e89efb8453c38c6caf114 to your computer and use it in GitHub Desktop.
Save Tim-Schwalbe/e66089a48b8e89efb8453c38c6caf114 to your computer and use it in GitHub Desktop.
Cache Images in K8S
apiVersion: apps/v1beta2
kind: DaemonSet
metadata:
name: prepull-image
spec:
selector:
matchLabels:
name: prepull-image
template:
metadata:
labels:
name: prepull-image
spec:
initContainers:
- name: prepull
image: eu.gcr.io/YOUR_IMAGE:latest
command: ["/bin/sh"]
args: ["-c", "ls"]
containers:
- name: pause
image: gcr.io/google_containers/pause
Cache Image:
variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://localhost:2375
image: dtzar/helm-kubectl:2.10.0
stage: Cache Image
before_script:
- apk update && apk add curl docker sed
- echo $KUBE_CONFIG | base64 -d > ./kube_config
- export KUBECONFIG=$PWD/kube_config
script:
- kubectl delete daemonset prepull-image -n YOUR_NAMESPACE
- kubectl apply -f cache_docker_images_in_cluster.yaml -n YOUR_NAMESPACE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment