Skip to content

Commit 5353c38

Browse files
Merge pull request #9 from OneideLuizSchneider/add-stop-start
Adds start and stop cluster functionality
2 parents 5eed932 + a2573b6 commit 5353c38

File tree

8 files changed

+235
-317
lines changed

8 files changed

+235
-317
lines changed

README.md

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# blitzctl
22

3-
`blitzctl` is a CLI tool for managing local Kubernetes environments. It simplifies the creation, deletion, upgrading, and management of Kubernetes clusters using tools like `Minikube`, `Kind`, and `K3d`.
3+
`blitzctl` is a CLI tool for managing local Kubernetes environments. It simplifies the creation, deletion, upgrading, and management of Kubernetes clusters using tools like `Minikube` and `Kind`.
44

55
Currently supports `macOS` and `Linux`.
66

77
## Key Features
88

9-
- 🚀 **Multi-Provider Support**: Kind, Minikube, and K3d
9+
- 🚀 **Multi-Provider Support**: Kind and Minikube
1010
- ⚙️ **Smart Configuration**: Powered by Viper with file, environment, and flag support
1111
- 🔄 **Context Switching**: Easy switching between different cluster environments
1212
- 📊 **Cluster State Tracking**: Automatic tracking of created clusters and their metadata
@@ -24,7 +24,7 @@ curl -fsSL https://raw.githubusercontent.com/OneideLuizSchneider/blitzctl/main/s
2424
- Pin a specific version:
2525

2626
```sh
27-
BLITZCTL_VERSION=v0.0.1 \
27+
BLITZCTL_VERSION=v0.0.3 \
2828
curl -fsSL https://raw.githubusercontent.com/OneideLuizSchneider/blitzctl/main/scripts/blitzctl.sh | sh -
2929
```
3030

@@ -72,6 +72,8 @@ blitzctl <command> <subcommand> [flags]
7272
- `list`: List all available clusters.
7373
- `install`: Install tools like Minikube or Kind.
7474
- `upgrade`: Upgrade tools like Minikube or Kind to their latest versions.
75+
- `start` `start`: Only available for `minikube`
76+
- It'll `start` or `stop` a cluster
7577

7678
##### Configuration Commands
7779

@@ -290,15 +292,13 @@ blitzctl config get driver # Shows: containerd
290292
# Create clusters with your configured defaults
291293
blitzctl cluster create minikube --cluster-name prod-cluster
292294
blitzctl cluster create kind --cluster-name dev-cluster
293-
blitzctl cluster create k3d --cluster-name test-cluster
294295

