k8s-helper-cli 0.5.3__py3-none-any.whl → 0.5.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
k8s_helper/__init__.py CHANGED
@@ -20,7 +20,7 @@ from .utils import (
20
20
  create_service_manifest
21
21
  )
22
22
 
23
- __version__ = "0.5.3"
23
+ __version__ = "0.5.5"
24
24
  __author__ = "Harshit Chatterjee"
25
25
  __email__ = "harshitchatterjee50@gmail.com"
26
26
 
k8s_helper/core.py CHANGED
@@ -3418,16 +3418,35 @@ scrape_configs:
3418
3418
  'service': {
3419
3419
  'type': grafana_service_type
3420
3420
  },
3421
+ 'env': {
3422
+ 'GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS': 'true',
3423
+ 'GF_INSTALL_PLUGINS': '', # Disable automatic plugin installation
3424
+ 'GF_SECURITY_DISABLE_INITIAL_ADMIN_CREATION': 'false'
3425
+ },
3421
3426
  'adminPassword': 'admin',
3427
+ 'plugins': [], # Disable problematic plugins
3428
+ 'sidecar': {
3429
+ 'datasources': {
3430
+ 'enabled': True,
3431
+ 'defaultDatasourceEnabled': True
3432
+ },
3433
+ 'dashboards': {
3434
+ 'enabled': True,
3435
+ 'searchNamespace': 'ALL'
3436
+ }
3437
+ },
3422
3438
  'datasources': {
3423
3439
  'datasources.yaml': {
3424
3440
  'apiVersion': 1,
3441
+ 'deleteDatasources': [],
3425
3442
  'datasources': [{
3426
3443
  'name': 'Prometheus',
3427
3444
  'type': 'prometheus',
3428
3445
  'url': 'http://kube-prometheus-stack-prometheus:9090',
3429
3446
  'access': 'proxy',
3430
- 'isDefault': True
3447
+ 'isDefault': True,
3448
+ 'uid': 'prometheus',
3449
+ 'editable': True
3431
3450
  }]
3432
3451
  }
3433
3452
  },
@@ -3471,6 +3490,16 @@ scrape_configs:
3471
3490
  'enabled': True,
