k8s-helper-cli 0.1.1__py3-none-any.whl → 0.2.0__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.
@@ -0,0 +1,11 @@
1
+ k8s_helper/__init__.py,sha256=Q2GcFYJIwXQ5EmkCG5Tm8NKEKU6e4pKvNsUD1PSZkxg,2666
2
+ k8s_helper/cli.py,sha256=s7O2sxkdrrpVyZcqL9tEQg4gYytkmBSzESqiflx-Xc4,18722
3
+ k8s_helper/config.py,sha256=P7YdfyvCHprrNs2J9DRb3RrClylfTTh5hfTtDzLug0A,6867
4
+ k8s_helper/core.py,sha256=gCQkJSEQ3_ectExB9h1rFvI56Egysg50eVgYtpfquH0,21066
5
+ k8s_helper/utils.py,sha256=wYgTd5ktyuI-EiVcfW7FrxA7MzXY5odrEKQgmMVdueY,9496
6
+ k8s_helper_cli-0.2.0.dist-info/licenses/LICENSE,sha256=tXPvVl3gLVc6e0qCEoLH9KjeA7z4JVL78UybpvGtBCw,1096
7
+ k8s_helper_cli-0.2.0.dist-info/METADATA,sha256=Q4WVmlwoAhp5IT1vgiOGOB-HHv1Xof3uwgpHQpapbUM,23379
8
+ k8s_helper_cli-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
+ k8s_helper_cli-0.2.0.dist-info/entry_points.txt,sha256=IoCMWUZ6mn90LwzQzEy5YkWOwvogDdZ6ycqUWAzCFTQ,50
10
+ k8s_helper_cli-0.2.0.dist-info/top_level.txt,sha256=x9A1jflyer-z2cFnkqk5B42juoH2q0fy5hkT9upsTG8,11
11
+ k8s_helper_cli-0.2.0.dist-info/RECORD,,
@@ -1,491 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: k8s-helper-cli
3
- Version: 0.1.1
4
- Summary: A simplified Python wrapper for common Kubernetes operations
5
- Author-email: Harshit Chatterjee <harshitchatterjee50@gmail.com>
6
- License-Expression: MIT
7
- Project-URL: Homepage, https://github.com/Harshit1o/k8s-helper
8
- Project-URL: Repository, https://github.com/Harshit1o/k8s-helper
9
- Project-URL: Bug Tracker, https://github.com/Harshit1o/k8s-helper/issues
10
- Requires-Python: >=3.8
11
- Description-Content-Type: text/markdown
12
- License-File: LICENSE
13
- Requires-Dist: kubernetes>=26.1.0
14
- Requires-Dist: typer>=0.9.0
15
- Requires-Dist: rich>=13.0.0
16
- Requires-Dist: pyyaml>=6.0
17
- Provides-Extra: dev
18
- Requires-Dist: pytest>=7.0.0; extra == "dev"
19
- Requires-Dist: pytest-mock>=3.10.0; extra == "dev"
20
- Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
21
- Requires-Dist: black>=22.0.0; extra == "dev"
22
- Requires-Dist: flake8>=4.0.0; extra == "dev"
23
- Requires-Dist: mypy>=0.991; extra == "dev"
24
- Dynamic: license-file
25
-
26
- # k8s-helper
27
-
28
- A simplified Python wrapper for common Kubernetes operations that makes it easy to manage pods, deployments, services, and more.
29
-
30
- ## Features
31
-
32
- - ✅ **Pod Management**: Create, delete, and list pods
33
- - ✅ **Deployment Management**: Create, delete, scale, and list deployments
34
- - ✅ **Service Management**: Create, delete, and list services
35
- - ✅ **Resource Monitoring**: Get logs, events, and resource descriptions
36
- - ✅ **Easy Configuration**: Simple configuration management
37
- - ✅ **Formatted Output**: Beautiful table, YAML, and JSON output formats
38
- - ✅ **Error Handling**: Comprehensive error handling with helpful messages
39
- - ✅ **Quick Functions**: Convenience functions for common tasks
40
-
41
- ## Installation
42
-
43
- ```bash
44
- pip install k8s-helper-cli
45
- ```
46
-
47
- ### Development Installation
48
-
49
- ```bash
50
- git clone https://github.com/Harshit1o/k8s-helper.git
51
- cd k8s-helper
52
- pip install -e .
53
- ```
54
-
55
- ## Prerequisites
56
-
57
- - Python 3.8+
58
- - kubectl configured with access to a Kubernetes cluster
59
- - Kubernetes cluster (local or remote)
60
-
61
- ## Quick Start
62
-
63
- ```python
64
- from k8s_helper import K8sClient
65
-
66
- # Initialize client with default namespace
67
- client = K8sClient()
68
-
69
- # Or specify a namespace
70
- client = K8sClient(namespace="my-namespace")
71
-
72
- # Create a deployment
73
- client.create_deployment(
74
- name="my-app",
75
- image="nginx:latest",
76
- replicas=3,
77
- container_port=80
78
- )
79
-
80
- # Create a service
81
- client.create_service(
82
- name="my-app-service",
83
- port=80,
84
- target_port=80,
85
- service_type="ClusterIP"
86
- )
87
-
88
- # Scale deployment
89
- client.scale_deployment("my-app", replicas=5)
90
-
91
- # Get logs
92
- logs = client.get_logs("my-app-pod-12345")
93
-
94
- # List resources
95
- pods = client.list_pods()
96
- deployments = client.list_deployments()
97
- services = client.list_services()
98
- ```
99
-
100
- ## Detailed Usage
101
-
102
- ### Pod Management
103
-
104
- ```python
105
- # Create a pod
106
- client.create_pod(
107
- name="my-pod",
108
- image="nginx:latest",
109
- container_port=80,
110
- env_vars={"ENV": "production", "DEBUG": "false"},
111
- labels={"app": "my-app", "version": "v1.0"}
112
- )
113
-
114
- # Delete a pod
115
- client.delete_pod("my-pod")
116
-
117
- # List all pods
118
- pods = client.list_pods()
119
- print(format_pod_list(pods))
120
-
121
- # Describe a pod
122
- pod_info = client.describe_pod("my-pod")
123
- ```
124
-
125
- ### Deployment Management
126
-
127
- ```python
128
- # Create a deployment with environment variables
129
- client.create_deployment(
130
- name="my-app",
131
- image="nginx:latest",
132
- replicas=3,
133
- container_port=80,
134
- env_vars={"ENV": "production"},
135
- labels={"app": "my-app", "tier": "frontend"}
136
- )
137
-
138
- # Scale deployment
139
- client.scale_deployment("my-app", replicas=5)
140
-
141
- # Delete deployment
142
- client.delete_deployment("my-app")
143
-
144
- # List deployments
145
- deployments = client.list_deployments()
146
- print(format_deployment_list(deployments))
147
-
148
- # Wait for deployment to be ready
149
- client.wait_for_deployment_ready("my-app", timeout=300)
150
- ```
151
-
152
- ### Service Management
153
-
154
- ```python
155
- # Create a ClusterIP service
156
- client.create_service(
157
- name="my-app-service",
158
- port=80,
159
- target_port=8080,
160
- service_type="ClusterIP"
161
- )
162
-
163
- # Create a LoadBalancer service
164
- client.create_service(
165
- name="my-app-lb",
166
- port=80,
167
- target_port=80,
168
- service_type="LoadBalancer",
169
- selector={"app": "my-app"}
170
- )
171
-
172
- # Delete service
173
- client.delete_service("my-app-service")
174
-
175
- # List services
176
- services = client.list_services()
177
- print(format_service_list(services))
178
- ```
179
-
180
- ### Logs and Events
181
-
182
- ```python
183
- # Get pod logs
184
- logs = client.get_logs("my-pod")
185
-
186
- # Get logs with tail
187
- logs = client.get_logs("my-pod", tail_lines=100)
188
-
189
- # Get logs from specific container
190
- logs = client.get_logs("my-pod", container_name="nginx")
191
-
192
- # Get events
193
- events = client.get_events()
194
- print(format_events(events))
195
-
196
- # Get events for specific resource
197
- events = client.get_events("my-pod")
198
- ```
199
-
200
- ### Resource Description
201
-
202
- ```python
203
- # Describe pod
204
- pod_info = client.describe_pod("my-pod")
205
- print(format_yaml_output(pod_info))
206
-
207
- # Describe deployment
208
- deployment_info = client.describe_deployment("my-app")
209
- print(format_json_output(deployment_info))
210
-
211
- # Describe service
212
- service_info = client.describe_service("my-service")
213
- ```
214
-
215
- ## Quick Functions
216
-
217
- For simple operations, use the convenience functions:
218
-
219
- ```python
220
- from k8s_helper import (
221
- quick_deployment,
222
- quick_service,
223
- quick_scale,
224
- quick_logs,
225
- quick_delete_deployment,
226
- quick_delete_service
227
- )
228
-
229
- # Quick deployment
230
- quick_deployment("my-app", "nginx:latest", replicas=3)
231
-
232
- # Quick service
233
- quick_service("my-service", port=80)
234
-
235
- # Quick scaling
236
- quick_scale("my-app", replicas=5)
237
-
238
- # Quick logs
239
- logs = quick_logs("my-pod")
240
-
241
- # Quick cleanup
242
- quick_delete_deployment("my-app")
243
- quick_delete_service("my-service")
244
- ```
245
-
246
- ## Configuration
247
-
248
- k8s-helper supports configuration through files and environment variables:
249
-
250
- ```python
251
- from k8s_helper import get_config
252
-
253
- # Get configuration
254
- config = get_config()
255
-
256
- # Set default namespace
257
- config.set_namespace("my-namespace")
258
-
259
- # Set output format
260
- config.set_output_format("yaml") # table, yaml, json
261
-
262
- # Set timeout
263
- config.set_timeout(600)
264
-
265
- # Save configuration
266
- config.save_config()
267
- ```
268
-
269
- ### Environment Variables
270
-
271
- - `K8S_HELPER_NAMESPACE`: Default namespace
272
- - `K8S_HELPER_OUTPUT_FORMAT`: Output format (table, yaml, json)
273
- - `K8S_HELPER_TIMEOUT`: Default timeout in seconds
274
- - `K8S_HELPER_VERBOSE`: Enable verbose output (true/false)
275
- - `KUBECONFIG`: Path to kubectl config file
276
-
277
- ## Output Formatting
278
-
279
- The library provides several output formats:
280
-
281
- ```python
282
- from k8s_helper.utils import (
283
- format_pod_list,
284
- format_deployment_list,
285
- format_service_list,
286
- format_events,
287
- format_yaml_output,
288
- format_json_output
289
- )
290
-
291
- # Format as table
292
- pods = client.list_pods()
293
- print(format_pod_list(pods))
294
-
295
- # Format as YAML
296
- pod_info = client.describe_pod("my-pod")
297
- print(format_yaml_output(pod_info))
298
-
299
- # Format as JSON
300
- deployment_info = client.describe_deployment("my-app")
301
- print(format_json_output(deployment_info))
302
- ```
303
-
304
- ## Error Handling
305
-
306
- The library provides comprehensive error handling:
307
-
308
- ```python
309
- # All operations return None/False on failure
310
- result = client.create_deployment("my-app", "nginx:latest")
311
- if result is None:
312
- print("Failed to create deployment")
313
-
314
- # Boolean operations return True/False
315
- success = client.delete_deployment("my-app")
316
- if not success:
317
- print("Failed to delete deployment")
318
-
319
- # Use try-except for custom error handling
320
- try:
321
- client.create_deployment("my-app", "nginx:latest")
322
- except Exception as e:
323
- print(f"Error: {e}")
324
- ```
325
-
326
- ## Advanced Usage
327
-
328
- ### Using YAML Manifests
329
-
330
- ```python
331
- from k8s_helper.utils import create_deployment_manifest, create_service_manifest
332
-
333
- # Create deployment manifest
334
- deployment_manifest = create_deployment_manifest(
335
- name="my-app",
336
- image="nginx:latest",
337
- replicas=3,
338
- port=80,
339
- env_vars={"ENV": "production"},
340
- labels={"app": "my-app"}
341
- )
342
-
343
- # Create service manifest
344
- service_manifest = create_service_manifest(
345
- name="my-app-service",
346
- port=80,
347
- target_port=80,
348
- service_type="ClusterIP",
349
- selector={"app": "my-app"}
350
- )
351
-
352
- print(format_yaml_output(deployment_manifest))
353
- ```
354
-
355
- ### Working with Multiple Namespaces
356
-
357
- ```python
358
- # Create clients for different namespaces
359
- prod_client = K8sClient(namespace="production")
360
- dev_client = K8sClient(namespace="development")
361
-
362
- # Deploy to production
363
- prod_client.create_deployment("my-app", "nginx:1.20", replicas=5)
364
-
365
- # Deploy to development
366
- dev_client.create_deployment("my-app", "nginx:latest", replicas=1)
367
- ```
368
-
369
- ### Monitoring and Health Checks
370
-
371
- ```python
372
- # Check namespace resources
373
- resources = client.get_namespace_resources()
374
- print(f"Pods: {resources['pods']}")
375
- print(f"Deployments: {resources['deployments']}")
376
- print(f"Services: {resources['services']}")
377
-
378
- # Wait for deployment to be ready
379
- if client.wait_for_deployment_ready("my-app", timeout=300):
380
- print("Deployment is ready!")
381
- else:
382
- print("Deployment failed to become ready")
383
- ```
384
-
385
- ## Examples
386
-
387
- ### Complete Application Deployment
388
-
389
- ```python
390
- from k8s_helper import K8sClient
391
-
392
- # Initialize client
393
- client = K8sClient(namespace="my-app")
394
-
395
- # Create deployment
396
- client.create_deployment(
397
- name="web-app",
398
- image="nginx:latest",
399
- replicas=3,
400
- container_port=80,
401
- env_vars={"ENV": "production"},
402
- labels={"app": "web-app", "tier": "frontend"}
403
- )
404
-
405
- # Create service
406
- client.create_service(
407
- name="web-app-service",
408
- port=80,
409
- target_port=80,
410
- service_type="LoadBalancer",
411
- selector={"app": "web-app"}
412
- )
413
-
414
- # Wait for deployment to be ready
415
- if client.wait_for_deployment_ready("web-app"):
416
- print("✅ Application deployed successfully!")
417
-
418
- # Show status
419
- print("\nDeployments:")
420
- print(format_deployment_list(client.list_deployments()))
421
-
422
- print("\nServices:")
423
- print(format_service_list(client.list_services()))
424
-
425
- print("\nPods:")
426
- print(format_pod_list(client.list_pods()))
427
- else:
428
- print("❌ Deployment failed!")
429
- ```
430
-
431
- ### Cleanup Script
432
-
433
- ```python
434
- from k8s_helper import K8sClient
435
-
436
- client = K8sClient(namespace="my-app")
437
-
438
- # Clean up resources
439
- resources_to_clean = [
440
- "web-app",
441
- "database",
442
- "cache"
443
- ]
444
-
445
- for resource in resources_to_clean:
446
- print(f"Cleaning up {resource}...")
447
- client.delete_deployment(resource)
448
- client.delete_service(f"{resource}-service")
449
-
450
- print("✅ Cleanup completed!")
451
- ```
452
-
453
- ## Contributing
454
-
455
- 1. Fork the repository
456
- 2. Create a feature branch
457
- 3. Make your changes
458
- 4. Add tests
459
- 5. Submit a pull request
460
-
461
- ## Testing
462
-
463
- ```bash
464
- # Install test dependencies
465
- pip install pytest pytest-mock
466
-
467
- # Run tests
468
- pytest tests/
469
-
470
- # Run tests with coverage
471
- pytest --cov=k8s_helper tests/
472
- ```
473
-
474
- ## License
475
-
476
- MIT License - see LICENSE file for details.
477
-
478
- ## Support
479
-
480
- - GitHub Issues: [Report bugs or request features](https://github.com/Harshit1o/k8s-helper/issues)
481
- - Documentation: [Full documentation](https://github.com/Harshit1o/k8s-helper)
482
-
483
- ## Changelog
484
-
485
- ### v0.1.0
486
- - Initial release
487
- - Basic pod, deployment, and service management
488
- - Configuration management
489
- - Comprehensive error handling
490
- - Multiple output formats
491
- - Quick convenience functions
@@ -1,11 +0,0 @@
1
- k8s_helper/__init__.py,sha256=QjPeV7P3FN7lYoU83Y786Mu2zwevuJeW8uL4kRiqhN8,2666
2
- k8s_helper/cli.py,sha256=HSa_JXe-LB7pUYJIBM3KxjsRLVFe1fSDD6uwG_NJn6A,18282
3
- k8s_helper/config.py,sha256=P7YdfyvCHprrNs2J9DRb3RrClylfTTh5hfTtDzLug0A,6867
4
- k8s_helper/core.py,sha256=gCQkJSEQ3_ectExB9h1rFvI56Egysg50eVgYtpfquH0,21066
5
- k8s_helper/utils.py,sha256=wYgTd5ktyuI-EiVcfW7FrxA7MzXY5odrEKQgmMVdueY,9496
6
- k8s_helper_cli-0.1.1.dist-info/licenses/LICENSE,sha256=tXPvVl3gLVc6e0qCEoLH9KjeA7z4JVL78UybpvGtBCw,1096
7
- k8s_helper_cli-0.1.1.dist-info/METADATA,sha256=RK4gmvLHq29b3xJuE_s0_AUPQYD08xsOINJEnytG2ME,11314
8
- k8s_helper_cli-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
- k8s_helper_cli-0.1.1.dist-info/entry_points.txt,sha256=IoCMWUZ6mn90LwzQzEy5YkWOwvogDdZ6ycqUWAzCFTQ,50
10
- k8s_helper_cli-0.1.1.dist-info/top_level.txt,sha256=x9A1jflyer-z2cFnkqk5B42juoH2q0fy5hkT9upsTG8,11
11
- k8s_helper_cli-0.1.1.dist-info/RECORD,,