about summary refs log tree commit diff
path: root/pkgs/by-name/kr/krr/package.nix
blob: f919f8c0d2262fcbbc2f86a995c3b2b3435a35e2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{ lib
, python3
, fetchFromGitHub
, testers
, krr
}:

python3.pkgs.buildPythonPackage rec {
  pname = "krr";
  version = "1.7.1";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "robusta-dev";
    repo = "krr";
    rev = "refs/tags/v${version}";
    hash = "sha256-Bc1Ql3z/UmOXE2RJYC5/sE4a3MFdE06I3HwKY+SdSlk=";
  };

  postPatch = ''
    substituteInPlace robusta_krr/__init__.py \
      --replace-warn '1.7.0-dev' '${version}'

    substituteInPlace pyproject.toml \
      --replace-warn '1.7.0-dev' '${version}' \
      --replace-fail 'aiostream = "^0.4.5"' 'aiostream = "*"' \
      --replace-fail 'kubernetes = "^26.1.0"' 'kubernetes = "*"' \
      --replace-fail 'pydantic = "1.10.7"' 'pydantic = "*"' \
      --replace-fail 'typer = { extras = ["all"], version = "^0.7.0" }' 'typer = { extras = ["all"], version = "*" }'
  '';

  propagatedBuildInputs = with python3.pkgs; [
    aiostream
    alive-progress
    kubernetes
    numpy
    poetry-core
    prometheus-api-client
    prometrix
    pydantic_1
    slack-sdk
    typer
  ] ++ typer.optional-dependencies.all;

  nativeCheckInputs = with python3.pkgs; [
    pytestCheckHook
  ];

  pythonImportsCheck = [
    "robusta_krr"
  ];

  passthru.tests.version = testers.testVersion {
    package = krr;
    command = "krr version";
  };

  meta = with lib; {
    description = "Prometheus-based Kubernetes resource recommendations";
    longDescription = ''
      Robusta KRR (Kubernetes Resource Recommender) is a CLI tool for optimizing
      resource allocation in Kubernetes clusters. It gathers Pod usage data from
      Prometheus and recommends requests and limits for CPU and memory. This
      reduces costs and improves performance.
    '';
    homepage = "https://github.com/robusta-dev/krr";
    changelog = "https://github.com/robusta-dev/krr/releases/tag/v${src.rev}";
    license = licenses.mit;
    maintainers = with lib.maintainers; [ azahi ];
    mainProgram = "krr";
  };
}