295296
# View all managed clusters
296297
blitzctl config list
297298
# Output:
298299
# Managed Clusters:
299300
# ✅ prod-cluster (minikube) - 1.34.4 - Created: 2025-09-01 10:30:00
300301
# ✅ dev-cluster (kind) - 1.34.4 - Created: 2025-09-01 10:35:00
301-
# ✅ test-cluster (k3d) - 1.34.4 - Created: 2025-09-01 10:40:00
302302
```
303303

304304
### Context Management Examples
@@ -313,7 +313,6 @@ blitzctl context list
313313
# ==========================
314314
# ✅ prod-cluster (minikube) - 1.34.4
315315
# ✅ dev-cluster (kind) - 1.34.4
316-
# ✅ test-cluster (k3d) - 1.34.4
317316

318317
# Switch to development cluster
319318
blitzctl context use dev-cluster kind
@@ -337,12 +336,10 @@ blitzctl config set cni cilium
337336
# 2. Create different clusters for different purposes
338337
blitzctl cluster create kind --cluster-name frontend-dev
339338
blitzctl cluster create minikube --cluster-name backend-dev --driver podman
340-
blitzctl cluster create k3d --cluster-name integration-test
341339

342340
# 3. Switch between environments as needed
343341
blitzctl context use frontend-dev kind # Work on frontend
344342
blitzctl context use backend-dev minikube # Work on backend
345-
blitzctl context use integration-test k3d # Run integration tests
346343

347344
# 4. Check what you're currently working on
348345
blitzctl context current
@@ -378,7 +375,6 @@ blitzctl config set k8s-version 1.34.4
378375
# 2. Create multiple environments
379376
blitzctl cluster create kind --cluster-name frontend-dev
380377
blitzctl cluster create minikube --cluster-name backend-dev --driver podman
381-
blitzctl cluster create k3d --cluster-name staging
382378

383379
# 3. View all your environments
384380
blitzctl config list
@@ -391,9 +387,6 @@ blitzctl context use frontend-dev kind
391387
blitzctl context use backend-dev minikube
392388
# ... do backend development work ...
393389

394-
blitzctl context use staging k3d
395-
# ... run staging tests ...
396-
397390
# 5. Check what you're currently working on
398391
blitzctl context current
399392

cmd/cluster/cluster.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ var (
2727
# Upgrade a Minikube cluster
2828
blitzctl cluster upgrade minikube
2929
# Upgrade a Kind cluster
30-
blitzctl cluster upgrade kind`))
30+
blitzctl cluster upgrade kind
31+
32+
# Stop a Minikube cluster
33+
blitzctl cluster stop minikube --cluster-name <cluster-name>
34+
# Start a Minikube cluster
35+
blitzctl cluster start minikube --cluster-name <cluster-name>`))
3136

3237
clusterCmd = &cobra.Command{
3338
Use: "cluster",
@@ -59,4 +64,7 @@ func init() {
5964
clusterCmd.AddCommand(createCmd)
6065
clusterCmd.AddCommand(deleteCmd)
6166
clusterCmd.AddCommand(upgradeCmd)
67+
68+
clusterCmd.AddCommand(startCmd)
69+
clusterCmd.AddCommand(stopCmd)
6270
}

cmd/cluster/provider/factory.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ func NewClusterProviderFactory() *ClusterProviderFactory {
2929
func (f *ClusterProviderFactory) registerBuiltInProviders() {
3030
f.RegisterProvider(Kind, NewKindProvider)
3131
f.RegisterProvider(Minikube, NewMinikubeProvider)
32-
f.RegisterProvider(K3d, NewK3dProvider)
3332
}
3433

3534
// RegisterProvider allows registering custom providers

cmd/cluster/provider/interfaces.go

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,76 +14,52 @@ const (
1414
K3d ProviderType = "k3d"
1515
)
1616

17-
// ClusterOptions represents common options for cluster operations
17+
type Default struct {
18+
ClusterName string
19+
}
20+
1821
type ClusterOptions struct {
1922
ClusterName string
2023
K8sVersion string
2124
}
2225

23-
// CreateOptions represents options for creating a cluster
2426
type CreateOptions struct {
2527
ClusterOptions
2628
// Provider-specific options will be handled via composition or type assertions
2729
ProviderOptions map[string]interface{}
2830
}
2931

30-
// DeleteOptions represents options for deleting a cluster
31-
type DeleteOptions struct {
32-
ClusterName string
33-
}
34-
35-
// ListOptions represents options for listing clusters
3632
type ListOptions struct {
3733
// Currently no specific options needed, but keeping for future extensibility
3834
}
3935

40-
// UpgradeOptions represents options for upgrading a cluster
4136
type UpgradeOptions struct {
4237
ClusterOptions
4338
ProviderOptions map[string]interface{}
4439
}
4540

46-
// InstallOptions represents options for installing a cluster
4741
type InstallOptions struct {
4842
ClusterOptions
4943
ProviderOptions map[string]interface{}
5044
}
5145

5246
// ClusterProvider defines the interface that all cluster providers must implement
5347
type ClusterProvider interface {
54-
// GetProviderType returns the type of this provider
5548
GetProviderType() ProviderType
56-
57-
// Create creates a new cluster with the given options
5849
Create(options *CreateOptions) error
59-
60-
// Delete deletes a cluster with the given options
61-
Delete(options *DeleteOptions) error
62-
63-
// List lists all clusters for this provider
50+
Delete(options *Default) error
6451
List(options *ListOptions) error
65-
66-
// Upgrade upgrades a cluster with the given options
6752
Upgrade(options *UpgradeOptions) error
68-
69-
// Install installs a cluster with the given options
7053
Install(options *InstallOptions) error
71-
72-
// Validate validates that the provider is available and properly configured
54+
Start(options *Default) error
55+
Stop(options *Default) error
7356
Validate() error
7457

75-
// GetCreateCommand returns the cobra command for creating clusters with this provider
7658
GetCreateCommand() *cobra.Command
77-
78-
// GetDeleteCommand returns the cobra command for deleting clusters with this provider
7959
GetDeleteCommand() *cobra.Command
80-
81-
// GetListCommand returns the cobra command for listing clusters with this provider
8260
GetListCommand() *cobra.Command
83-
84-
// GetUpgradeCommand returns the cobra command for upgrading clusters with this provider
8561
GetUpgradeCommand() *cobra.Command
86-
87-
// GetInstallCommand returns the cobra command for installing clusters with this provider
8862
GetInstallCommand() *cobra.Command
63+
GetStartCommand() *cobra.Command
64+
GetStopCommand() *cobra.Command
8965
}

0 commit comments

Comments
 (0)