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 +103 -125
- package/package.json +1 -1
- package/src/preflight/checkEnvironment.js +33 -0
package/README.md
CHANGED
|
@@ -1,176 +1,154 @@
|
|
|
1
|
-
|
|
1
|
+
### k8s-deploy-helper π
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
7
|
+
-----
|
|
9
8
|
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
|
|
19
|
+
# For beginners and even intermediate developers, this process can be confusing, time-consuming, and error-prone.
|
|
21
20
|
|
|
22
|
-
-
|
|
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
|
-
|
|
25
|
+
### WHAT THIS TOOL DOES βοΈ
|
|
33
26
|
|
|
34
|
-
|
|
35
|
-
npm install -g k8s-deploy-helper
|
|
27
|
+
## k8s-deploy-helper automates the full deployment process by:
|
|
36
28
|
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
41
|
-
|
|
36
|
+
You focus on building your application.
|
|
37
|
+
The tool handles the deployment.
|
|
42
38
|
|
|
43
|
-
|
|
39
|
+
-----
|
|
44
40
|
|
|
45
|
-
|
|
41
|
+
### REQUIREMENTS (BEGINNER FRIENDLY) π οΈ
|
|
46
42
|
|
|
47
|
-
|
|
43
|
+
# Minimum setup for local usage:
|
|
44
|
+
β’ Docker Desktop installed
|
|
45
|
+
β’ Kubernetes enabled inside Docker Desktop
|
|
48
46
|
|
|
49
|
-
|
|
47
|
+
# Docker Desktop already includes:
|
|
48
|
+
β’ Docker
|
|
49
|
+
β’ kubectl
|
|
50
|
+
β’ A local Kubernetes cluster
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
# To verify Kubernetes is running:
|
|
53
|
+
kubectl get nodes
|
|
52
54
|
|
|
53
|
-
|
|
55
|
+
-----
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
### INSTALLATION π¦
|
|
56
58
|
|
|
57
|
-
|
|
59
|
+
# Install the package globally using npm:
|
|
60
|
+
npm install -g k8s-deploy-helper
|
|
58
61
|
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
# Verify the installation:
|
|
63
|
+
k8s-deploy --version
|
|
61
64
|
|
|
62
|
-
|
|
63
|
-
json
|
|
64
|
-
Copy code
|
|
65
|
-
{
|
|
66
|
-
"appName": "my-app",
|
|
67
|
-
"namespace": "default",
|
|
65
|
+
-----
|
|
68
66
|
|
|
69
|
-
|
|
70
|
-
"image": "username/my-app",
|
|
71
|
-
"tag": "latest",
|
|
72
|
-
"context": ".",
|
|
73
|
-
"dockerfile": "Dockerfile"
|
|
74
|
-
},
|
|
67
|
+
### HOW TO USE (STEP-BY-STEP) βΆοΈ
|
|
75
68
|
|
|
76
|
-
|
|
77
|
-
"replicas": 2,
|
|
78
|
-
"containerPort": 3000,
|
|
79
|
-
"servicePort": 80,
|
|
80
|
-
"serviceType": "ClusterIP"
|
|
81
|
-
},
|
|
69
|
+
## STEP 1: INITIALIZE THE PROJECT β
|
|
82
70
|
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
95
|
-
|
|
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
|
-
|
|
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
|
-
|
|
81
|
+
## STEP 2: DEPLOY LOCALLY (RECOMMENDED FOR BEGINNERS) π§ͺ
|
|
108
82
|
|
|
109
|
-
|
|
83
|
+
## For first-time users, deploy without using Docker Hub or any container registry:
|
|
84
|
+
k8s-deploy deploy --local
|
|
110
85
|
|
|
111
|
-
deployment
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
92
|
+
# No Docker Hub account or login is required.
|
|
118
93
|
|
|
119
|
-
|
|
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
|
-
|
|
127
|
-
|
|
96
|
+
# Once you are comfortable and logged into a container registry, run:
|
|
97
|
+
k8s-deploy deploy
|
|
128
98
|
|
|
129
|
-
|
|
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
|
-
|
|
104
|
+
-----
|
|
132
105
|
|
|
133
|
-
|
|
106
|
+
### FILES CREATED BY THE TOOL π
|
|
134
107
|
|
|
135
|
-
|
|
108
|
+
# After running the commands, the following files will exist in your project:
|
|
136
109
|
|
|
137
|
-
|
|
138
|
-
|
|
110
|
+
Dockerfile
|
|
111
|
+
k8s.config.json
|
|
112
|
+
deployment.yaml
|
|
113
|
+
service.yaml
|
|
139
114
|
|
|
140
|
-
|
|
115
|
+
# These files can be:
|
|
116
|
+
β’ Reviewed
|
|
117
|
+
β’ Modified
|
|
118
|
+
β’ Committed to Git
|
|
119
|
+
β’ Used independently if needed
|
|
141
120
|
|
|
142
|
-
|
|
121
|
+
-----
|
|
143
122
|
|
|
144
|
-
|
|
123
|
+
### WHAT HAPPENS INTERNALLY π
|
|
145
124
|
|
|
146
|
-
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
133
|
+
# Each step is logged clearly so you can understand what is happening.
|
|
163
134
|
|
|
164
|
-
|
|
135
|
+
-----
|
|
165
136
|
|
|
166
|
-
|
|
137
|
+
### WHY THIS TOOL IS VALUABLE β
|
|
167
138
|
|
|
168
|
-
|
|
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
|
-
|
|
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
|
-
|
|
173
|
-
MIT License
|
|
151
|
+
-----
|
|
174
152
|
|
|
175
|
-
π¨βπ»
|
|
176
|
-
Lokesh Shimpi
|
|
153
|
+
### AUTHOR π¨βπ»
|
|
154
|
+
Lokesh Shimpi
|
package/package.json
CHANGED
|
@@ -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
|
+
}
|