|
| 1 | + |
| 2 | +# Lab 10 — Helm Package Manager |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +> Package your Kubernetes applications with Helm for reusable, configurable deployments across environments. |
| 10 | +
|
| 11 | +--- |
| 12 | + |
| 13 | +## Chart Overview |
| 14 | + |
| 15 | +This Helm chart (`myapp`) converts Kubernetes manifests from Lab 9 into a reusable, configurable deployment system. |
| 16 | + |
| 17 | +### Structure |
| 18 | + |
| 19 | +``` |
| 20 | +
|
| 21 | +myapp/ |
| 22 | +├── Chart.yaml |
| 23 | +├── values.yaml |
| 24 | +├── values-dev.yaml |
| 25 | +├── values-prod.yaml |
| 26 | +└── templates/ |
| 27 | +├── deployment.yaml |
| 28 | +├── service.yaml |
| 29 | +└── hooks/ |
| 30 | +├── pre-install-job.yaml |
| 31 | +└── post-install-job.yaml |
| 32 | +
|
| 33 | +```` |
| 34 | +
|
| 35 | +### Key Components |
| 36 | +
|
| 37 | +- **Deployment template** — runs the Python application with configurable replicas, image, and resources |
| 38 | +- **Service template** — exposes the application inside cluster (NodePort / ClusterIP) |
| 39 | +- **Values files** — environment-based configuration (dev/prod) |
| 40 | +- **Hooks** — lifecycle jobs executed before and after deployment |
| 41 | +
|
| 42 | +--- |
| 43 | +
|
| 44 | +## Configuration Guide |
| 45 | +
|
| 46 | +### Main values (`values.yaml`) |
| 47 | +
|
| 48 | +- `replicaCount` — number of pods |
| 49 | +- `image.repository` — Docker image name |
| 50 | +- `image.tag` — image version |
| 51 | +- `service.port` — exposed port |
| 52 | +- `service.targetPort` — container port (5000) |
| 53 | +- `resources` — CPU/memory limits |
| 54 | +- `livenessProbe` — health check configuration |
| 55 | +- `readinessProbe` — readiness check configuration |
| 56 | +
|
| 57 | +### Dev environment (`values-dev.yaml`) |
| 58 | +
|
| 59 | +- 1 replica |
| 60 | +- lightweight CPU/memory limits |
| 61 | +- NodePort service |
| 62 | +- relaxed probes |
| 63 | +
|
| 64 | +### Prod environment (`values-prod.yaml`) |
| 65 | +
|
| 66 | +- 3–5 replicas |
| 67 | +- higher resource limits |
| 68 | +- LoadBalancer-ready configuration |
| 69 | +- stricter probes |
| 70 | +
|
| 71 | +### Example usage |
| 72 | +
|
| 73 | +```bash |
| 74 | +helm install myapp-dev ./myapp -f values-dev.yaml |
| 75 | +helm install myapp-prod ./myapp -f values-prod.yaml |
| 76 | +```` |
| 77 | +
|
| 78 | +--- |
| 79 | +
|
| 80 | +## Hook Implementation |
| 81 | +
|
| 82 | +### Pre-install hook |
| 83 | +
|
| 84 | +Executes before deployment starts. |
| 85 | +
|
| 86 | +* Used for initialization / validation |
| 87 | +* Runs a Kubernetes Job |
| 88 | +
|
| 89 | +### Post-install hook |
| 90 | +
|
| 91 | +Executes after deployment completes. |
| 92 | +
|
| 93 | +* Used for smoke tests or verification |
| 94 | +* Confirms application readiness |
| 95 | +
|
| 96 | +### Hook execution order |
| 97 | +
|
| 98 | +``` |
| 99 | +Pre-install → Deploy resources → Post-install |
| 100 | +``` |
| 101 | +
|
| 102 | +### Hook weights |
| 103 | +
|
| 104 | +* `-5` → pre-install (runs first) |
| 105 | +* `5` → post-install (runs last) |
| 106 | +
|
| 107 | +### Deletion policy |
| 108 | +
|
| 109 | +Hooks are configured with: |
| 110 | +
|
| 111 | +``` |
| 112 | +hook-delete-policy: hook-succeeded |
| 113 | +``` |
| 114 | +
|
| 115 | +This ensures: |
| 116 | +
|
| 117 | +* cleanup after successful execution |
| 118 | +* no leftover Jobs in cluster |
| 119 | +
|
| 120 | +--- |
| 121 | +
|
| 122 | +## Installation Evidence |
| 123 | +
|
| 124 | +### Helm release list |
| 125 | +
|
| 126 | +```bash |
| 127 | +helm list |
| 128 | +``` |
| 129 | + |
| 130 | +📸 Screenshot: `lab10-set.png` |
| 131 | + |
| 132 | +--- |
| 133 | + |
| 134 | +### Kubernetes resources |
| 135 | + |
| 136 | +```bash |
| 137 | +kubectl get all |
| 138 | +``` |
| 139 | + |
| 140 | +📸 Screenshot: `lab10-set.png` |
| 141 | + |
| 142 | +--- |
| 143 | + |
| 144 | +### Application running |
| 145 | + |
| 146 | +```bash |
| 147 | +kubectl get pods |
| 148 | +kubectl get svc |
| 149 | +``` |
| 150 | + |
| 151 | +📸 Screenshot: `lab10-app.png` |
| 152 | + |
| 153 | +--- |
| 154 | + |
| 155 | +### Hooks execution |
| 156 | + |
| 157 | +```bash |
| 158 | +kubectl get jobs |
| 159 | +kubectl logs job/<pre-install-job> |
| 160 | +kubectl logs job/<post-install-job> |
| 161 | +``` |
| 162 | + |
| 163 | +📸 Screenshot: `lab10-hooks.png` |
| 164 | + |
| 165 | +--- |
| 166 | + |
| 167 | +## Operations |
| 168 | + |
| 169 | +### Install |
| 170 | + |
| 171 | +```bash |
| 172 | +helm install myapp-release ./myapp |
| 173 | +``` |
| 174 | + |
| 175 | +### Upgrade |
| 176 | + |
| 177 | +```bash |
| 178 | +helm upgrade myapp-release ./myapp |
| 179 | +``` |
| 180 | + |
| 181 | +### Rollback |
| 182 | + |
| 183 | +```bash |
| 184 | +helm rollback myapp-release 1 |
| 185 | +``` |
| 186 | + |
| 187 | +### Uninstall |
| 188 | + |
| 189 | +```bash |
| 190 | +helm uninstall myapp-release |
| 191 | +``` |
| 192 | + |
| 193 | +--- |
| 194 | + |
| 195 | +## Testing & Validation |
| 196 | + |
| 197 | +### Chart validation |
| 198 | + |
| 199 | +```bash |
| 200 | +helm lint ./myapp |
| 201 | +``` |
| 202 | + |
| 203 | +### Template rendering |
| 204 | + |
| 205 | +```bash |
| 206 | +helm template myapp ./myapp |
| 207 | +``` |
| 208 | + |
| 209 | +### Dry-run install |
| 210 | + |
| 211 | +```bash |
| 212 | +helm install test ./myapp --dry-run --debug |
| 213 | +``` |
| 214 | + |
| 215 | +### Result |
| 216 | + |
| 217 | +* Deployment successfully created |
| 218 | +* Service exposed via NodePort |
| 219 | +* Application accessible in browser via `http://localhost:8080` |
| 220 | + |
| 221 | +--- |
| 222 | + |
| 223 | +## Summary |
| 224 | + |
| 225 | +This Helm chart demonstrates: |
| 226 | + |
| 227 | +* templating Kubernetes manifests |
| 228 | +* environment-based configuration |
| 229 | +* lifecycle hooks (pre/post install) |
| 230 | +* production-ready structure |
| 231 | +* reusable deployment patterns |
| 232 | + |
| 233 | +Helm significantly improves maintainability, scalability, and repeatability of Kubernetes deployments. |
| 234 | + |
| 235 | +--- |
| 236 | + |
| 237 | +## Screenshots |
| 238 | + |
| 239 | +### Cluster setup & Helm state |
| 240 | + |
| 241 | + |
| 242 | + |
| 243 | +### Application running |
| 244 | + |
| 245 | + |
| 246 | + |
| 247 | +### Hooks execution |
| 248 | + |
| 249 | + |
0 commit comments