apiVersion: v1
data:
  config.yml: |
    logging:
      level: ${LOGGING_LEVEL:info}

    metrics:
      scope:
        prefix: "chronocollector"
      prometheus:
        handlerPath: /metrics
      sanitization: prometheus
      samplingRate: 1.0
      extended: none

    listenAddress: "${LISTEN_ADDRESS:0.0.0.0:3030}"

    labels:
      defaults:
        tenant_k8s_cluster: ${KUBERNETES_CLUSTER_NAME:""}

    backend:
      type: ${BACKEND_TYPE:gateway}
      gateway:
        address: ${GATEWAY_ADDRESS:""}
        insecure: ${GATEWAY_INSECURE:false}
        cert: ${GATEWAY_CERT:""}
        certSkipVerify: ${GATEWAY_CERT_SKIP_VERIFY:false}

    discovery:
      prometheus:
        enabled: true
        scrape_configs:
          - job_name: "<your-app-name-here>"
            scrape_interval: 10s
            scrape_timeout: 10s
            static_configs:
              - targets: ["localhost:<your-metrics-port-here>"]

    scrape:
      enableStalenessMarker: false
      defaults:
        scrapeInterval: 10s
        scrapeTimeout: 10s
        relabels:
          - action: replace
            regex: (.*)
            replacement: $1
            sourceLabels:
              - __meta_kubernetes_namespace
            targetLabel: tenant_k8s_namespace
          - action: replace
            regex: (.+)
            replacement: ${HOSTNAME:"unknown"}
            sourceLabels:
              - instance
            targetLabel: instance
kind: ConfigMap
metadata:
  labels:
    app: chronocollector
  name: chronocollector-config
  namespace: default
---
apiVersion: v1
data:
  address: <add-base64-encoded-token-here>
  api-token: <add-base64-encoded-token-here>
kind: Secret
metadata:
  labels:
    app: chronocollector
  name: chronosphere-secret
  namespace: default
type: Opaque
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: chronocollector
  name: <your-app-name-here>
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: chronocollector
  template:
    metadata:
      annotations:
        prometheus.io/port: "3030"
        prometheus.io/scrape: "true"
      labels:
        app: chronocollector
    spec:
      containers:
      - env:
        - name: LISTEN_ADDRESS
          value: 0.0.0.0:3030
        - name: LOGGING_LEVEL
          value: info
        - name: API_TOKEN
          valueFrom:
            secretKeyRef:
              key: token
              name: chronosphere-secret
        - name: GATEWAY_ADDRESS
          valueFrom:
            secretKeyRef:
              key: address
              name: chronosphere-secret
        - name: KUBERNETES_NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        - name: KUBERNETES_CLUSTER_NAME
          value: default
        image: gcr.io/chronosphereio/chronocollector:v0.102.0
        imagePullPolicy: IfNotPresent
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /health
            port: http
          initialDelaySeconds: 5
          periodSeconds: 30
          successThreshold: 1
          timeoutSeconds: 5
        name: chronocollector-sidecar
        ports:
        - containerPort: 3030
          name: http
        readinessProbe:
          failureThreshold: 5
          httpGet:
            path: /ready
            port: http
          initialDelaySeconds: 5
          periodSeconds: 5
          successThreshold: 1
          timeoutSeconds: 3
        resources:
          limits:
            cpu: 1000m
            memory: 512Mi
          requests:
            cpu: 1000m
            memory: 512Mi
        volumeMounts:
        - mountPath: /etc/chronocollector
          name: chronocollector-config
      terminationGracePeriodSeconds: 5
      tolerations:
      - operator: Exists
      volumes:
      - configMap:
          name: chronocollector-config
        name: chronocollector-config