3472
3491
  'prometheusSpec': {
3473
3492
  'retention': '30d',
3493
+ 'resources': {
3494
+ 'requests': {
3495
+ 'memory': '512Mi',
3496
+ 'cpu': '200m'
3497
+ },
3498
+ 'limits': {
3499
+ 'memory': '2Gi',
3500
+ 'cpu': '1000m'
3501
+ }
3502
+ },
3474
3503
  'storageSpec': {
3475
3504
  'volumeClaimTemplate': {
3476
3505
  'spec': {
@@ -3487,13 +3516,57 @@ scrape_configs:
3487
3516
  }
3488
3517
  },
3489
3518
  'alertmanager': {
3490
- 'enabled': True
3519
+ 'enabled': True,
3520
+ 'alertmanagerSpec': {
3521
+ 'resources': {
3522
+ 'requests': {
3523
+ 'memory': '128Mi',
3524
+ 'cpu': '100m'
3525
+ },
3526
+ 'limits': {
3527
+ 'memory': '512Mi',
3528
+ 'cpu': '500m'
3529
+ }
3530
+ }
3531
+ }
3491
3532
  },
3492
3533
  'nodeExporter': {
3493
- 'enabled': True
3534
+ 'enabled': True,
3535
+ 'resources': {
3536
+ 'requests': {
3537
+ 'memory': '30Mi',
3538
+ 'cpu': '100m'
3539
+ },
3540
+ 'limits': {
3541
+ 'memory': '100Mi',
3542
+ 'cpu': '200m'
3543
+ }
3544
+ }
3494
3545
  },
3495
3546
  'kubeStateMetrics': {
3496
- 'enabled': True
3547
+ 'enabled': True,
3548
+ 'resources': {
3549
+ 'requests': {
3550
+ 'memory': '64Mi',
3551
+ 'cpu': '50m'
3552
+ },
3553
+ 'limits': {
3554
+ 'memory': '256Mi',
3555
+ 'cpu': '200m'
3556
+ }
3557
+ }
3558
+ },
3559
+ 'prometheusOperator': {
3560
+ 'resources': {
3561
+ 'requests': {
3562
+ 'memory': '128Mi',
3563
+ 'cpu': '100m'
3564
+ },
3565
+ 'limits': {
3566
+ 'memory': '512Mi',
3567
+ 'cpu': '500m'
3568
+ }
3569
+ }
3497
3570
  },
3498
3571
  'defaultRules': {
3499
3572
  'create': True,
@@ -3536,14 +3609,19 @@ scrape_configs:
3536
3609
  'helm', 'install', 'kube-prometheus-stack',
3537
3610
  'prometheus-community/kube-prometheus-stack',
3538
3611
  '--namespace', namespace,
3539
- '--values', values_file
3612
+ '--values', values_file,
3613
+ '--create-namespace'
3540
3614
  ]
3541
3615
 
3542
3616
  if wait_for_ready:
3543
3617
  helm_cmd.append('--wait')
3544
- helm_cmd.extend(['--timeout', '10m'])
3618
+ helm_cmd.extend(['--timeout', '20m']) # Increased timeout
3619
+ print("⏳ This may take up to 20 minutes for first-time installation...")
3620
+ else:
3621
+ # Even without wait, add a reasonable timeout
3622
+ helm_cmd.extend(['--timeout', '5m'])
3545
3623
 
3546
- result = subprocess.run(helm_cmd, capture_output=True, text=True, check=True)
3624
+ result = subprocess.run(helm_cmd, capture_output=True, text=True, check=True, timeout=1200) # 20 min subprocess timeout
3547
3625
  print("✅ Helm chart installed successfully")
3548
3626
 
3549
3627
  # Wait a bit for pods to start
@@ -3574,9 +3652,72 @@ scrape_configs:
3574
3652
 
3575
3653
  except subprocess.CalledProcessError as e:
3576
3654
  error_msg = e.stderr if e.stderr else str(e)
3655
+
3656
+ # Check if it's a timeout error and offer fallback
3657
+ if 'context deadline exceeded' in error_msg or 'timeout' in error_msg.lower():
3658
+ print("⚠️ Installation timed out, but this doesn't necessarily mean failure.")
3659
+ print("🔍 Checking if components were actually deployed...")
3660
+
3661
+ # Check if the release was created even if it timed out
3662
+ try:
3663
+ check_result = subprocess.run([
3664
+ 'helm', 'status', 'kube-prometheus-stack', '--namespace', namespace
3665
+ ], capture_output=True, text=True, timeout=30)
3666
+
3667
+ if check_result.returncode == 0:
3668
+ print("✅ Helm release was created successfully despite timeout!")
3669
+ print("⏳ Components may still be starting up. Use 'k8s-helper monitoring-stack-status' to check progress.")
3670
+
3671
+ return {
3672
+ 'success': True,
3673
+ 'namespace': namespace,
3674
+ 'release_name': 'kube-prometheus-stack',
3675
+ 'prometheus': {'deployed': True},
3676
+ 'grafana': {
3677
+ 'deployed': True,
3678
+ 'admin_password': 'admin'
3679
+ },
3680
+ 'warning': 'Installation completed but timed out waiting for all pods to be ready. Components may still be starting.',
3681
+ 'suggestion': 'Use "k8s-helper monitoring-stack-status" to check current status.'
3682
+ }
3683
+ except:
3684
+ pass
3685
+
3686
+ return {
3687
+ 'success': False,
3688
+ 'error': f'Helm installation failed: {error_msg}',
3689
+ 'suggestion': 'Try running without --wait flag, or increase cluster resources.'
3690
+ }
3691
+ except subprocess.TimeoutExpired:
3692
+ print("⚠️ Installation timed out after 20 minutes.")
3693
+ print("🔍 Checking if components were deployed...")
3694
+
3695
+ # Check if anything was installed
3696
+ try:
3697
+ check_result = subprocess.run([
3698
+ 'helm', 'list', '--namespace', namespace
3699
+ ], capture_output=True, text=True, timeout=30)
3700
+
3701
+ if 'kube-prometheus-stack' in check_result.stdout:
3702
+ return {
3703
+ 'success': True,
3704
+ 'namespace': namespace,
3705
+ 'release_name': 'kube-prometheus-stack',
3706
+ 'prometheus': {'deployed': True},
3707
+ 'grafana': {
3708
+ 'deployed': True,
3709
+ 'admin_password': 'admin'
3710
+ },
3711
+ 'warning': 'Installation timed out but components may be deployed. Check status manually.',
3712
+ 'suggestion': 'Use "k8s-helper monitoring-stack-status" to verify deployment status.'
3713
+ }
3714
+ except:
3715
+ pass
3716
+
3577
3717
  return {
3578
3718
  'success': False,
3579
- 'error': f'Helm installation failed: {error_msg}'
3719
+ 'error': 'Installation timed out after 20 minutes',
3720
+ 'suggestion': 'Try running "k8s-helper setup-monitoring-stack" without --wait flag, or increase cluster resources.'
3580
3721
  }
3581
3722
  except Exception as e:
3582
3723
  return {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: k8s-helper-cli
3
- Version: 0.5.3
3
+ Version: 0.5.5
4
4
  Summary: A simplified Python wrapper for common Kubernetes operations
5
5
  Author-email: Harshit Chatterjee <harshitchatterjee50@gmail.com>
6
6
  License-Expression: MIT
@@ -0,0 +1,11 @@
1
+ k8s_helper/__init__.py,sha256=m2qQQFAXIhvJzVvMCKQo-oh6LfaB2OEL8xXBMPsVn9o,2666
2
+ k8s_helper/cli.py,sha256=3eP3J7srPIM0bm_G5RxdU_RvtDwJHLX2xBguF2EmXtk,95115
3
+ k8s_helper/config.py,sha256=P7YdfyvCHprrNs2J9DRb3RrClylfTTh5hfTtDzLug0A,6867
4
+ k8s_helper/core.py,sha256=l3QDHZBHN8IKdua8Ke65Djjw4MitdjSKypqsF5tJ4vA,167222
5
+ k8s_helper/utils.py,sha256=wYgTd5ktyuI-EiVcfW7FrxA7MzXY5odrEKQgmMVdueY,9496
6
+ k8s_helper_cli-0.5.5.dist-info/licenses/LICENSE,sha256=tXPvVl3gLVc6e0qCEoLH9KjeA7z4JVL78UybpvGtBCw,1096
7
+ k8s_helper_cli-0.5.5.dist-info/METADATA,sha256=6n1cmKDTgT6rbeglC-iPbEGLcDSZx4RUqiqqxBU3N9c,30789
8
+ k8s_helper_cli-0.5.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
+ k8s_helper_cli-0.5.5.dist-info/entry_points.txt,sha256=IoCMWUZ6mn90LwzQzEy5YkWOwvogDdZ6ycqUWAzCFTQ,50
10
+ k8s_helper_cli-0.5.5.dist-info/top_level.txt,sha256=x9A1jflyer-z2cFnkqk5B42juoH2q0fy5hkT9upsTG8,11
11
+ k8s_helper_cli-0.5.5.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- k8s_helper/__init__.py,sha256=3GNylm6r22pm4iWnjRfi_QLWcPBP9GL0NqZSTtFnLdc,2666
2
- k8s_helper/cli.py,sha256=3eP3J7srPIM0bm_G5RxdU_RvtDwJHLX2xBguF2EmXtk,95115
3
- k8s_helper/config.py,sha256=P7YdfyvCHprrNs2J9DRb3RrClylfTTh5hfTtDzLug0A,6867
4
- k8s_helper/core.py,sha256=0a4juGOteVZ3xwPqhq8vA3Dai63El1nCHo4D9tt7UMM,160443
5
- k8s_helper/utils.py,sha256=wYgTd5ktyuI-EiVcfW7FrxA7MzXY5odrEKQgmMVdueY,9496
6
- k8s_helper_cli-0.5.3.dist-info/licenses/LICENSE,sha256=tXPvVl3gLVc6e0qCEoLH9KjeA7z4JVL78UybpvGtBCw,1096
7
- k8s_helper_cli-0.5.3.dist-info/METADATA,sha256=K-zPIghmapn0gBpCr0AAxR3Uulbu1ww3z_xxTbNIKEo,30789
8
- k8s_helper_cli-0.5.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
- k8s_helper_cli-0.5.3.dist-info/entry_points.txt,sha256=IoCMWUZ6mn90LwzQzEy5YkWOwvogDdZ6ycqUWAzCFTQ,50
10
- k8s_helper_cli-0.5.3.dist-info/top_level.txt,sha256=x9A1jflyer-z2cFnkqk5B42juoH2q0fy5hkT9upsTG8,11
11
- k8s_helper_cli-0.5.3.dist-info/RECORD,,