k8s-helper-cli 0.4.2__tar.gz → 0.4.3__tar.gz

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.
Files changed (18) hide show
  1. {k8s_helper_cli-0.4.2/src/k8s_helper_cli.egg-info → k8s_helper_cli-0.4.3}/PKG-INFO +1 -1
  2. {k8s_helper_cli-0.4.2 → k8s_helper_cli-0.4.3}/pyproject.toml +1 -1
  3. {k8s_helper_cli-0.4.2 → k8s_helper_cli-0.4.3}/src/k8s_helper/__init__.py +1 -1
  4. {k8s_helper_cli-0.4.2 → k8s_helper_cli-0.4.3}/src/k8s_helper/cli.py +14 -0
  5. {k8s_helper_cli-0.4.2 → k8s_helper_cli-0.4.3}/src/k8s_helper/core.py +51 -18
  6. {k8s_helper_cli-0.4.2 → k8s_helper_cli-0.4.3/src/k8s_helper_cli.egg-info}/PKG-INFO +1 -1
  7. {k8s_helper_cli-0.4.2 → k8s_helper_cli-0.4.3}/LICENSE +0 -0
  8. {k8s_helper_cli-0.4.2 → k8s_helper_cli-0.4.3}/README.md +0 -0
  9. {k8s_helper_cli-0.4.2 → k8s_helper_cli-0.4.3}/setup.cfg +0 -0
  10. {k8s_helper_cli-0.4.2 → k8s_helper_cli-0.4.3}/src/k8s_helper/config.py +0 -0
  11. {k8s_helper_cli-0.4.2 → k8s_helper_cli-0.4.3}/src/k8s_helper/utils.py +0 -0
  12. {k8s_helper_cli-0.4.2 → k8s_helper_cli-0.4.3}/src/k8s_helper_cli.egg-info/SOURCES.txt +0 -0
  13. {k8s_helper_cli-0.4.2 → k8s_helper_cli-0.4.3}/src/k8s_helper_cli.egg-info/dependency_links.txt +0 -0
  14. {k8s_helper_cli-0.4.2 → k8s_helper_cli-0.4.3}/src/k8s_helper_cli.egg-info/entry_points.txt +0 -0
  15. {k8s_helper_cli-0.4.2 → k8s_helper_cli-0.4.3}/src/k8s_helper_cli.egg-info/requires.txt +0 -0
  16. {k8s_helper_cli-0.4.2 → k8s_helper_cli-0.4.3}/src/k8s_helper_cli.egg-info/top_level.txt +0 -0
  17. {k8s_helper_cli-0.4.2 → k8s_helper_cli-0.4.3}/tests/test_core.py +0 -0
  18. {k8s_helper_cli-0.4.2 → k8s_helper_cli-0.4.3}/tests/test_integration.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: k8s-helper-cli
3
- Version: 0.4.2
3
+ Version: 0.4.3
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "k8s-helper-cli"
3
- version = "0.4.2"
3
+ version = "0.4.3"
4
4
  description = "A simplified Python wrapper for common Kubernetes operations"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -20,7 +20,7 @@ from .utils import (
20
20
  create_service_manifest
21
21
  )
22
22
 
23
- __version__ = "0.4.2"
23
+ __version__ = "0.4.3"
24
24
  __author__ = "Harshit Chatterjee"
25
25
  __email__ = "harshitchatterjee50@gmail.com"
26
26
 
