c12s-kubespray/roles/kubernetes-apps/registry/templates/registry-rs.yml.j2
zhengtianbao e35a87e3eb
Update registry template (#8198)
* Add registry replica setting

* Add registry liveness and readiness probe

* Set the security context for registry

* Add registry pvc access mode option

* registry add replica requirement check

* docs: add registry replicas setting note

* Update docs/kubernetes-apps/registry.md

Co-authored-by: Cristian Calin <6627509+cristicalin@users.noreply.github.com>

Co-authored-by: Cristian Calin <6627509+cristicalin@users.noreply.github.com>
2021-11-22 02:45:09 -08:00

63 lines
1.8 KiB
Django/Jinja

---
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: registry
namespace: {{ registry_namespace }}
labels:
k8s-app: registry
version: v{{ registry_image_tag }}
addonmanager.kubernetes.io/mode: Reconcile
spec:
{% if registry_storage_class != "" and registry_storage_access_mode == "ReadWriteMany" %}
replicas: {{ registry_replica_count }}
{% else %}
replicas: 1
{% endif %}
selector:
matchLabels:
k8s-app: registry
version: v{{ registry_image_tag }}
template:
metadata:
labels:
k8s-app: registry
version: v{{ registry_image_tag }}
spec:
priorityClassName: {% if registry_namespace == 'kube-system' %}system-cluster-critical{% else %}k8s-cluster-critical{% endif %}{{''}}
serviceAccountName: registry
securityContext:
fsGroup: 1000
runAsUser: 1000
containers:
- name: registry
image: {{ registry_image_repo }}:{{ registry_image_tag }}
imagePullPolicy: {{ k8s_image_pull_policy }}
env:
- name: REGISTRY_HTTP_ADDR
value: :{{ registry_port }}
- name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY
value: /var/lib/registry
volumeMounts:
- name: registry-pvc
mountPath: /var/lib/registry
ports:
- containerPort: {{ registry_port }}
name: registry
protocol: TCP
livenessProbe:
httpGet:
path: /
port: {{ registry_port }}
readinessProbe:
httpGet:
path: /
port: {{ registry_port }}
volumes:
- name: registry-pvc
{% if registry_storage_class != "" %}
persistentVolumeClaim:
claimName: registry-pvc
{% else %}
emptyDir: {}
{% endif %}