k8s-deploy-helper 1.0.0 β†’ 1.3.0

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.
package/README.md CHANGED
@@ -1,176 +1,154 @@
1
- # k8s-deploy-helper
1
+ ### k8s-deploy-helper πŸš€
2
2
 
3
- A production-grade CLI tool that automates Docker image builds and Kubernetes deployments using a single command.
4
- Designed for real-world CI/CD pipelines and local developer workflows.
3
+ # k8s-deploy-helper is a simple and beginner-friendly CLI tool that helps you build Docker images and deploy applications to Kubernetes using a guided and automated workflow.
5
4
 
6
- ---
5
+ # It is designed to reduce the learning curve of Kubernetes while still supporting real-world DevOps practices.
7
6
 
8
- ## ✨ Overview
7
+ -----
9
8
 
10
- `k8s-deploy-helper` simplifies the process of:
11
- - Building Docker images
12
- - Pushing images to container registries
13
- - Generating Kubernetes manifests
14
- - Deploying applications to Kubernetes clusters
9
+ ### PROBLEM THIS TOOL SOLVES 🧩
15
10
 
16
- The tool is **configuration-driven**, **CI/CD-friendly**, and uses **native Docker and kubectl** instead of opaque SDK abstractions.
11
+ ## Deploying an application to Kubernetes usually involves many manual steps:
17
12
 
18
- ---
13
+ β€’ Creating and maintaining a Dockerfile
14
+ β€’ Writing Kubernetes YAML files (Deployment, Service, etc.)
15
+ β€’ Understanding kubectl commands
16
+ β€’ Managing Docker registry authentication
17
+ β€’ Debugging unclear or low-level runtime errors
19
18
 
20
- ## πŸš€ Features
19
+ # For beginners and even intermediate developers, this process can be confusing, time-consuming, and error-prone.
21
20
 
22
- - Docker image build automation
23
- - Registry push support (Docker Hub, ECR, GHCR, etc.)
24
- - Kubernetes Deployment & Service YAML generation
25
- - Automatic `kubectl apply`
26
- - Graceful handling of partial failures
27
- - Idempotent deployments
28
- - Works locally and in CI pipelines
21
+ # k8s-deploy-helper removes this complexity by automating these steps and guiding the user through a clear, predictable workflow.
29
22
 
30
- ---
23
+ -----
31
24
 
32
- ## πŸ“¦ Installation
25
+ ### WHAT THIS TOOL DOES βš™οΈ
33
26
 
34
- Install globally from npm:
35
- npm install -g k8s-deploy-helper
27
+ ## k8s-deploy-helper automates the full deployment process by:
36
28
 
37
- Verify installation:
38
- k8s-deploy --version
29
+ β€’ Automatically generating missing Docker and Kubernetes configuration files
30
+ β€’ Building Docker images for your application
31
+ β€’ Supporting local deployments without pushing images to Docker Hub
32
+ β€’ Generating Kubernetes Deployment and Service YAML files automatically
33
+ β€’ Applying Kubernetes resources using kubectl
34
+ β€’ Detecting missing setup early and displaying clear, actionable error messages
39
35
 
40
- πŸ›  Prerequisites
41
- Ensure the following are installed and configured:
36
+ You focus on building your application.
37
+ The tool handles the deployment.
42
38
 
43
- Node.js (v18+)
39
+ -----
44
40
 
45
- Docker (running)
41
+ ### REQUIREMENTS (BEGINNER FRIENDLY) πŸ› οΈ
46
42
 
47
- kubectl
43
+ # Minimum setup for local usage:
44
+ β€’ Docker Desktop installed
45
+ β€’ Kubernetes enabled inside Docker Desktop
48
46
 
49
- Kubernetes cluster:
47
+ # Docker Desktop already includes:
48
+ β€’ Docker
49
+ β€’ kubectl
50
+ β€’ A local Kubernetes cluster
50
51
 
51
- Docker Desktop Kubernetes
52
+ # To verify Kubernetes is running:
53
+ kubectl get nodes
52
54
 
53
- Minikube
55
+ -----
54
56
 
