Backend API for managing Helm chart installations on a K3s cluster, simulating an app store experience.
- Prerequisites
- Project Structure
- Configuration
- Getting Started
- Building
- Docker
- API Endpoints
- Kubernetes Deployment
- Contributing
- Go (version specified in
go.mod, e.g., 1.24) - Docker
- kubectl
- Helm CLI (v3+)
- A running Kubernetes cluster (e.g., K3s, Minikube, Docker Desktop K8s)
- Access to
charts.yaml(local or via ConfigMap)
cmd/appstore/main.go: Main application entry point.pkg/: Contains core packages:api/: HTTP handlers, routes, middleware.appcatalog/: Logic for managing the chart catalog.config/: Application configuration management.helm/: Helm and Kubernetes client interaction logic.
charts.yaml: Defines the list of available Helm charts for the store.Dockerfile: For building the application Docker image.k8s/: Kubernetes manifest files for deployment.
The application is configured via environment variables. See pkg/config/config.go for details. Key variables:
APP_PORT: Port the API listens on (default:8080).GIN_MODE: Gin framework mode (debugorrelease, default:debug).APP_INSTALL_NAMESPACE: Kubernetes namespace where charts will be installed (default:app-store-apps).KUBECONFIG: Path to the kubeconfig file (tries in-cluster config first, then default path).HELM_DRIVER: Helm storage driver (default:secret).HELM_TIMEOUT_SECONDS: Timeout for Helm operations (default:300).CHART_CONFIG_PATH: Path to the chart catalog definition file (default:charts.yaml).
The charts.yaml file at the root (or specified by CHART_CONFIG_PATH) defines the applications available in the
store.
-
Clone the repository:
git clone https://github.com/YOUR_USERNAME/app-store-api.git cd app-store-api -
Ensure KUBECONFIG is set: Make sure your
KUBECONFIGenvironment variable points to a valid Kubernetes cluster, or that~/.kube/configis set up. The API needs to interact with a K8s cluster. -
Install dependencies:
go mod tidy
-
Run the application:
go run ./cmd/appstore/main.go
The API will start, typically on port 8080. Check logs for the exact address and any initialization errors.
For local development, you might want to set
GIN_MODE=debug.
To build the binary:
go build -o app-store-api ./cmd/appstore/main.goTo build the Docker image:
docker build -t app-store-api:latest .To run the Docker image (example, assuming KUBECONFIG is mounted and network configured):
docker run -p 8080:8080 \
-v ~/.kube/config:/root/.kube/config:ro \
--env APP_INSTALL_NAMESPACE=my-apps \
app-store-api:latestNote: For running locally with Docker, ensure the Kubernetes context in the mounted kubeconfig points to a reachable cluster from the Docker container's perspective (e.g., host.docker.internal or an external IP).
(Refer to pkg/api/routes.go for detailed routes)
GET /health: Health check.GET /api/charts: List available charts.POST /api/charts/:chartName/install: Install a chart.- Body (JSON, optional):
{"release_name": "custom-name", "values": {"key": "value"}}
- Body (JSON, optional):
GET /api/releases: List installed releases.GET /api/releases/:releaseName/status: Get status of a specific release.DELETE /api/releases/:releaseName: Uninstall a release.
Manifests for deploying the API to Kubernetes are located in the k8s/ directory.
- Build and push the Docker image to a registry accessible by your K8s cluster (e.g., GHCR, Docker Hub).
Example for GHCR:
ghcr.io/YOUR_USERNAME/app-store-api:tag - Update the
imagefield ink8s/02-deployment.yamlto point to your pushed image. - Apply the manifests:
kubectl apply -f k8s/00-namespaces.yaml
kubectl apply -f k8s/01-rbac.yaml
# If using charts.yaml via ConfigMap:
# kubectl create configmap chart-config --from-file=charts.yaml -n app-store-api
kubectl apply -f k8s/02-deployment.yaml
kubectl apply -f k8s/03-service.yamlPlease follow Conventional Commits specification for commit messages to enable automated versioning and changelog generation.