Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run logs compact in a separate deployment #852

Merged
merged 11 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ COPY --from=installer /root/.local/ /root/.local/
ENV NP_MONITORING_API_PORT=8080
EXPOSE $NP_MONITORING_API_PORT

CMD platform-monitoring
CMD [ "platform-monitoring-api" ]
180 changes: 176 additions & 4 deletions charts/platform-monitoring/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
{{- end -}}

{{- define "platformMonitoring.logs.storage.s3.keyPrefixFormat" -}}
kube.var.log.containers.{pod_name}_{namespace_name}_{container_name}
{{- end -}}

{{- define "platformMonitoring.logs.storage.keySecret" -}}
{{- if .Values.logs.persistence.keySecret -}}
{{ .Values.logs.persistence.keySecret }}
Expand All @@ -72,3 +68,179 @@ kube.var.log.containers.{pod_name}_{namespace_name}_{container_name}
{{- define "platformMonitoring.kubeAuthMountRoot" -}}
{{- printf "/var/run/secrets/kubernetes.io/serviceaccount" -}}
{{- end -}}

{{- define "platformMonitoring.env.common" -}}
- name: NP_MONITORING_CLUSTER_NAME
value: {{ .Values.platform.clusterName }}
- name: NP_MONITORING_CONTAINER_RUNTIME_PORT
value: {{ .Values.containerRuntime.port | quote }}
- name: NP_MONITORING_PLATFORM_API_TOKEN
{{- if .Values.platform.token }}
{{ toYaml .Values.platform.token | indent 2 }}
{{- end }}
- name: NP_MONITORING_PLATFORM_AUTH_TOKEN
{{- if .Values.platform.token }}
{{ toYaml .Values.platform.token | indent 2 }}
{{- end }}
- name: NP_MONITORING_PLATFORM_CONFIG_TOKEN
{{- if .Values.platform.token }}
{{ toYaml .Values.platform.token | indent 2 }}
{{- end }}
- name: NP_MONITORING_K8S_API_URL
value: https://kubernetes.default:443
- name: NP_MONITORING_K8S_AUTH_TYPE
value: token
- name: NP_MONITORING_K8S_CA_PATH
value: {{ include "platformMonitoring.kubeAuthMountRoot" . }}/ca.crt
- name: NP_MONITORING_K8S_TOKEN_PATH
value: {{ include "platformMonitoring.kubeAuthMountRoot" . }}/token
- name: NP_MONITORING_PLATFORM_API_URL
value: {{ .Values.platform.apiUrl | quote }}
- name: NP_MONITORING_PLATFORM_AUTH_URL
value: {{ .Values.platform.authUrl | quote }}
- name: NP_MONITORING_PLATFORM_CONFIG_URL
value: {{ .Values.platform.configUrl | quote }}
- name: NP_MONITORING_K8S_NS
value: {{ .Values.jobsNamespace }}
- name: NP_MONITORING_REGISTRY_URL
value: {{ .Values.platform.registryUrl | quote }}
- name: NP_MONITORING_K8S_KUBELET_PORT
value: {{ .Values.kubeletPort | quote }}
{{- if .Values.nvidiaDCGMPort }}
- name: NP_MONITORING_K8S_NVIDIA_DCGM_PORT
value: {{ .Values.nvidiaDCGMPort | quote }}
{{- end }}
{{- if .Values.cors.origins }}
- name: NP_CORS_ORIGINS
value: {{ join "," .Values.cors.origins | quote }}
{{- end }}
{{- if .Values.zipkin }}
- name: NP_ZIPKIN_URL
value: {{ .Values.zipkin.url }}
- name: NP_ZIPKIN_SAMPLE_RATE
value: {{ .Values.zipkin.sampleRate | default 0 | quote }}
{{- end }}
{{- if .Values.sentry }}
- name: NP_SENTRY_DSN
value: {{ .Values.sentry.dsn }}
- name: NP_SENTRY_CLUSTER_NAME
value: {{ .Values.sentry.clusterName }}
- name: NP_SENTRY_SAMPLE_RATE
value: {{ .Values.sentry.sampleRate | default 0 | quote }}
{{- end }}
{{- if .Values.nodeLabels.job }}
- name: NP_MONITORING_NODE_LABEL_JOB
value: {{ .Values.nodeLabels.job }}
{{- end }}
{{- if .Values.nodeLabels.nodePool }}
- name: NP_MONITORING_NODE_LABEL_NODE_POOL
value: {{ .Values.nodeLabels.nodePool }}
{{- end }}
- name: NP_MONITORING_LOGS_CLEANUP_INTERVAL_SEC
value: {{ .Values.logs.cleanup_interval_sec | quote }}
{{- end -}}

