|
| 1 | +# MLflow Development Guide |
| 2 | + |
| 3 | +This document provides information about developing, testing, and releasing the MLflow application using the included Taskfile. |
| 4 | + |
| 5 | +## Development Workflow |
| 6 | + |
| 7 | +The MLflow application includes a Taskfile.yml that provides tasks for developing, testing, and publishing the application. |
| 8 | + |
| 9 | +### Prerequisites |
| 10 | + |
| 11 | +- [Task](https://taskfile.dev/#/installation) command line tool |
| 12 | +- Kubernetes cluster configured in your current context |
| 13 | +- kubectl, helm, and python3 installed |
| 14 | + |
| 15 | +### Local Development |
| 16 | + |
| 17 | +Follow this workflow for development: |
| 18 | + |
| 19 | +1. Add required Helm repositories and update dependencies: |
| 20 | + ```bash |
| 21 | + task add:repos:helm |
| 22 | + task update:deps:helm |
| 23 | + ``` |
| 24 | + |
| 25 | +2. Lint charts to check for issues: |
| 26 | + ```bash |
| 27 | + task lint |
| 28 | + ``` |
| 29 | + |
| 30 | +3. Template charts to verify the rendered manifests: |
| 31 | + ```bash |
| 32 | + task template |
| 33 | + ``` |
| 34 | + |
| 35 | +4. Install charts for development: |
| 36 | + ```bash |
| 37 | + # Installs with Replicated SDK disabled |
| 38 | + task install:helm:local |
| 39 | + |
| 40 | + # Optionally specify a custom values file |
| 41 | + MLFLOW_VALUES=./my-values.yaml task install:helm:local |
| 42 | + ``` |
| 43 | + |
| 44 | + > **Note:** For local development, the Replicated SDK is explicitly disabled (`replicated.enabled=false`). This allows development without requiring access to the Replicated platform. |
| 45 | + > |
| 46 | + > This task automatically sets up port forwarding from localhost:5000 to the MLflow service in the cluster, making the application available for testing. |
| 47 | + > |
| 48 | + > The Helm releases are created with names `infra` and `mlflow` in the `mlflow` namespace. |
| 49 | +
|
| 50 | +5. Run application tests: |
| 51 | + ```bash |
| 52 | + task run:tests:app |
| 53 | + ``` |
| 54 | + |
| 55 | +6. Make changes to your charts and repeat steps 2-5 as needed |
| 56 | + |
| 57 | +This workflow allows rapid iteration without needing to publish to the Replicated registry. |
| 58 | + |
| 59 | +### Task Reference |
| 60 | + |
| 61 | +Tasks follow a `verb:resource[:subresource]` naming convention for clarity: |
| 62 | + |
| 63 | +```bash |
| 64 | +# Validation and verification |
| 65 | +task lint # Lint Helm charts |
| 66 | +task template # Render templates to stdout (SDK disabled) |
| 67 | +task check:versions # Verify Chart.yaml and KOTS manifest versions match |
| 68 | + |
| 69 | +# Repository and dependency management |
| 70 | +task add:repos:helm # Add required Helm repositories |
| 71 | +task update:deps:helm # Update Helm chart dependencies |
| 72 | + |
| 73 | +# Packaging and versioning |
| 74 | +task update:versions:chart # Update chart version refs in KOTS manifests |
| 75 | +task package:charts # Package Helm charts for distribution |
| 76 | +task extract:version:chart # Extract current MLflow chart version |
| 77 | + |
| 78 | +# Installation |
| 79 | +task install:helm:local # Install charts for local development (SDK disabled) |
| 80 | + |
| 81 | +# Testing |
| 82 | +task test:install:helm # Test with charts from Replicated registry |
| 83 | +task test:install:kots # Test KOTS installation |
| 84 | +task run:tests:app # Run application tests against running MLflow |
| 85 | +task run:tests:all # Run all tests (Helm install + app tests) |
| 86 | + |
| 87 | +# Release management |
| 88 | +task create:release # Create a Replicated release |
| 89 | + |
| 90 | +# Cleanup |
| 91 | +task clean:files:charts # Clean packaged chart files |
| 92 | +task clean:all # Clean all generated files |
| 93 | +``` |
| 94 | + |
| 95 | +## Releasing |
| 96 | + |
| 97 | +### Updating Documentation |
| 98 | + |
| 99 | +Before creating a release, ensure the documentation is up-to-date: |
| 100 | + |
| 101 | +1. Update version information in `charts/mlflow/Chart.yaml` if needed. |
| 102 | + |
| 103 | +2. Update the changelog in `charts/mlflow/README_CHANGELOG.md.gotmpl` with details about the new release. |
| 104 | + |
| 105 | +3. Generate documentation using helm-docs: |
| 106 | + ```bash |
| 107 | + # From the mlflow chart directory |
| 108 | + cd charts/mlflow |
| 109 | + |
| 110 | + # If helm-docs is installed locally |
| 111 | + helm-docs |
| 112 | + |
| 113 | + # Or use Docker |
| 114 | + docker run --rm -v "$(pwd):/helm-docs" -u $(id -u) jnorwood/helm-docs:latest |
| 115 | + ``` |
| 116 | + |
| 117 | +4. Verify the generated documentation: |
| 118 | + - `README.md` - Main chart documentation |
| 119 | + - `README_CHANGELOG.md` - Changelog |
| 120 | + - `README_CONFIG.md` - Configuration reference |
| 121 | + |
| 122 | +### Publishing Replicated Releases |
| 123 | + |
| 124 | +When you're ready to publish your changes to the Replicated platform: |
| 125 | + |
| 126 | +1. Update the version in `charts/mlflow/Chart.yaml` if necessary. |
| 127 | + |
| 128 | +2. Update documentation: |
| 129 | + ```bash |
| 130 | + # If helm-docs is not installed |
| 131 | + cd charts/mlflow |
| 132 | + docker run --rm -v "$(pwd):/helm-docs" -u $(id -u) jnorwood/helm-docs:latest |
| 133 | + ``` |
| 134 | + |
| 135 | +3. Set up the required environment variables: |
| 136 | + ```bash |
| 137 | + # Replicated API token for authentication |
| 138 | + export REPLICATED_API_TOKEN=your_api_token |
| 139 | + |
| 140 | + # App and channel to publish to |
| 141 | + export REPLICATED_APP=app_slug |
| 142 | + export REPLICATED_CHANNEL=channel_name |
| 143 | + ``` |
| 144 | + |
| 145 | +4. Package the charts and update version references: |
| 146 | + ```bash |
| 147 | + # This updates KOTS manifests with the current chart versions |
| 148 | + # and packages the charts as .tgz files |
| 149 | + task package:charts |
| 150 | + ``` |
| 151 | + |
| 152 | +5. Create a release in Replicated: |
| 153 | + ```bash |
| 154 | + # This uploads the packaged charts and creates a new release |
| 155 | + task create:release |
| 156 | + ``` |
| 157 | + |
| 158 | +6. Verify the release was created successfully in the Replicated vendor portal |
| 159 | + |
| 160 | +### Testing Replicated Releases |
| 161 | + |
| 162 | +This workflow tests the full Replicated release and distribution process: |
| 163 | + |
| 164 | +1. After publishing a release, login to the registry with a license ID: |
| 165 | + ```bash |
| 166 | + # Set license ID for registry authentication |
| 167 | + export REPLICATED_LICENSE_ID=your_license_id |
| 168 | + export REPLICATED_APP=app_slug |
| 169 | + export REPLICATED_CHANNEL=channel_name |
| 170 | + |
| 171 | + # Login to the registry |
| 172 | + task login:registry |
| 173 | + ``` |
| 174 | + |
| 175 | +2. Test the Helm installation from the Replicated registry: |
| 176 | + ```bash |
| 177 | + # This pulls charts from the Replicated registry with SDK enabled |
| 178 | + task test:install:helm |
| 179 | + ``` |
| 180 | + |
| 181 | + > **Note:** This creates Helm releases named `infra` and `mlflow` in the `mlflow` namespace. |
| 182 | +
|
| 183 | +3. Verify the installation with application tests: |
| 184 | + ```bash |
| 185 | + task run:tests:app |
| 186 | + ``` |
| 187 | + |
| 188 | +You can also run the complete test suite after setting up environment variables: |
| 189 | +```bash |
| 190 | +task run:tests:all |
| 191 | +``` |
| 192 | + |
| 193 | +This workflow validates the entire release pipeline from publishing to installation, ensuring that your charts work correctly when distributed through the Replicated platform. |
| 194 | + |
| 195 | +## CI/CD Pipeline |
| 196 | + |
| 197 | +This application includes a CI/CD pipeline implemented with GitHub Actions. The pipeline handles: |
| 198 | + |
| 199 | +- Linting and validating Helm chart templates |
| 200 | +- Creating releases in Replicated |
| 201 | +- Testing Helm installation with charts from the Replicated registry |
| 202 | +- Installing the application via KOTS |
| 203 | + |
| 204 | +The pipeline workflow: |
| 205 | +1. `lint-and-template`: Validates chart syntax and templates (SDK disabled) |
| 206 | +2. `create-release`: Packages charts and creates a release in Replicated |
| 207 | +3. `helm-install-test`: Tests Helm installation with charts from Replicated registry (SDK enabled) |
| 208 | +4. `kots-install-test`: Tests KOTS installation |
| 209 | +5. `cleanup-test-release`: Cleans up test resources |
| 210 | + |
| 211 | +The pipeline is triggered on: |
| 212 | +- Pull requests affecting the MLflow application |
| 213 | +- Pushes to the main branch |
| 214 | + |
| 215 | +For more details, see the workflow definition in [.github/workflows/mlflow-ci.yml](../../.github/workflows/mlflow-ci.yml). |
0 commit comments