@@ -1400,6 +1400,14 @@ def setup_monitoring(
1400
1400
  if result['success']:
1401
1401
  console.print("✅ Monitoring stack deployed successfully!")
1402
1402
 
1403
+ # Show warning if Grafana configuration failed
1404
+ if result.get('warning'):
1405
+ console.print(f"⚠️ {result['warning']}")
1406
+ console.print("💡 You can manually configure Grafana by:")
1407
+ console.print(" 1. Accessing Grafana with admin/admin123")
1408
+ console.print(" 2. Adding Prometheus as a data source")
1409
+ console.print(f" 3. Use URL: http://prometheus-service.{result['namespace']}.svc.cluster.local:9090")
1410
+
1403
1411
  # Show deployment summary
1404
1412
  console.print(f"\n📋 Deployment Summary:")
1405
1413
  console.print(f"📍 Namespace: {result['namespace']}")
@@ -1412,6 +1420,12 @@ def setup_monitoring(
1412
1420
  if result['grafana']['deployed']:
1413
1421
  console.print("✅ Grafana: Deployed")
1414
1422
  console.print(f"🔑 Admin credentials: {result['grafana']['admin_user']}/{result['grafana']['admin_password']}")
1423
+
1424
+ # Show Grafana configuration status
1425
+ if result.get('grafana_configured', True):
1426
+ console.print("✅ Grafana: Automatically configured with Prometheus")
1427
+ else:
1428
+ console.print("⚠️ Grafana: Manual configuration required")
1415
1429
  else:
1416
1430
  console.print("❌ Grafana: Failed to deploy")
1417
1431
 
@@ -1724,8 +1724,11 @@ class K8sClient:
1724
1724
  # Configure Grafana data source and dashboard
1725
1725
  if self._configure_grafana(namespace, import_dashboard):
1726
1726
  result['success'] = True
1727
+ result['grafana_configured'] = True
1727
1728
  else:
1728
- result['error'] = "Failed to configure Grafana"
1729
+ result['success'] = True # Still successful even if config fails
1730
+ result['grafana_configured'] = False
1731
+ result['warning'] = "Grafana deployed but automatic configuration failed"
1729
1732
  else:
1730
1733
  result['error'] = "Monitoring deployments failed to become ready"
1731
1734
  else:
@@ -2124,9 +2127,6 @@ scrape_configs:
2124
2127
  def _configure_grafana(self, namespace: str, import_dashboard: bool = True) -> bool:
2125
2128
  """Configure Grafana with Prometheus data source and dashboard"""
2126
2129
  try:
2127
- # Wait a bit for Grafana to fully start
2128
- time.sleep(10)
2129
-
2130
2130
  import requests
2131
2131
  import json
2132
2132
 
@@ -2138,6 +2138,32 @@ scrape_configs:
2138
2138
 
2139
2139
  print(f"🔧 Configuring Grafana at {grafana_url}")
2140
2140
 
2141
+ # Wait for Grafana to be accessible with retry logic
2142
+ max_retries = 12 # 2 minutes total (12 * 10 seconds)
2143
+ retry_count = 0
2144
+ auth = ('admin', 'admin123')
2145
+
2146
+ while retry_count < max_retries:
2147
+ try:
2148
+ # Test connection to Grafana
2149
+ health_response = requests.get(
2150
+ f"{grafana_url}/api/health",
2151
+ auth=auth,
2152
+ timeout=10
2153
+ )
2154
+ if health_response.status_code == 200:
2155
+ print("✅ Grafana is accessible")
2156
+ break
2157
+ except Exception as e:
2158
+ retry_count += 1
2159
+ if retry_count < max_retries:
2160
+ print(f"⏳ Waiting for Grafana to be accessible... (attempt {retry_count}/{max_retries})")
2161
+ time.sleep(10)
2162
+ else:
2163
+ print(f"❌ Grafana not accessible after {max_retries} attempts")
2164
+ print("💡 You can manually add Prometheus as a data source in Grafana")
2165
+ return False
2166
+
2141
2167
  # Add Prometheus data source
2142
2168
  datasource_payload = {
2143
2169
  "name": "Prometheus",
@@ -2147,20 +2173,27 @@ scrape_configs:
2147
2173
  "isDefault": True
2148
2174
  }
2149
2175
 
2150
- auth = ('admin', 'admin123')
2151
-
2152
- # Add data source
2153
- response = requests.post(
2154
- f"{grafana_url}/api/datasources",
2155
- json=datasource_payload,
2156
- auth=auth,
2157
- timeout=30
2158
- )
2159
-
2160
- if response.status_code in [200, 409]: # Success or already exists
2161
- print("✅ Prometheus data source configured")
2162
- else:
2163
- print(f"⚠️ Warning: Could not add Prometheus data source: {response.text}")
2176
+ # Try to add data source with retry
2177
+ for attempt in range(3):
2178
+ try:
2179
+ response = requests.post(
2180
+ f"{grafana_url}/api/datasources",
2181
+ json=datasource_payload,
2182
+ auth=auth,
2183
+ timeout=30
2184
+ )
2185
+
2186
+ if response.status_code in [200, 409]: # Success or already exists
2187
+ print("✅ Prometheus data source configured")
2188
+ break
2189
+ else:
2190
+ print(f"⚠️ Attempt {attempt + 1}: Could not add Prometheus data source: {response.text}")
2191
+ if attempt < 2:
2192
+ time.sleep(5)
2193
+ except Exception as e:
2194
+ print(f"⚠️ Attempt {attempt + 1}: Error adding data source: {e}")
2195
+ if attempt < 2:
2196
+ time.sleep(5)
2164
2197
 
2165
2198
  # Import default dashboard if requested
2166
2199
  if import_dashboard:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: k8s-helper-cli
3
- Version: 0.4.2
3
+ Version: 0.4.3
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
File without changes
File without changes
File without changes