55
- EKS / GKE / AKS
57
+ ### INSTALLATION πŸ“¦
56
58
 
57
- Container registry access (Docker Hub, ECR, GHCR, etc.)
59
+ # Install the package globally using npm:
60
+ npm install -g k8s-deploy-helper
58
61
 
59
- πŸ“„ Configuration
60
- Create a k8s.config.json file in your project root.
62
+ # Verify the installation:
63
+ k8s-deploy --version
61
64
 
62
- Example configuration:
63
- json
64
- Copy code
65
- {
66
- "appName": "my-app",
67
- "namespace": "default",
65
+ -----
68
66
 
69
- "docker": {
70
- "image": "username/my-app",
71
- "tag": "latest",
72
- "context": ".",
73
- "dockerfile": "Dockerfile"
74
- },
67
+ ### HOW TO USE (STEP-BY-STEP) ▢️
75
68
 
76
- "kubernetes": {
77
- "replicas": 2,
78
- "containerPort": 3000,
79
- "servicePort": 80,
80
- "serviceType": "ClusterIP"
81
- },
69
+ ## STEP 1: INITIALIZE THE PROJECT ⭐
82
70
 
83
- "resources": {
84
- "limits": {
85
- "cpu": "500m",
86
- "memory": "512Mi"
87
- },
88
- "requests": {
89
- "cpu": "250m",
90
- "memory": "256Mi"
91
- }
92
- },
71
+ # If your project does not already have a Dockerfile or k8s.config.json, run:
72
+ k8s-deploy init
93
73
 
94
- "env": {
95
- "NODE_ENV": "production"
96
- }
97
- }
98
- ▢️ Usage
99
- Deploy your application using a single command:
74
+ # This command will:
75
+ β€’ Create a basic Dockerfile
76
+ β€’ Create a k8s.config.json configuration file
77
+ β€’ Prepare your project for Kubernetes deployment
100
78
 
101
- bash
102
- Copy code
103
- k8s-deploy deploy
104
- What this command does:
105
- Builds the Docker image
79
+ # You can modify these files later to match your application needs.
106
80
 
107
- Pushes the image to the registry (if authorized)
81
+ ## STEP 2: DEPLOY LOCALLY (RECOMMENDED FOR BEGINNERS) πŸ§ͺ
108
82
 
109
- Generates Kubernetes manifests:
83
+ ## For first-time users, deploy without using Docker Hub or any container registry:
84
+ k8s-deploy deploy --local
110
85
 
111
- deployment.yaml
112
-
113
- service.yaml
114
-
115
- Applies the resources to the Kubernetes cluster using kubectl
86
+ ## What happens during local deployment:
87
+ β€’ The Docker image is built locally
88
+ β€’ Image push to a registry is skipped
89
+ β€’ Kubernetes uses the local image
90
+ β€’ The application is deployed to the local Kubernetes cluster
116
91
 
117
- If the image push fails, deployment continues using the existing image tag.
92
+ # No Docker Hub account or login is required.
118
93
 
119
- πŸ“ Generated Files
120
- text
121
- Copy code
122
- deployment.yaml
123
- service.yaml
124
- These files can be reviewed, committed to version control, or applied independently.
94
+ ## STEP 3: STANDARD DEPLOYMENT (OPTIONAL) 🌐
125
95
 
126
- πŸ” Authentication
127
- This tool does not manage credentials.
96
+ # Once you are comfortable and logged into a container registry, run:
97
+ k8s-deploy deploy
128
98
 
129
- Authentication must be handled externally:
99
+ ### This will:
100
+ β€’ Build the Docker image
101
+ β€’ Push the image to the configured registry
102
+ β€’ Deploy the application to Kubernetes
130
103
 
131
- docker login for container registries
104
+ -----
132
105
 
133
- kubectl config for Kubernetes clusters
106
+ ### FILES CREATED BY THE TOOL πŸ“
134
107
 
135
- This mirrors real-world CI/CD environments and avoids secret leakage.
108
+ # After running the commands, the following files will exist in your project:
136
109
 
137
- 🧠 Design Principles
138
- Explicit over implicit β€” no hidden magic
110
+ Dockerfile
111
+ k8s.config.json
112
+ deployment.yaml
113
+ service.yaml
139
114
 
