statefulset-loki.yaml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. {{- if .Values.loki.enabled }}
  2. apiVersion: apps/v1
  3. kind: StatefulSet
  4. metadata:
  5. name: loki
  6. namespace: {{ .Release.Namespace }}
  7. labels:
  8. app: loki
  9. spec:
  10. serviceName: loki
  11. replicas: {{ .Values.loki.replicas }}
  12. selector:
  13. matchLabels:
  14. app: loki
  15. template:
  16. metadata:
  17. labels:
  18. app: loki
  19. spec:
  20. serviceAccountName: loki
  21. securityContext:
  22. fsGroup: 65534
  23. runAsNonRoot: false
  24. runAsUser: 0
  25. nodeSelector: {{ toYaml .Values.nodeSelector | nindent 8 }}
  26. tolerations: {{ toYaml .Values.tolerations | nindent 8 }}
  27. affinity: {{ toYaml .Values.affinity | nindent 8 }}
  28. initContainers:
  29. - name: init-loki-storage
  30. image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/alpine:3.18
  31. securityContext:
  32. runAsUser: 0
  33. command:
  34. - sh
  35. - -c
  36. - |
  37. set -e
  38. mkdir -p /loki/chunks
  39. mkdir -p /loki/boltdb-shipper-active
  40. mkdir -p /loki/boltdb-shipper-cache
  41. mkdir -p /loki/compactor
  42. mkdir -p /wal
  43. chmod -R 777 /loki
  44. chmod -R 777 /wal
  45. echo "Loki storage and WAL directories created successfully"
  46. volumeMounts:
  47. - name: loki-storage
  48. mountPath: /loki
  49. - name: wal-vol
  50. mountPath: /wal
  51. containers:
  52. - name: loki
  53. image: "{{ .Values.loki.image.repository }}:{{ .Values.loki.image.tag }}"
  54. imagePullPolicy: IfNotPresent
  55. args:
  56. - -config.file=/etc/loki/loki-config.yaml
  57. ports:
  58. - name: http
  59. containerPort: 3100
  60. protocol: TCP
  61. livenessProbe:
  62. httpGet:
  63. path: /ready
  64. port: http
  65. initialDelaySeconds: 45
  66. timeoutSeconds: 1
  67. periodSeconds: 10
  68. successThreshold: 1
  69. failureThreshold: 3
  70. readinessProbe:
  71. httpGet:
  72. path: /ready
  73. port: http
  74. initialDelaySeconds: 45
  75. timeoutSeconds: 1
  76. periodSeconds: 10
  77. successThreshold: 1
  78. failureThreshold: 3
  79. resources:
  80. limits:
  81. cpu: {{ .Values.loki.resources.limits.cpu }}
  82. memory: {{ .Values.loki.resources.limits.memory }}
  83. requests:
  84. cpu: {{ .Values.loki.resources.requests.cpu }}
  85. memory: {{ .Values.loki.resources.requests.memory }}
  86. volumeMounts:
  87. - name: loki-config
  88. mountPath: /etc/loki
  89. readOnly: true
  90. - name: loki-storage
  91. mountPath: /loki
  92. - name: wal-vol
  93. mountPath: /wal
  94. volumes:
  95. - name: loki-config
  96. configMap:
  97. name: loki-config
  98. - name: wal-vol
  99. emptyDir: {}
  100. volumeClaimTemplates:
  101. - metadata:
  102. name: loki-storage
  103. spec:
  104. accessModes:
  105. - ReadWriteOnce
  106. storageClassName: {{ .Values.loki.persistence.storageClassName }}
  107. resources:
  108. requests:
  109. storage: {{ .Values.loki.persistence.size }}
  110. {{- end }}