|
1 | 1 | # helm-values-manager
|
2 | 2 |
|
3 |
| -A Helm plugin for managing value configurations across multiple environments with schema-driven validation and secret management. |
| 3 | +A Helm plugin that helps manage Helm value configurations across different deployments (dev, test, prod) with a schema-driven approach. It separates value definitions (schema) from actual values, enabling vendors to distribute schemas while customers manage their deployment-specific values securely. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Schema-driven configuration**: Define value metadata (descriptions, paths, requirements) separately from actual values |
| 8 | +- **Multi-environment support**: Manage values for different deployments in a single workflow |
| 9 | +- **Secret management**: Support for environment variables with pluggable architecture for future providers |
| 10 | +- **CD system agnostic**: Generates standard values.yaml files usable with any CD system |
| 11 | +- **Type safety**: JSON-based configuration with validation |
| 12 | +- **Interactive CLI**: Commands to add/update/remove both schema entries and values |
4 | 13 |
|
5 | 14 | ## Installation
|
6 | 15 |
|
| 16 | +### As a Helm Plugin (Recommended) |
| 17 | + |
| 18 | +Install the plugin using the Helm plugin manager: |
| 19 | + |
7 | 20 | ```bash
|
8 | 21 | helm plugin install https://github.com/yourusername/helm-values-manager
|
9 | 22 | ```
|
10 | 23 |
|
11 |
| -## Usage |
| 24 | +Or install from source: |
| 25 | + |
| 26 | +```bash |
| 27 | +git clone https://github.com/yourusername/helm-values-manager |
| 28 | +helm plugin install ./helm-values-manager |
| 29 | +``` |
| 30 | + |
| 31 | +### As a Standalone CLI Tool |
| 32 | + |
| 33 | +Install directly with pip: |
| 34 | + |
| 35 | +```bash |
| 36 | +pip install helm-values-manager |
| 37 | +``` |
| 38 | + |
| 39 | +Or with uv: |
12 | 40 |
|
13 |
| -Initialize a new schema: |
14 | 41 | ```bash
|
15 |
| -helm values-manager init |
| 42 | +uv add helm-values-manager |
| 43 | +``` |
| 44 | + |
| 45 | +Or install from source: |
| 46 | + |
| 47 | +```bash |
| 48 | +git clone https://github.com/yourusername/helm-values-manager |
| 49 | +cd helm-values-manager |
| 50 | +uv install |
| 51 | +# CLI will be available as: uv run helm-values-manager |
| 52 | +``` |
| 53 | + |
| 54 | +## Quick Start |
| 55 | + |
| 56 | +### Vendor Workflow (Chart Publisher) |
| 57 | + |
| 58 | +1. **Initialize schema**: |
| 59 | + ```bash |
| 60 | + helm values-manager init |
| 61 | + ``` |
| 62 | + |
| 63 | +2. **Add schema definitions**: |
| 64 | + ```bash |
| 65 | + helm values-manager schema add |
| 66 | + # Interactive prompts for: key, path, description, type, required, etc. |
| 67 | + ``` |
| 68 | + |
| 69 | +3. **Distribute schema.json** alongside your Helm chart |
| 70 | + |
| 71 | +### Customer Workflow (Chart User) |
| 72 | + |
| 73 | +1. **Set up environment values**: |
| 74 | + ```bash |
| 75 | + # Set regular values |
| 76 | + helm values-manager values set database-host "prod-db.example.com" --env prod |
| 77 | + |
| 78 | + # Set secrets (uses environment variables) |
| 79 | + helm values-manager values set-secret database-password --env prod |
| 80 | + ``` |
| 81 | + |
| 82 | +2. **Generate values.yaml for deployment**: |
| 83 | + ```bash |
| 84 | + export PROD_DB_PASSWORD="actual-secret-password" |
| 85 | + helm values-manager generate --env prod > values-prod.yaml |
| 86 | + ``` |
| 87 | + |
| 88 | +3. **Deploy with Helm**: |
| 89 | + ```bash |
| 90 | + helm upgrade myapp ./chart -f values-prod.yaml |
| 91 | + ``` |
| 92 | + |
| 93 | +## Command Reference |
| 94 | + |
| 95 | +> **Note**: Replace `helm values-manager` with `helm-values-manager` when using the standalone CLI installation. |
| 96 | +
|
| 97 | +| Command | Description | |
| 98 | +|---------|-------------| |
| 99 | +| `helm values-manager init` | Initialize a new schema.json file | |
| 100 | +| `helm values-manager validate [--env ENV]` | Validate schema and values | |
| 101 | +| `helm values-manager generate --env ENV` | Generate values.yaml for deployment | |
| 102 | + |
| 103 | +### Schema Management |
| 104 | + |
| 105 | +| Command | Description | |
| 106 | +|---------|-------------| |
| 107 | +| `helm values-manager schema add` | Add new value to schema (interactive) | |
| 108 | +| `helm values-manager schema list` | List all schema entries | |
| 109 | +| `helm values-manager schema get KEY` | Show details of specific schema entry | |
| 110 | +| `helm values-manager schema update KEY` | Update existing schema entry | |
| 111 | +| `helm values-manager schema remove KEY` | Remove entry from schema | |
| 112 | + |
| 113 | +### Values Management |
| 114 | + |
| 115 | +| Command | Description | |
| 116 | +|---------|-------------| |
| 117 | +| `helm values-manager values set KEY VALUE --env ENV` | Set or update a value | |
| 118 | +| `helm values-manager values set-secret KEY --env ENV` | Configure secret (interactive) | |
| 119 | +| `helm values-manager values get KEY --env ENV` | Get specific value | |
| 120 | +| `helm values-manager values list --env ENV` | List all values for environment | |
| 121 | +| `helm values-manager values remove KEY --env ENV` | Remove a value | |
| 122 | +| `helm values-manager values init --env ENV` | Interactive setup for environment | |
| 123 | + |
| 124 | +### Global Options |
| 125 | + |
| 126 | +All commands support these options: |
| 127 | +- `--schema PATH`: Path to schema.json (default: ./schema.json) |
| 128 | +- `--values PATH`: Base path for values files (default: ./values-{env}.json) |
| 129 | + |
| 130 | +## File Structure |
| 131 | + |
| 132 | +``` |
| 133 | +project/ |
| 134 | +├── schema.json # Value definitions (from vendor) |
| 135 | +├── values-dev.json # Customer's values for dev environment |
| 136 | +├── values-staging.json # Customer's values for staging |
| 137 | +└── values-prod.json # Customer's values for production |
| 138 | +``` |
| 139 | + |
| 140 | +### Schema File Example |
| 141 | + |
| 142 | +```json |
| 143 | +{ |
| 144 | + "version": "1.0", |
| 145 | + "values": [ |
| 146 | + { |
| 147 | + "key": "database-host", |
| 148 | + "path": "database.host", |
| 149 | + "description": "PostgreSQL database hostname", |
| 150 | + "type": "string", |
| 151 | + "required": true, |
| 152 | + "default": "localhost" |
| 153 | + }, |
| 154 | + { |
| 155 | + "key": "database-password", |
| 156 | + "path": "database.password", |
| 157 | + "description": "PostgreSQL password", |
| 158 | + "type": "string", |
| 159 | + "required": true, |
| 160 | + "sensitive": true |
| 161 | + }, |
| 162 | + { |
| 163 | + "key": "replicas", |
| 164 | + "path": "deployment.replicas", |
| 165 | + "type": "number", |
| 166 | + "required": false, |
| 167 | + "default": 3 |
| 168 | + } |
| 169 | + ] |
| 170 | +} |
| 171 | +``` |
| 172 | + |
| 173 | +### Values File Example |
| 174 | + |
| 175 | +```json |
| 176 | +{ |
| 177 | + "database-host": "prod-db.example.com", |
| 178 | + "database-password": { |
| 179 | + "type": "env", |
| 180 | + "name": "PROD_DB_PASSWORD" |
| 181 | + }, |
| 182 | + "replicas": 5 |
| 183 | +} |
16 | 184 | ```
|
17 | 185 |
|
18 |
| -Add a value to the schema: |
| 186 | +## Security Best Practices |
| 187 | + |
| 188 | +### Secret Management |
| 189 | + |
| 190 | +1. **Never store actual secrets in values files** - Use environment variable references: |
| 191 | + ```json |
| 192 | + { |
| 193 | + "database-password": { |
| 194 | + "type": "env", |
| 195 | + "name": "PROD_DB_PASSWORD" |
| 196 | + } |
| 197 | + } |
| 198 | + ``` |
| 199 | + |
| 200 | +2. **Set environment variables before generation**: |
| 201 | + ```bash |
| 202 | + export PROD_DB_PASSWORD="actual-secret" |
| 203 | + helm values-manager generate --env prod |
| 204 | + ``` |
| 205 | + |
| 206 | +3. **Pipe output directly to Helm** to avoid writing secrets to disk: |
| 207 | + ```bash |
| 208 | + helm values-manager generate --env prod | helm upgrade myapp ./chart -f - |
| 209 | + ``` |
| 210 | + |
| 211 | +### File Permissions |
| 212 | + |
| 213 | +- Ensure generated values.yaml has appropriate permissions (600) |
| 214 | +- Consider using CI/CD environment variables instead of local files |
| 215 | +- Never commit generated values.yaml files to version control |
| 216 | + |
| 217 | +## Troubleshooting |
| 218 | + |
| 219 | +### Common Errors |
| 220 | + |
| 221 | +**Error: Missing required value: database-host (env: prod)** |
| 222 | +- Solution: Set the missing value with `helm values-manager values set database-host "value" --env prod` |
| 223 | + |
| 224 | +**Error: Environment variable not found: PROD_DB_PASSWORD** |
| 225 | +- Solution: Export the environment variable before generation: `export PROD_DB_PASSWORD="secret"` |
| 226 | + |
| 227 | +**Error: Type mismatch: replicas should be number, got string** |
| 228 | +- Solution: Ensure numeric values are not quoted: `helm values-manager values set replicas 3 --env prod` |
| 229 | + |
| 230 | +**Error: Schema file not found: schema.json** |
| 231 | +- Solution: Run `helm values-manager init` to create a schema file, or use `--schema` flag to specify path |
| 232 | + |
| 233 | +**Error: Key 'unknown-key' not found in schema** |
| 234 | +- Solution: Add the key to schema first with `helm values-manager schema add`, or check for typos |
| 235 | + |
| 236 | +### Validation Issues |
| 237 | + |
| 238 | +Run validation to see all issues at once: |
19 | 239 | ```bash
|
20 |
| -helm values-manager schema add |
| 240 | +helm values-manager validate --env prod |
21 | 241 | ```
|
22 | 242 |
|
23 |
| -Set values for an environment: |
| 243 | +This will show all missing values, type mismatches, and other validation errors. |
| 244 | + |
| 245 | +### Debug Mode |
| 246 | + |
| 247 | +For detailed error information, use the validation command: |
24 | 248 | ```bash
|
25 |
| -helm values-manager values set --env dev |
| 249 | +helm values-manager validate # Validates all environments |
| 250 | +helm values-manager validate --env prod # Validates specific environment |
26 | 251 | ```
|
27 | 252 |
|
28 |
| -Generate values.yaml: |
| 253 | +## Development |
| 254 | + |
| 255 | +This plugin is written in Python and uses: |
| 256 | +- **CLI Framework**: Typer |
| 257 | +- **Dependencies**: PyYAML for YAML generation |
| 258 | +- **Testing**: pytest with comprehensive test coverage |
| 259 | + |
| 260 | +### Building from Source |
| 261 | + |
29 | 262 | ```bash
|
30 |
| -helm values-manager generate --env dev |
31 |
| -``` |
| 263 | +git clone https://github.com/yourusername/helm-values-manager |
| 264 | +cd helm-values-manager |
| 265 | +uv install |
| 266 | +uv run pytest # Run tests |
| 267 | +``` |
| 268 | + |
| 269 | +## Contributing |
| 270 | + |
| 271 | +1. Fork the repository |
| 272 | +2. Create a feature branch |
| 273 | +3. Add tests for new functionality |
| 274 | +4. Ensure all tests pass |
| 275 | +5. Submit a pull request |
| 276 | + |
| 277 | +## License |
| 278 | + |
| 279 | +[MIT License](LICENSE) |
0 commit comments