walheim 0.1.2
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.
- checksums.yaml +7 -0
- data/README.md +321 -0
- data/bin/whctl +703 -0
- data/lib/walheim/cluster_resource.rb +166 -0
- data/lib/walheim/config.rb +206 -0
- data/lib/walheim/handler_registry.rb +55 -0
- data/lib/walheim/namespaced_resource.rb +195 -0
- data/lib/walheim/resource.rb +76 -0
- data/lib/walheim/resources/apps.rb +576 -0
- data/lib/walheim/resources/configmaps.rb +48 -0
- data/lib/walheim/resources/namespaces.rb +41 -0
- data/lib/walheim/resources/secrets.rb +50 -0
- data/lib/walheim/sync.rb +60 -0
- data/lib/walheim/version.rb +5 -0
- data/lib/walheim.rb +19 -0
- metadata +105 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 4259f1395b556c0214182501a85b39d7a5bd1845856ba9b917f79c2506792af1
|
|
4
|
+
data.tar.gz: 4c6d2682e56406e6de469a5cdf8aff987f70cd8dcac425f893410c4c0ece7939
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: f2c9b4757a1cffbe832f8b160c9f05521a8d3d615135deaa85a4ac57cdf92531fe91d4ca01e73e8d557f10aa2821629fe912a896ba1913271178a5bdc271f931
|
|
7
|
+
data.tar.gz: 454a92eead0642c653ee6a064a62370eb3a8ed223007873eba172246d03ced1598183a863e1ffe5a07dc5fd7c617400284e19eb7172dec97887c75d2112f1073
|
data/README.md
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
# Walheim
|
|
2
|
+
|
|
3
|
+
A kubectl-style CLI for managing Docker-based homelab infrastructure across multiple machines.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Walheim provides a familiar Kubernetes-like interface for deploying and managing applications in your homelab. Use `whctl` (Walheim Control) to manage namespaces, apps, secrets, and configuration across your physical machines.
|
|
8
|
+
|
|
9
|
+
**Key Features:**
|
|
10
|
+
- kubectl-style CLI interface (`whctl get`, `whctl apply`, etc.)
|
|
11
|
+
- Context-based configuration for multiple environments
|
|
12
|
+
- Docker Compose as the application definition format
|
|
13
|
+
- Kubernetes-style Secret management with automatic injection
|
|
14
|
+
- SSH-based deployment to remote machines
|
|
15
|
+
- Namespace = physical machine mapping
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
gem install walheim
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
### 1. Create Your First Context
|
|
26
|
+
|
|
27
|
+
A context points to a data directory containing your homelab configuration:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Create a context for your homelab
|
|
31
|
+
whctl context new homelab --data-dir ~/my-homelab
|
|
32
|
+
|
|
33
|
+
# The data directory will be created if it doesn't exist
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 2. Create a Namespace
|
|
37
|
+
|
|
38
|
+
Namespaces in Walheim represent physical machines:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Create a namespace for a production server
|
|
42
|
+
whctl create namespace production \
|
|
43
|
+
--hostname prod.example.com \
|
|
44
|
+
--username admin
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 3. Deploy an Application
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Import an existing docker-compose.yml
|
|
51
|
+
whctl import app nginx -n production -f docker-compose.yml
|
|
52
|
+
|
|
53
|
+
# Deploy the app to the namespace
|
|
54
|
+
whctl apply app nginx -n production
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Context Management
|
|
58
|
+
|
|
59
|
+
Walheim uses contexts to manage multiple homelab environments (similar to kubectl):
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Create contexts for different environments
|
|
63
|
+
whctl context new homelab --data-dir ~/homelab-prod
|
|
64
|
+
whctl context new staging --data-dir ~/homelab-staging
|
|
65
|
+
|
|
66
|
+
# List all contexts (* indicates active)
|
|
67
|
+
whctl context list
|
|
68
|
+
# CURRENT NAME DATA DIRECTORY
|
|
69
|
+
# * homelab /home/user/homelab-prod
|
|
70
|
+
# staging /home/user/homelab-staging
|
|
71
|
+
|
|
72
|
+
# Switch between contexts
|
|
73
|
+
whctl context use staging
|
|
74
|
+
|
|
75
|
+
# Show current context
|
|
76
|
+
whctl context current
|
|
77
|
+
# Current context: staging
|
|
78
|
+
# Data directory: /home/user/homelab-staging
|
|
79
|
+
|
|
80
|
+
# Delete a context
|
|
81
|
+
whctl context delete old-context
|
|
82
|
+
|
|
83
|
+
# Override context for a single command
|
|
84
|
+
whctl --context homelab get namespaces
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Configuration is stored in `~/.walheim/config`:
|
|
88
|
+
|
|
89
|
+
```yaml
|
|
90
|
+
apiVersion: walheim.io/v1
|
|
91
|
+
kind: Config
|
|
92
|
+
currentContext: homelab
|
|
93
|
+
contexts:
|
|
94
|
+
- name: homelab
|
|
95
|
+
dataDir: /home/user/homelab-prod
|
|
96
|
+
- name: staging
|
|
97
|
+
dataDir: /home/user/homelab-staging
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Common Commands
|
|
101
|
+
|
|
102
|
+
### Namespace Management
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# List all namespaces
|
|
106
|
+
whctl get namespaces
|
|
107
|
+
|
|
108
|
+
# Create a namespace (represents a physical machine)
|
|
109
|
+
whctl create namespace production \
|
|
110
|
+
--hostname prod.example.com \
|
|
111
|
+
--username admin
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Application Management
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# List apps in a namespace
|
|
118
|
+
whctl get apps -n production
|
|
119
|
+
|
|
120
|
+
# List apps across all namespaces
|
|
121
|
+
whctl get apps --all
|
|
122
|
+
|
|
123
|
+
# Deploy an app
|
|
124
|
+
whctl apply app myapp -n production
|
|
125
|
+
|
|
126
|
+
# Import from docker-compose.yml
|
|
127
|
+
whctl import app myapp -n production -f docker-compose.yml
|
|
128
|
+
|
|
129
|
+
# Start/pause/stop an app
|
|
130
|
+
whctl start app myapp -n production
|
|
131
|
+
whctl pause app myapp -n production
|
|
132
|
+
whctl stop app myapp -n production
|
|
133
|
+
|
|
134
|
+
# View logs
|
|
135
|
+
whctl logs app myapp -n production
|
|
136
|
+
whctl logs app myapp -n production --follow
|
|
137
|
+
whctl logs app myapp -n production --tail 100
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Secret Management
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
# List secrets
|
|
144
|
+
whctl get secrets -n production
|
|
145
|
+
|
|
146
|
+
# Deploy a secret
|
|
147
|
+
whctl apply secret db-creds -n production
|
|
148
|
+
|
|
149
|
+
# Secrets are automatically injected into apps via labels
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Data Directory Structure
|
|
153
|
+
|
|
154
|
+
Your homelab configuration lives in a data directory:
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
~/my-homelab/
|
|
158
|
+
└── namespaces/
|
|
159
|
+
├── production/
|
|
160
|
+
│ ├── .namespace.yaml # SSH credentials
|
|
161
|
+
│ ├── apps/
|
|
162
|
+
│ │ ├── nginx/
|
|
163
|
+
│ │ │ └── docker-compose.yml
|
|
164
|
+
│ │ └── postgres/
|
|
165
|
+
│ │ └── docker-compose.yml
|
|
166
|
+
│ └── secrets/
|
|
167
|
+
│ └── db-creds/
|
|
168
|
+
│ └── secret.yaml
|
|
169
|
+
└── staging/
|
|
170
|
+
├── .namespace.yaml
|
|
171
|
+
└── apps/
|
|
172
|
+
└── myapp/
|
|
173
|
+
└── docker-compose.yml
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Namespace Configuration
|
|
177
|
+
|
|
178
|
+
Each namespace has a `.namespace.yaml` file with SSH connection details:
|
|
179
|
+
|
|
180
|
+
```yaml
|
|
181
|
+
username: admin
|
|
182
|
+
hostname: production.example.com
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Secret Format
|
|
186
|
+
|
|
187
|
+
Secrets use Kubernetes-style YAML format:
|
|
188
|
+
|
|
189
|
+
```yaml
|
|
190
|
+
apiVersion: v1
|
|
191
|
+
kind: Secret
|
|
192
|
+
metadata:
|
|
193
|
+
name: db-creds
|
|
194
|
+
namespace: production
|
|
195
|
+
type: Opaque
|
|
196
|
+
stringData:
|
|
197
|
+
DB_PASSWORD: "secret123"
|
|
198
|
+
API_KEY: "abc-xyz"
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Secrets are automatically injected into Docker Compose services:
|
|
202
|
+
|
|
203
|
+
```yaml
|
|
204
|
+
services:
|
|
205
|
+
myapp:
|
|
206
|
+
image: myapp:latest
|
|
207
|
+
labels:
|
|
208
|
+
- walheim.env-from-secrets=db-creds
|
|
209
|
+
environment:
|
|
210
|
+
APP_MODE: production
|
|
211
|
+
# DB_PASSWORD and API_KEY will be injected automatically
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Architecture
|
|
215
|
+
|
|
216
|
+
### Namespaces vs Nodes
|
|
217
|
+
|
|
218
|
+
Unlike Kubernetes where namespaces are logical and nodes are physical:
|
|
219
|
+
|
|
220
|
+
- **Walheim namespace = physical machine** (1:1 mapping)
|
|
221
|
+
- No scheduling - you explicitly target a namespace with `-n`
|
|
222
|
+
- Each namespace has its own SSH credentials
|
|
223
|
+
|
|
224
|
+
### Deployment Flow
|
|
225
|
+
|
|
226
|
+
1. You maintain configuration in your data directory (Git repository)
|
|
227
|
+
2. Run `whctl apply app myapp -n production`
|
|
228
|
+
3. Walheim syncs files to the remote machine via rsync/SSH
|
|
229
|
+
4. Runs `docker compose up -d` on the remote machine
|
|
230
|
+
5. Secrets are injected before deployment
|
|
231
|
+
|
|
232
|
+
### Resource Types
|
|
233
|
+
|
|
234
|
+
- **ClusterResource**: Resources at the top level (e.g., namespaces)
|
|
235
|
+
- Path: `{data_dir}/namespaces/{name}/`
|
|
236
|
+
- Example: `whctl get namespaces`
|
|
237
|
+
|
|
238
|
+
- **NamespacedResource**: Resources within a namespace (e.g., apps, secrets)
|
|
239
|
+
- Path: `{data_dir}/namespaces/{namespace}/{kind}/{name}/`
|
|
240
|
+
- Example: `whctl get apps -n production`
|
|
241
|
+
|
|
242
|
+
## Global Flags
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
# Override active context
|
|
246
|
+
whctl --context staging get namespaces
|
|
247
|
+
|
|
248
|
+
# Use alternate config file
|
|
249
|
+
whctl --whconfig /path/to/config get namespaces
|
|
250
|
+
|
|
251
|
+
# Or via environment variable
|
|
252
|
+
WHCONFIG=/path/to/config whctl get namespaces
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Development
|
|
256
|
+
|
|
257
|
+
### Setup
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
# Clone the repository
|
|
261
|
+
git clone https://github.com/walheimlab/walheim-rb
|
|
262
|
+
cd walheim-rb
|
|
263
|
+
|
|
264
|
+
# Install dependencies
|
|
265
|
+
bundle install
|
|
266
|
+
|
|
267
|
+
# Run locally
|
|
268
|
+
./bin/whctl --help
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Building
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
# Build the gem
|
|
275
|
+
gem build walheim.gemspec
|
|
276
|
+
|
|
277
|
+
# Install locally
|
|
278
|
+
gem install --local walheim-*.gem
|
|
279
|
+
|
|
280
|
+
# Test
|
|
281
|
+
whctl --help
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Testing
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
# Create a test context
|
|
288
|
+
./bin/whctl context new test --data-dir /tmp/walheim-test
|
|
289
|
+
|
|
290
|
+
# Create test resources
|
|
291
|
+
./bin/whctl create namespace demo --hostname localhost
|
|
292
|
+
|
|
293
|
+
# Verify
|
|
294
|
+
./bin/whctl get namespaces
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## For Maintainers
|
|
298
|
+
|
|
299
|
+
If you're a maintainer releasing new versions:
|
|
300
|
+
|
|
301
|
+
- **[Release Process](docs/maintainers/release.md)** - Step-by-step guide for publishing to RubyGems
|
|
302
|
+
|
|
303
|
+
## Contributing
|
|
304
|
+
|
|
305
|
+
Contributions are welcome! Please:
|
|
306
|
+
|
|
307
|
+
1. Fork the repository
|
|
308
|
+
2. Create a feature branch
|
|
309
|
+
3. Make your changes
|
|
310
|
+
4. Test locally
|
|
311
|
+
5. Submit a pull request
|
|
312
|
+
|
|
313
|
+
## License
|
|
314
|
+
|
|
315
|
+
MIT
|
|
316
|
+
|
|
317
|
+
## Links
|
|
318
|
+
|
|
319
|
+
- **Repository**: https://github.com/walheimlab/walheim-rb
|
|
320
|
+
- **Issues**: https://github.com/walheimlab/walheim-rb/issues
|
|
321
|
+
- **RubyGems**: https://rubygems.org/gems/walheim
|