Skip to content

Instantly share code, notes, and snippets.

@pengsun
Last active March 30, 2020 12:17
Show Gist options
  • Save pengsun/6438c8571a730f4d4c2d22482d36146b to your computer and use it in GitHub Desktop.
Save pengsun/6438c8571a730f4d4c2d22482d36146b to your computer and use it in GitHub Desktop.
{# pre-pull images into each node with "pulling concurrency control" #}
{% set image = "your_repo/your_image:your_tag" %}
{% set docker_registry_credential = "your-cred" %}
{% set node_key = "type" %}
{% set node_value = "cpu" %}
{% set n_nodes = 1 %}
{# this concurrency number can be gradually changed afterwards, by using, e.g., k edit your_replicaset #}
kind: ReplicaSet
apiVersion: extensions/v1beta1
metadata:
name: pre-pull-image
spec:
replicas: {{ n_nodes }}
template:
metadata:
labels:
hasOnePodOnNode: yy
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: {{ node_key }}
operator: In
values:
- {{ node_value }}
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: hasOnePodOnNode
operator: In
values:
- yy
topologyKey: "kubernetes.io/hostname"
{% if docker_registry_credential != "" %}
imagePullSecrets:
- name: {{ docker_registry_credential }}
{% endif %}
containers:
- name: tmp-pre-pull-image
image: {{ image }}
imagePullPolicy: IfNotPresent
command:
- "sleep"
args:
- "36000000"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment