k8s-helper-cli 0.4.2__py3-none-any.whl → 0.4.3__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 +1 -1
- k8s_helper/cli.py +14 -0
- k8s_helper/core.py +51 -18
- {k8s_helper_cli-0.4.2.dist-info → k8s_helper_cli-0.4.3.dist-info}/METADATA +1 -1
- k8s_helper_cli-0.4.3.dist-info/RECORD +11 -0
- k8s_helper_cli-0.4.2.dist-info/RECORD +0 -11
- {k8s_helper_cli-0.4.2.dist-info → k8s_helper_cli-0.4.3.dist-info}/WHEEL +0 -0
- {k8s_helper_cli-0.4.2.dist-info → k8s_helper_cli-0.4.3.dist-info}/entry_points.txt +0 -0
- {k8s_helper_cli-0.4.2.dist-info → k8s_helper_cli-0.4.3.dist-info}/licenses/LICENSE +0 -0
- {k8s_helper_cli-0.4.2.dist-info → k8s_helper_cli-0.4.3.dist-info}/top_level.txt +0 -0
k8s_helper/__init__.py
CHANGED
k8s_helper/cli.py
CHANGED
@@ -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
|
|
k8s_helper/core.py
CHANGED
@@ -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['
|
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
|
-
|
2151
|
-
|
2152
|
-
|
2153
|
-
|
2154
|
-
|
2155
|
-
|
2156
|
-
|
2157
|
-
|
2158
|
-
|
2159
|
-
|
2160
|
-
|
2161
|
-
|
2162
|
-
|
2163
|
-
|
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:
|
@@ -0,0 +1,11 @@
|
|
1
|
+
k8s_helper/__init__.py,sha256=8xOzKrONciTYSjLyhDKR4cQs5wVVtW0UZll7TnsTpqQ,2666
|
2
|
+
k8s_helper/cli.py,sha256=g0hzBHaROOT0gbKN5xu5GeC-aqbIyXpl3U-xx7vNWEU,80259
|
3
|
+
k8s_helper/config.py,sha256=P7YdfyvCHprrNs2J9DRb3RrClylfTTh5hfTtDzLug0A,6867
|
4
|
+
k8s_helper/core.py,sha256=R0_EDqVGFWQCpu5YuWC4abLLWIqjFtpn6KHgGD_Wues,112490
|
5
|
+
k8s_helper/utils.py,sha256=wYgTd5ktyuI-EiVcfW7FrxA7MzXY5odrEKQgmMVdueY,9496
|
6
|
+
k8s_helper_cli-0.4.3.dist-info/licenses/LICENSE,sha256=tXPvVl3gLVc6e0qCEoLH9KjeA7z4JVL78UybpvGtBCw,1096
|
7
|
+
k8s_helper_cli-0.4.3.dist-info/METADATA,sha256=-uygNSjY9k0yhuw6KPwft5Uu-77b0GBGCPRURlt4PEM,30789
|
8
|
+
k8s_helper_cli-0.4.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
9
|
+
k8s_helper_cli-0.4.3.dist-info/entry_points.txt,sha256=IoCMWUZ6mn90LwzQzEy5YkWOwvogDdZ6ycqUWAzCFTQ,50
|
10
|
+
k8s_helper_cli-0.4.3.dist-info/top_level.txt,sha256=x9A1jflyer-z2cFnkqk5B42juoH2q0fy5hkT9upsTG8,11
|
11
|
+
k8s_helper_cli-0.4.3.dist-info/RECORD,,
|
@@ -1,11 +0,0 @@
|
|
1
|
-
k8s_helper/__init__.py,sha256=YuM-ES4NKCK-M1VusIhUSIsO8vigHDWGPyAS6bvShgw,2666
|
2
|
-
k8s_helper/cli.py,sha256=ngXnZ-6EaTm9hCViLPOLZya4HtFDsqpPbLYnOBEfQmA,79400
|
3
|
-
k8s_helper/config.py,sha256=P7YdfyvCHprrNs2J9DRb3RrClylfTTh5hfTtDzLug0A,6867
|
4
|
-
k8s_helper/core.py,sha256=HCsDx8xApBvgDooR3XqaW2ZeIzQU35oGm6rfjTBzYVc,110654
|
5
|
-
k8s_helper/utils.py,sha256=wYgTd5ktyuI-EiVcfW7FrxA7MzXY5odrEKQgmMVdueY,9496
|
6
|
-
k8s_helper_cli-0.4.2.dist-info/licenses/LICENSE,sha256=tXPvVl3gLVc6e0qCEoLH9KjeA7z4JVL78UybpvGtBCw,1096
|
7
|
-
k8s_helper_cli-0.4.2.dist-info/METADATA,sha256=p6tE1EFVcCIGx5vwv-L-EDB-K5VRbOtAXcc5z2K5dXM,30789
|
8
|
-
k8s_helper_cli-0.4.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
9
|
-
k8s_helper_cli-0.4.2.dist-info/entry_points.txt,sha256=IoCMWUZ6mn90LwzQzEy5YkWOwvogDdZ6ycqUWAzCFTQ,50
|
10
|
-
k8s_helper_cli-0.4.2.dist-info/top_level.txt,sha256=x9A1jflyer-z2cFnkqk5B42juoH2q0fy5hkT9upsTG8,11
|
11
|
-
k8s_helper_cli-0.4.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|