# Copyright Broadcom, Inc. All Rights Reserved.
# SPDX-License-Identifier: APACHE-2.0

http:
  http://milvus-data-coordinator:{{ .Vars.dataCoord.service.ports.metrics }}/metrics:
    status: 200
    body:
      - milvus_num_node
  http://milvus-query-coordinator:{{ .Vars.queryCoord.service.ports.metrics }}/metrics:
    status: 200
    body:
      - milvus_num_node
  http://milvus-root-coordinator:{{ .Vars.rootCoord.service.ports.metrics }}/metrics:
    status: 200
    body:
      - milvus_num_node
  http://milvus-data-node:{{ .Vars.dataNode.service.ports.metrics }}/metrics:
    status: 200
    body:
      - milvus_num_node
  http://milvus-query-node:{{ .Vars.queryNode.service.ports.metrics }}/metrics:
    status: 200
    body:
      - milvus_num_node
  http://milvus-index-node:{{ .Vars.indexNode.service.ports.metrics }}/metrics:
    status: 200
    body:
      - milvus_num_node
  http://milvus-proxy:{{ .Vars.proxy.service.ports.metrics }}/metrics:
    status: 200
    body:
      - milvus_num_node
  http://milvus-attu:{{ .Vars.attu.service.ports.http }}:
    status: 200
  http://127.0.0.1:{{ .Vars.proxy.containerPorts.metrics }}/metrics:
    status: 200
    body:
      - milvus_num_node
addr:
  tcp://milvus-data-coordinator:{{ .Vars.dataCoord.service.ports.grpc }}:
    reachable: true
    timeout: 500
  tcp://milvus-query-coordinator:{{ .Vars.queryCoord.service.ports.grpc }}:
    reachable: true
    timeout: 500
  tcp://milvus-root-coordinator:{{ .Vars.rootCoord.service.ports.grpc }}:
    reachable: true
    timeout: 500
  tcp://milvus-data-node:{{ .Vars.dataNode.service.ports.grpc }}:
    reachable: true
    timeout: 500
  tcp://milvus-query-node:{{ .Vars.queryNode.service.ports.grpc }}:
    reachable: true
    timeout: 500
  tcp://milvus-index-node:{{ .Vars.indexNode.service.ports.grpc }}:
    reachable: true
    timeout: 500
  tcp://milvus-proxy:{{ .Vars.proxy.service.ports.grpc }}:
    reachable: true
    timeout: 500
  tcp://127.0.0.1:{{ .Vars.proxy.containerPorts.grpc }}:
    reachable: true
    timeout: 500
file:
  /opt/bitnami/milvus/configs/milvus.yaml:
    exists: true
    filetype: file
    mode: '0644'
    contents:
      - /timeTickInterval.*{{ .Vars.proxy.extraConfig.proxy.timeTickInterval }}/
      - /gracefulStopTimeout.*{{ .Vars.milvus.extraConfig.common.gracefulStopTimeout }}/
command:
  {{- $uid := .Vars.proxy.containerSecurityContext.runAsUser }}
  {{- $gid := .Vars.proxy.podSecurityContext.fsGroup }}
  check-user-info:
    # The UID and GID should always be either the one specified as vars (always a bigger number that the def<ault)
    # or the one randomly defined by openshift (larger values). Otherwise, the chart is still using the default value.
    exec: if [ $(id -u) -lt {{ $uid }} ] || [ $(id -G | awk '{print $2}') -lt {{ $gid }} ]; then exit 1; fi
    exit-status: 0
  {{- if .Vars.proxy.containerSecurityContext.enabled }}
  check-no-capabilities:
    exec: cat /proc/1/status
    exit-status: 0
    stdout:
    - "CapInh:	0000000000000000"
    - "CapPrm:	0000000000000000"
    - "CapEff:	0000000000000000"
    - "CapBnd:	0000000000000000"
    - "CapAmb:	0000000000000000"
  {{- end }}
  {{ if .Vars.proxy.automountServiceAccountToken }}
  check-sa:
    exec: cat /var/run/secrets/kubernetes.io/serviceaccount/token | cut -d '.' -f 2 | xargs -I '{}' echo '{}====' | fold -w 4 | sed '$ d' | tr -d '\n' | base64 -d
    exit-status: 0
    stdout:
    - /serviceaccount.*name.*milvus-proxy/
  {{ end }}
