|
| 1 | +# Development Guide |
| 2 | + |
| 3 | +This guide provides instructions for local development and testing of the Flipt Helm charts. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +Before you begin, ensure you have the following tools installed: |
| 8 | + |
| 9 | +- [Docker](https://docs.docker.com/get-docker/) |
| 10 | +- [kubectl](https://kubernetes.io/docs/tasks/tools/) |
| 11 | +- [Helm](https://helm.sh/docs/intro/install/) (v3.0+) |
| 12 | +- [kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation) |
| 13 | +- [chart-testing (ct)](https://github.com/helm/chart-testing#installation) |
| 14 | + |
| 15 | +## Setting Up Local Development Environment |
| 16 | + |
| 17 | +### 1. Create a kind Cluster |
| 18 | + |
| 19 | +```bash |
| 20 | +# Create a new kind cluster for testing |
| 21 | +kind create cluster --name flipt-dev |
| 22 | + |
| 23 | +# Verify the cluster is running |
| 24 | +kubectl cluster-info --context kind-flipt-dev |
| 25 | +kubectl get nodes |
| 26 | +``` |
| 27 | + |
| 28 | +### 2. Clone and Navigate to Repository |
| 29 | + |
| 30 | +```bash |
| 31 | +git clone https://github.com/flipt-io/helm-charts.git |
| 32 | +cd helm-charts |
| 33 | +``` |
| 34 | + |
| 35 | +## Testing Charts Locally |
| 36 | + |
| 37 | +### Testing Flipt v1 Chart |
| 38 | + |
| 39 | +```bash |
| 40 | +# Install Flipt v1 chart |
| 41 | +helm install flipt-v1-test ./charts/flipt |
| 42 | + |
| 43 | +# Check deployment status |
| 44 | +kubectl get pods -l app.kubernetes.io/name=flipt |
| 45 | +kubectl get svc -l app.kubernetes.io/name=flipt |
| 46 | + |
| 47 | +# View logs |
| 48 | +kubectl logs -l app.kubernetes.io/name=flipt |
| 49 | + |
| 50 | +# Port forward to access Flipt UI |
| 51 | +kubectl port-forward svc/flipt-v1-test 8080:8080 |
| 52 | + |
| 53 | +# Visit http://localhost:8080 in your browser |
| 54 | +``` |
| 55 | + |
| 56 | +### Testing Flipt v2 Chart |
| 57 | + |
| 58 | +```bash |
| 59 | +# Install Flipt v2 chart |
| 60 | +helm install flipt-v2-test ./charts/flipt-v2 |
| 61 | + |
| 62 | +# Check deployment status |
| 63 | +kubectl get pods -l app.kubernetes.io/name=flipt-v2 |
| 64 | +kubectl get svc -l app.kubernetes.io/name=flipt-v2 |
| 65 | + |
| 66 | +# View logs |
| 67 | +kubectl logs -l app.kubernetes.io/name=flipt-v2 |
| 68 | + |
| 69 | +# Port forward to access Flipt UI |
| 70 | +kubectl port-forward svc/flipt-v2-test 8080:8080 |
| 71 | + |
| 72 | +# Visit http://localhost:8080 in your browser |
| 73 | +``` |
| 74 | + |
| 75 | +## Testing with Custom Values |
| 76 | + |
| 77 | +### Create Test Values Files |
| 78 | + |
| 79 | +Create custom values files for testing different configurations: |
| 80 | + |
| 81 | +```bash |
| 82 | +# Create test values for v1 |
| 83 | +cat > test-values-v1.yaml << EOF |
| 84 | +ingress: |
| 85 | + enabled: true |
| 86 | + className: nginx |
| 87 | + hosts: |
| 88 | + - host: flipt-v1.local |
| 89 | + paths: |
| 90 | + - path: / |
| 91 | + pathType: Prefix |
| 92 | +
|
| 93 | +flipt: |
| 94 | + config: |
| 95 | + log: |
| 96 | + level: DEBUG |
| 97 | + db: |
| 98 | + url: "file:/var/opt/flipt/flipt.db" |
| 99 | +EOF |
| 100 | + |
| 101 | +# Create test values for v2 |
| 102 | +cat > test-values-v2.yaml << EOF |
| 103 | +ingress: |
| 104 | + enabled: true |
| 105 | + className: nginx |
| 106 | + hosts: |
| 107 | + - host: flipt-v2.local |
| 108 | + paths: |
| 109 | + - path: / |
| 110 | + pathType: Prefix |
| 111 | +
|
| 112 | +flipt: |
| 113 | + config: |
| 114 | + log: |
| 115 | + level: DEBUG |
| 116 | + storage: |
| 117 | + type: local |
| 118 | + local: |
| 119 | + path: /var/opt/flipt |
| 120 | +EOF |
| 121 | +``` |
| 122 | + |
| 123 | +### Install with Custom Values |
| 124 | + |
| 125 | +```bash |
| 126 | +# Install v1 with custom values |
| 127 | +helm install flipt-v1-custom ./charts/flipt -f test-values-v1.yaml |
| 128 | + |
| 129 | +# Install v2 with custom values |
| 130 | +helm install flipt-v2-custom ./charts/flipt-v2 -f test-values-v2.yaml |
| 131 | +``` |
| 132 | + |
| 133 | +## Development Workflow |
| 134 | + |
| 135 | +### 1. Template Testing (Dry Run) |
| 136 | + |
| 137 | +Before installing, always test your templates: |
| 138 | + |
| 139 | +```bash |
| 140 | +# Test v1 chart templates |
| 141 | +helm template flipt-v1-test ./charts/flipt |
| 142 | + |
| 143 | +# Test v2 chart templates |
| 144 | +helm template flipt-v2-test ./charts/flipt-v2 |
| 145 | + |
| 146 | +# Test with custom values |
| 147 | +helm template flipt-v1-test ./charts/flipt -f test-values-v1.yaml |
| 148 | +helm template flipt-v2-test ./charts/flipt-v2 -f test-values-v2.yaml |
| 149 | + |
| 150 | +# Save templates to files for inspection |
| 151 | +helm template flipt-v1-test ./charts/flipt > v1-templates.yaml |
| 152 | +helm template flipt-v2-test ./charts/flipt-v2 > v2-templates.yaml |
| 153 | +``` |
| 154 | + |
| 155 | +### 2. Chart Linting |
| 156 | + |
| 157 | +```bash |
| 158 | +# Lint all charts |
| 159 | +ct lint --lint-conf lintconf.yaml --target-branch main |
| 160 | + |
| 161 | +# Lint specific chart |
| 162 | +ct lint --lint-conf lintconf.yaml --charts charts/flipt |
| 163 | +ct lint --lint-conf lintconf.yaml --charts charts/flipt-v2 |
| 164 | + |
| 165 | +# YAML linting |
| 166 | +yamllint -c lintconf.yaml charts/ |
| 167 | + |
| 168 | +# Helm linting |
| 169 | +helm lint charts/flipt |
| 170 | +helm lint charts/flipt-v2 |
| 171 | +``` |
| 172 | + |
| 173 | +### 3. Upgrade Testing |
| 174 | + |
| 175 | +```bash |
| 176 | +# Test upgrades for v1 |
| 177 | +helm upgrade flipt-v1-test ./charts/flipt |
| 178 | +helm upgrade flipt-v1-test ./charts/flipt -f test-values-v1.yaml |
| 179 | + |
| 180 | +# Test upgrades for v2 |
| 181 | +helm upgrade flipt-v2-test ./charts/flipt-v2 |
| 182 | +helm upgrade flipt-v2-test ./charts/flipt-v2 -f test-values-v2.yaml |
| 183 | +``` |
| 184 | + |
| 185 | +### 4. Chart Testing with ct |
| 186 | + |
| 187 | +```bash |
| 188 | +# Run comprehensive chart tests |
| 189 | +ct install --config ct.yaml |
| 190 | + |
| 191 | +# Test specific charts |
| 192 | +ct install --config ct.yaml --charts charts/flipt |
| 193 | +ct install --config ct.yaml --charts charts/flipt-v2 |
| 194 | +``` |
| 195 | + |
| 196 | +## Debugging Common Issues |
| 197 | + |
| 198 | +### Pod Not Starting |
| 199 | + |
| 200 | +```bash |
| 201 | +# Check pod status |
| 202 | +kubectl get pods -l app.kubernetes.io/instance=<release-name> |
| 203 | + |
| 204 | +# Describe pod for detailed information |
| 205 | +kubectl describe pod -l app.kubernetes.io/instance=<release-name> |
| 206 | + |
| 207 | +# Check logs |
| 208 | +kubectl logs -l app.kubernetes.io/instance=<release-name> |
| 209 | + |
| 210 | +# Check events |
| 211 | +kubectl get events --sort-by=.metadata.creationTimestamp |
| 212 | +``` |
| 213 | + |
| 214 | +### Configuration Issues |
| 215 | + |
| 216 | +```bash |
| 217 | +# Check ConfigMap contents |
| 218 | +kubectl get configmap <release-name> -o yaml |
| 219 | + |
| 220 | +# Check rendered templates |
| 221 | +helm get manifest <release-name> |
| 222 | + |
| 223 | +# Check values used |
| 224 | +helm get values <release-name> |
| 225 | +``` |
| 226 | + |
| 227 | +### Network Issues |
| 228 | + |
| 229 | +```bash |
| 230 | +# Check services |
| 231 | +kubectl get svc -l app.kubernetes.io/instance=<release-name> |
| 232 | + |
| 233 | +# Check endpoints |
| 234 | +kubectl get endpoints <release-name> |
| 235 | + |
| 236 | +# Test connectivity |
| 237 | +kubectl run -it --rm debug --image=busybox --restart=Never -- sh |
| 238 | +# Inside the pod: wget -qO- http://<service-name>:8080/health |
| 239 | +``` |
| 240 | + |
| 241 | +## Making Changes |
| 242 | + |
| 243 | +### 1. Modify Chart Files |
| 244 | + |
| 245 | +Make your changes to: |
| 246 | +- `charts/flipt/` (for v1 changes) |
| 247 | +- `charts/flipt-v2/` (for v2 changes) |
| 248 | + |
| 249 | +### 2. Test Changes |
| 250 | + |
| 251 | +```bash |
| 252 | +# Lint changes |
| 253 | +ct lint --lint-conf lintconf.yaml --target-branch main |
| 254 | + |
| 255 | +# Template test |
| 256 | +helm template test-release ./charts/flipt |
| 257 | +helm template test-release ./charts/flipt-v2 |
| 258 | + |
| 259 | +# Install test |
| 260 | +helm install test-release ./charts/flipt |
| 261 | +helm install test-release ./charts/flipt-v2 |
| 262 | +``` |
| 263 | + |
| 264 | +### 3. Clean Up Test Releases |
| 265 | + |
| 266 | +```bash |
| 267 | +# List releases |
| 268 | +helm list |
| 269 | + |
| 270 | +# Uninstall test releases |
| 271 | +helm uninstall flipt-v1-test |
| 272 | +helm uninstall flipt-v2-test |
| 273 | +helm uninstall flipt-v1-custom |
| 274 | +helm uninstall flipt-v2-custom |
| 275 | +``` |
| 276 | + |
| 277 | +## Environment Cleanup |
| 278 | + |
| 279 | +### Clean Up Kubernetes Resources |
| 280 | + |
| 281 | +```bash |
| 282 | +# Delete all test releases |
| 283 | +helm list --short | xargs -I {} helm uninstall {} |
| 284 | + |
| 285 | +# Verify cleanup |
| 286 | +kubectl get all |
| 287 | +``` |
| 288 | + |
| 289 | +### Delete kind Cluster |
| 290 | + |
| 291 | +```bash |
| 292 | +# Delete the development cluster |
| 293 | +kind delete cluster --name flipt-dev |
| 294 | + |
| 295 | +# Verify deletion |
| 296 | +kind get clusters |
| 297 | +``` |
| 298 | + |
| 299 | +## Tips and Best Practices |
| 300 | + |
| 301 | +### 1. Use Separate Namespaces |
| 302 | + |
| 303 | +```bash |
| 304 | +# Create namespace for testing |
| 305 | +kubectl create namespace flipt-test |
| 306 | + |
| 307 | +# Install charts in specific namespace |
| 308 | +helm install flipt-v1 ./charts/flipt -n flipt-test |
| 309 | +helm install flipt-v2 ./charts/flipt-v2 -n flipt-test |
| 310 | + |
| 311 | +# Clean up namespace |
| 312 | +kubectl delete namespace flipt-test |
| 313 | +``` |
| 314 | + |
| 315 | +### 2. Monitor Resource Usage |
| 316 | + |
| 317 | +```bash |
| 318 | +# Check resource usage |
| 319 | +kubectl top nodes |
| 320 | +kubectl top pods |
| 321 | + |
| 322 | +# Check resource requests/limits |
| 323 | +kubectl describe deployment <release-name> |
| 324 | +``` |
| 325 | + |
| 326 | +### 3. Test Different Scenarios |
| 327 | + |
| 328 | +- Test with minimal values (defaults) |
| 329 | +- Test with custom configurations |
| 330 | +- Test upgrades between versions |
| 331 | +- Test with different Kubernetes versions |
| 332 | +- Test resource limits and requests |
| 333 | +- Test ingress configurations |
| 334 | +- Test persistent storage |
| 335 | + |
| 336 | +### 4. Version Testing |
| 337 | + |
| 338 | +```bash |
| 339 | +# Test with specific image versions |
| 340 | +helm install flipt-v1 ./charts/flipt --set image.tag=v1.59.0 |
| 341 | +helm install flipt-v2 ./charts/flipt-v2 --set image.tag=v2-beta |
| 342 | +``` |
| 343 | + |
| 344 | +## Continuous Integration |
| 345 | + |
| 346 | +The repository uses GitHub Actions for automated testing. You can run similar tests locally: |
| 347 | + |
| 348 | +```bash |
| 349 | +# Run the same linting as CI |
| 350 | +ct lint --lint-conf lintconf.yaml --target-branch main |
| 351 | + |
| 352 | +# Run the same installation tests as CI |
| 353 | +ct install --config ct.yaml |
| 354 | +``` |
| 355 | + |
| 356 | +For more information about the CI pipeline, see the GitHub Actions workflows in `.github/workflows/`. |
0 commit comments