provisioning-catalog/components/ontoref_panel/cluster/templates/deployment.yaml.j2

181 lines
6.4 KiB
Django/Jinja

apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ taskserv.name }}
namespace: {{ taskserv.namespace }}
labels:
app.kubernetes.io/name: {{ taskserv.name }}
app.kubernetes.io/managed-by: provisioning
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app.kubernetes.io/name: {{ taskserv.name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ taskserv.name }}
app.kubernetes.io/managed-by: provisioning
spec:
{% if taskserv.node %}
nodeSelector:
kubernetes.io/hostname: {{ taskserv.node }}
{% endif %}
{% if taskserv.placement is defined and taskserv.placement.node_class %}
affinity:
nodeAffinity:
{% if taskserv.placement.mode == "require" %}
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-class.{{ taskserv.placement.node_class.0 }}
operator: In
values: ["true"]
{% else %}
preferredDuringSchedulingIgnoredDuringExecution:
{% for c in taskserv.placement.node_class %}
- weight: {{ 100 - loop.index0 * 10 }}
preference:
matchExpressions:
- key: node-class.{{ c }}
operator: In
values: ["true"]
{% endfor %}
{% endif %}
{% endif %}
serviceAccountName: {{ taskserv.name }}
containers:
- name: panel
image: {{ taskserv.image }}
args: ["serve"]
ports:
- containerPort: {{ taskserv.port }}
name: http
protocol: TCP
env:
- name: PANEL_ENABLED
value: "{{ taskserv.panel_enabled }}"
- name: PANEL_NCL_PATH
value: "/config/panel.ncl"
- name: PANEL_PORT
value: "{{ taskserv.port }}"
- name: PANEL_TOKEN
valueFrom:
secretKeyRef:
name: {{ taskserv.panel_token_secret }}
key: token
{% if taskserv.panel_enabled == "mail" %}
- name: DOCKER_MAIL_SETUP_BIN
value: "{{ setup_proxy_path }}"
- name: DOCKER_MAIL_DATA_DIR
value: "{{ mail_data_mount }}"
{% endif %}
{% if taskserv.panel_enabled == "vpn" %}
- name: WG_EASY_BASE_URL
value: "{{ taskserv.wg_easy_url }}"
- name: WG_EASY_PASSWORD
valueFrom:
secretKeyRef:
name: {{ taskserv.wg_easy_secret }}
key: password
{% endif %}
{% if taskserv.panel_enabled == "dns" %}
- name: CLOUDFLARE_ZONE_ID
valueFrom:
secretKeyRef:
name: {{ taskserv.cloudflare_secret }}
key: zone_id
- name: CLOUDFLARE_API_TOKEN
valueFrom:
secretKeyRef:
name: {{ taskserv.cloudflare_secret }}
key: api_token
{% endif %}
volumeMounts:
- name: panel-config
mountPath: /config
readOnly: true
{% if taskserv.panel_enabled == "mail" %}
- name: mail-data
mountPath: {{ mail_data_mount }}
subPath: {{ taskserv.mail_data_subpath }}
readOnly: true
- name: setup-proxy
mountPath: /usr/local/bin/dms-setup-proxy.sh
subPath: dms-setup-proxy.sh
{% endif %}
{% if taskserv.probes is defined and taskserv.probes.readiness is defined %}
readinessProbe:
{% if taskserv.probes.readiness.type == "tcp" %}
tcpSocket:
port: {{ taskserv.probes.readiness.port | default(value=taskserv.port) }}
{% else %}
httpGet:
path: {{ taskserv.probes.readiness.path }}
port: {{ taskserv.probes.readiness.port | default(value=taskserv.port) }}
{% endif %}
initialDelaySeconds: {{ taskserv.probes.readiness.initial_delay }}
periodSeconds: {{ taskserv.probes.readiness.period }}
failureThreshold: {{ taskserv.probes.readiness.failure_threshold }}
{% else %}
readinessProbe:
httpGet:
path: /.panel/health
port: {{ taskserv.port }}
initialDelaySeconds: 5
periodSeconds: 10
{% endif %}
{% if taskserv.probes is defined and taskserv.probes.liveness is defined %}
livenessProbe:
{% if taskserv.probes.liveness.type == "tcp" %}
tcpSocket:
port: {{ taskserv.probes.liveness.port | default(value=taskserv.port) }}
{% else %}
httpGet:
path: {{ taskserv.probes.liveness.path }}
port: {{ taskserv.probes.liveness.port | default(value=taskserv.port) }}
{% endif %}
initialDelaySeconds: {{ taskserv.probes.liveness.initial_delay }}
periodSeconds: {{ taskserv.probes.liveness.period }}
failureThreshold: {{ taskserv.probes.liveness.failure_threshold }}
{% endif %}
{% if taskserv.resources_effective is defined %}
resources:
requests:
cpu: "{{ taskserv.resources_effective.cpu.request }}"
memory: "{{ taskserv.resources_effective.memory.request }}"
limits:
cpu: "{{ taskserv.resources_effective.cpu.limit }}"
memory: "{{ taskserv.resources_effective.memory.limit }}"
{% else %}
resources:
requests:
cpu: "50m"
memory: "64Mi"
limits:
cpu: "200m"
memory: "256Mi"
{% endif %}
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1000
capabilities:
drop: ["ALL"]
volumes:
- name: panel-config
configMap:
name: {{ taskserv.name }}-config
{% if taskserv.panel_enabled == "mail" %}
- name: mail-data
persistentVolumeClaim:
claimName: {{ taskserv.mail_pvc }}
readOnly: true
- name: setup-proxy
configMap:
name: {{ taskserv.name }}-setup-proxy
defaultMode: 0755
{% endif %}