140
- Fail loud, fail early β€” CI-friendly logs
115
+ # These files can be:
116
+ β€’ Reviewed
117
+ β€’ Modified
118
+ β€’ Committed to Git
119
+ β€’ Used independently if needed
141
120
 
142
- Idempotent operations β€” safe re-runs
121
+ -----
143
122
 
144
- No vendor lock-in β€” relies on standard tools
123
+ ### WHAT HAPPENS INTERNALLY πŸ”
145
124
 
146
- πŸ§ͺ Example Output
147
- text
148
- Copy code
149
- 🐳 Building Docker image: username/my-app:latest
150
- πŸ“€ Pushing Docker image: username/my-app:latest
151
- ⚠️ Image push failed β€” continuing deployment
125
+ # When you run the deploy command, the tool performs the following steps:
152
126
 
153
- ☸️ Deploying to Kubernetes namespace: default
154
- πŸ“¦ Applying deployment.yaml
155
- deployment.apps/my-app created
156
- πŸ“¦ Applying service.yaml
157
- service/my-app created
158
- βœ… Kubernetes resources applied successfully
159
- πŸ—Ί Roadmap
160
- Planned enhancements:
127
+ β€’ Checks for required files
128
+ β€’ Verifies Docker and Kubernetes availability
129
+ β€’ Builds the Docker image
130
+ β€’ Generates Kubernetes YAML files
131
+ β€’ Applies resources using kubectl
161
132
 
162
- --dry-run mode
133
+ # Each step is logged clearly so you can understand what is happening.
163
134
 
164
- Rollback support
135
+ -----
165
136
 
166
- Helm chart generation
137
+ ### WHY THIS TOOL IS VALUABLE ⭐
167
138
 
168
- Deployment health checks
139
+ ## Without this tool:
140
+ β€’ You manually write Kubernetes YAML
141
+ β€’ You manage Docker commands yourself
142
+ β€’ You deal with registry authentication issues
143
+ β€’ Kubernetes feels complex and fragile
169
144
 
170
- GitHub Actions CI template
145
+ ## With this tool:
146
+ β€’ One-command deployment
147
+ β€’ Beginner-safe defaults
148
+ β€’ Hands-on Kubernetes experience
149
+ β€’ Production-ready deployment workflow
171
150
 
172
- πŸ“œ License
173
- MIT License
151
+ -----
174
152
 
175
- πŸ‘¨β€πŸ’» Author
176
- Lokesh Shimpi
153
+ ### AUTHOR πŸ‘¨β€πŸ’»
154
+ Lokesh Shimpi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "k8s-deploy-helper",
3
- "version": "1.0.0",
3
+ "version": "1.3.0",
4
4
  "description": "CLI tool to build, push and deploy applications to Kubernetes",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,33 @@
1
+ import { execa } from 'execa';
2
+
3
+ export async function checkEnvironment() {
4
+ // 1. Check Docker availability
5
+ try {
6
+ await execa('docker', ['info'], { stdio: 'ignore' });
7
+ } catch {
8
+ throw new Error(
9
+ 'Docker is not running.\n' +
10
+ 'πŸ‘‰ Please start Docker Desktop and try again.'
11
+ );
12
+ }
13
+
14
+ // 2. Check kubectl availability
15
+ try {
16
+ await execa('kubectl', ['version', '--client'], { stdio: 'ignore' });
17
+ } catch {
18
+ throw new Error(
19
+ 'kubectl is not available.\n' +
20
+ 'πŸ‘‰ Enable Kubernetes in Docker Desktop or install kubectl.'
21
+ );
22
+ }
23
+
24
+ // 3. Check Kubernetes cluster connectivity
25
+ try {
26
+ await execa('kubectl', ['cluster-info'], { stdio: 'ignore' });
27
+ } catch {
28
+ throw new Error(
29
+ 'Kubernetes cluster is not reachable.\n' +
30
+ 'πŸ‘‰ Enable Kubernetes in Docker Desktop and wait until it is ready.'
31
+ );
32
+ }
33
+ }