- add liveness check/fix readiness check - ensure 'redis-cli ping' actually returns 'PONG', as exit code is 0 even if errors will detect situations where redis is not available, such as due to to max clients being reached - bump redis memory/cpu for now (until autoscaling/automatic adjustment is available)
131 lines
2.6 KiB
YAML
131 lines
2.6 KiB
YAML
# -------
|
|
# PVC
|
|
# -------
|
|
|
|
apiVersion: v1
|
|
kind: PersistentVolumeClaim
|
|
metadata:
|
|
name: {{ name }}
|
|
namespace: {{ namespace }}
|
|
labels:
|
|
crawl: {{ id }}
|
|
role: redis
|
|
|
|
spec:
|
|
accessModes:
|
|
- ReadWriteOnce
|
|
|
|
resources:
|
|
requests:
|
|
storage: {{ redis_storage }}
|
|
|
|
{% if volume_storage_class %}
|
|
storageClassName: {{ volume_storage_class }}
|
|
{% endif %}
|
|
|
|
# --------
|
|
# REDIS
|
|
# --------
|
|
{% if init_redis %}
|
|
---
|
|
apiVersion: v1
|
|
kind: Pod
|
|
metadata:
|
|
name: {{ name }}
|
|
namespace: {{ namespace }}
|
|
labels:
|
|
crawl: {{ id }}
|
|
role: redis
|
|
|
|
spec:
|
|
hostname: {{ name }}
|
|
subdomain: redis
|
|
|
|
terminationGracePeriodSeconds: 10
|
|
volumes:
|
|
- name: shared-redis-conf
|
|
configMap:
|
|
name: shared-redis-conf
|
|
items:
|
|
- key: redis.conf
|
|
path: redis.conf
|
|
|
|
- name: redis-data
|
|
persistentVolumeClaim:
|
|
claimName: {{ name }}
|
|
|
|
affinity:
|
|
nodeAffinity:
|
|
preferredDuringSchedulingIgnoredDuringExecution:
|
|
- weight: 1
|
|
preference:
|
|
matchExpressions:
|
|
- key: nodeType
|
|
operator: In
|
|
values:
|
|
- "{{ redis_node_type }}"
|
|
|
|
podAffinity:
|
|
preferredDuringSchedulingIgnoredDuringExecution:
|
|
- weight: 2
|
|
podAffinityTerm:
|
|
topologyKey: "failure-domain.beta.kubernetes.io/zone"
|
|
labelSelector:
|
|
matchLabels:
|
|
crawl: {{ id }}
|
|
|
|
tolerations:
|
|
- key: nodeType
|
|
operator: Equal
|
|
value: crawling
|
|
effect: NoSchedule
|
|
- key: node.kubernetes.io/not-ready
|
|
operator: Exists
|
|
tolerationSeconds: 300
|
|
effect: NoExecute
|
|
- key: node.kubernetes.io/unreachable
|
|
operator: Exists
|
|
effect: NoExecute
|
|
tolerationSeconds: 300
|
|
|
|
containers:
|
|
- name: redis
|
|
image: {{ redis_image }}
|
|
imagePullPolicy: {{ redis_image_pull_policy }}
|
|
|
|
args: ["/redis-conf/redis.conf", "--appendonly", "yes"]
|
|
volumeMounts:
|
|
- name: redis-data
|
|
mountPath: /data
|
|
|
|
- name: shared-redis-conf
|
|
mountPath: /redis-conf
|
|
|
|
resources:
|
|
limits:
|
|
memory: {{ redis_memory }}
|
|
|
|
requests:
|
|
cpu: {{ redis_cpu }}
|
|
memory: {{ redis_memory }}
|
|
|
|
readinessProbe:
|
|
initialDelaySeconds: 10
|
|
timeoutSeconds: 5
|
|
exec:
|
|
command:
|
|
- bash
|
|
- -c
|
|
- "res=$(redis-cli ping); [[ $res = 'PONG' ]]"
|
|
|
|
livenessProbe:
|
|
initialDelaySeconds: 10
|
|
timeoutSeconds: 5
|
|
exec:
|
|
command:
|
|
- bash
|
|
- -c
|
|
- "res=$(redis-cli ping); [[ $res = 'PONG' ]]"
|
|
|
|
{% endif %}
|