{{- define "platformMonitoring.env.s3" -}}
{{- $logsPersistence := .Values.logs.persistence -}}
{{- if eq $logsPersistence.type "aws" }}
- name: NP_MONITORING_LOGS_STORAGE_TYPE
value: s3
- name: NP_MONITORING_S3_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: {{ include "platformMonitoring.logs.storage.keySecret" . }}
key: access_key_id
- name: NP_MONITORING_S3_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: {{ include "platformMonitoring.logs.storage.keySecret" . }}
key: secret_access_key
{{- if $logsPersistence.aws.region }}
- name: NP_MONITORING_S3_REGION
value: {{ $logsPersistence.aws.region | quote }}
{{- end }}
{{- if $logsPersistence.aws.endpoint }}
- name: NP_MONITORING_S3_ENDPOINT_URL
value: {{ $logsPersistence.aws.endpoint | quote }}
{{- end }}
- name: NP_MONITORING_S3_JOB_LOGS_BUCKET_NAME
value: {{ $logsPersistence.aws.bucket | quote }}
{{- else if eq $logsPersistence.type "gcp" }}
- name: NP_MONITORING_LOGS_STORAGE_TYPE
value: s3
- name: NP_MONITORING_S3_REGION
value: {{ $logsPersistence.gcp.location | quote }}
- name: NP_MONITORING_S3_ACCESS_KEY_ID
value: minio_access_key
- name: NP_MONITORING_S3_SECRET_ACCESS_KEY
value: minio_secret_key
- name: NP_MONITORING_S3_ENDPOINT_URL
value: {{ include "platformMonitoring.minioGateway.endpoint" . }}
- name: NP_MONITORING_S3_JOB_LOGS_BUCKET_NAME
value: {{ $logsPersistence.gcp.bucket | quote }}
{{- else if eq $logsPersistence.type "azure" }}
- name: NP_MONITORING_LOGS_STORAGE_TYPE
value: s3
- name: NP_MONITORING_S3_REGION
value: minio
- name: NP_MONITORING_S3_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: {{ include "platformMonitoring.logs.storage.keySecret" . }}
key: account_name
- name: NP_MONITORING_S3_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: {{ include "platformMonitoring.logs.storage.keySecret" . }}
key: account_key
- name: NP_MONITORING_S3_ENDPOINT_URL
value: {{ include "platformMonitoring.minioGateway.endpoint" . }}
- name: NP_MONITORING_S3_JOB_LOGS_BUCKET_NAME
value: {{ $logsPersistence.azure.bucket | quote }}
{{- else if eq $logsPersistence.type "minio" }}
- name: NP_MONITORING_LOGS_STORAGE_TYPE
value: s3
- name: NP_MONITORING_S3_ENDPOINT_URL
value: {{ $logsPersistence.minio.url | quote }}
- name: NP_MONITORING_S3_REGION
value: {{ $logsPersistence.minio.region | quote }}
- name: NP_MONITORING_S3_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: {{ include "platformMonitoring.logs.storage.keySecret" . }}
key: access_key
- name: NP_MONITORING_S3_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: {{ include "platformMonitoring.logs.storage.keySecret" . }}
key: secret_key
- name: NP_MONITORING_S3_JOB_LOGS_BUCKET_NAME
value: {{ $logsPersistence.minio.bucket | quote }}
{{- end }}
{{- end -}}

{{- define "platformMonitoring.volumes.common" -}}
- name: kube-api-data
projected:
sources:
- serviceAccountToken:
expirationSeconds: 3600
path: token
- configMap:
name: kube-root-ca.crt
items:
- key: ca.crt
path: ca.crt
{{- end -}}

{{- define "platformMonitoring.volumeMounts.common" -}}
- mountPath: {{ include "platformMonitoring.kubeAuthMountRoot" . }}
name: kube-api-data
readOnly: true
{{- end -}}

{{- define "platformMonitoring.logs.compact.selectorLabels" -}}
app: {{ include "platformMonitoring.name" . }}
release: {{ .Release.Name | quote }}
service: platform-monitoring-logs-compact
{{- end -}}
Loading
Loading