Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions deploy-scripts/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
# cp .env.example .env

# Kubernetes Configuration
export NAMESPACE="${NAMESPACE:-hyperfleet-e2e}"

# NAMESPACE must be unique to prevent GCP Pub/Sub topic/subscription collisions.
# GCP resources are named using the namespace (e.g., ${NAMESPACE}-clusters),
# so multiple users sharing the same namespace will interfere with each other's tests.
export NAMESPACE="${NAMESPACE:-hyperfleet-e2e-$(echo ${USER:-default} | tr '[:upper:]' '[:lower:]')}"

# Provider Configuration
export GCP_PROJECT_ID="${GCP_PROJECT_ID:-hcm-hyperfleet}"
Expand Down
43 changes: 22 additions & 21 deletions deploy-scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ Ensure you have:
Install all components with default settings:

```bash
./deploy-scripts/deploy-clm.sh --action install --namespace hyperfleet-e2e
./deploy-scripts/deploy-clm.sh --action install --namespace <unique_namespace>
```

Install with custom image tags:

```bash
./deploy-scripts/deploy-clm.sh --action install \
--namespace my-test-env \
--namespace <unique_namespace> \
--api-image-tag v1.2.0 \
--sentinel-image-tag v1.2.0 \
--adapter-image-tag v1.2.0
Expand All @@ -55,7 +55,7 @@ Install with custom image tags:
Uninstall all components:

```bash
./deploy-scripts/deploy-clm.sh --action uninstall --namespace hyperfleet-e2e
./deploy-scripts/deploy-clm.sh --action uninstall --namespace hyperfleet-e2e-$USER
```

### Option 2: Using .env File (Recommended for Complex Configurations)
Expand All @@ -74,7 +74,7 @@ For easier management of deployment parameters, use a `.env` file:
```

Key parameters you can configure:
- `NAMESPACE` - Kubernetes namespace (default: `hyperfleet-e2e`)
- `NAMESPACE` - Kubernetes namespace (default: `hyperfleet-e2e-$USER`)
- `IMAGE_REGISTRY` - Container image registry
- `API_IMAGE_TAG`, `SENTINEL_IMAGE_TAG`, `ADAPTER_IMAGE_TAG` - Image tags
- `GCP_PROJECT_ID` - Google Cloud Project ID for Pub/Sub
Expand All @@ -84,7 +84,7 @@ For easier management of deployment parameters, use a `.env` file:

3. **Run the deployment:**
```bash
./deploy-clm.sh --action install
./deploy-clm.sh --action install --namespace hyperfleet-e2e-$USER
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

nit — non-blocking suggestion

Category: Inconsistency

Two small doc issues with the namespace examples:

  1. The README mixes <unique_namespace> (placeholder) and hyperfleet-e2e-$USER (literal) without a consistent rule. For example, Quick Start install uses the placeholder but Quick Start uninstall uses the literal. Consider standardizing — either use <unique_namespace> everywhere with a note explaining the convention, or use hyperfleet-e2e-$USER everywhere for copy-pasteable examples.

  2. Option 2 step 3 (line 87) adds --namespace hyperfleet-e2e-$USER to the .env-based workflow, but the whole point of Option 2 is that NAMESPACE is configured in .env. The --namespace CLI flag overrides the .env value, making step 2's config irrelevant. The script's own help text shows the correct pattern:

# Install with .env defaults
deploy-clm.sh --action install

Consider reverting line 87 to just ./deploy-clm.sh --action install (no --namespace) to match the .env-based intent.

```

**Configuration Priority:**
Expand Down Expand Up @@ -114,7 +114,7 @@ For basic usage, see [Quick Start](#quick-start) section above.

| Flag | Description | Default |
|------|-------------|---------|
| `--namespace <namespace>` | Kubernetes namespace for deployment | `hyperfleet-e2e` |
| `--namespace <namespace>` | Kubernetes namespace for deployment | `hyperfleet-e2e-$USER` |
| `--dry-run` | Print commands without executing | `false` |
| `--verbose` | Enable verbose logging | `false` |
| `--help` | Show help message | - |
Expand Down Expand Up @@ -151,7 +151,7 @@ For basic usage, see [Quick Start](#quick-start) section above.
#### 1. Install with Default Settings

```bash
./deploy-scripts/deploy-clm.sh --action install --namespace hyperfleet-e2e
./deploy-scripts/deploy-clm.sh --action install --namespace hyperfleet-e2e-$USER
```

This installs all three components (API, Sentinel, Adapter) with default configurations.
Expand All @@ -160,15 +160,15 @@ This installs all three components (API, Sentinel, Adapter) with default configu

```bash
./deploy-scripts/deploy-clm.sh --action install \
--namespace test-env \
--namespace <unique_namespace> \
--skip-adapter
```

#### 3. Install with Custom Image Tags

```bash
./deploy-scripts/deploy-clm.sh --action install \
--namespace staging \
--namespace <unique_namespace> \
--api-image-tag v1.2.0 \
--sentinel-image-tag v1.2.0 \
--adapter-image-tag v1.2.0
Expand All @@ -178,7 +178,7 @@ This installs all three components (API, Sentinel, Adapter) with default configu

```bash
./deploy-scripts/deploy-clm.sh --action install \
--namespace dev-test \
--namespace <unique_namespace> \
--api-image-repo myregistry.io/hyperfleet-api \
--api-image-tag pr-123
```
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Expand All @@ -187,7 +187,7 @@ This installs all three components (API, Sentinel, Adapter) with default configu

```bash
./deploy-scripts/deploy-clm.sh --action install \
--namespace test \
--namespace <unique_namespace> \
--dry-run \
--verbose
```
Expand All @@ -199,7 +199,7 @@ This simulates the installation without making any actual changes.
#### 1. Uninstall All Components

```bash
./deploy-scripts/deploy-clm.sh --action uninstall --namespace hyperfleet-e2e
./deploy-scripts/deploy-clm.sh --action uninstall --namespace <unique_namespace>
```

This removes all Helm releases.
Expand All @@ -208,7 +208,7 @@ This removes all Helm releases.

```bash
./deploy-scripts/deploy-clm.sh --action uninstall \
--namespace test-env \
--namespace <unique_namespace> \
--dry-run \
--verbose
```
Expand All @@ -217,7 +217,7 @@ This removes all Helm releases.

```bash
./deploy-scripts/deploy-clm.sh --action uninstall \
--namespace test-env \
--namespace <unique_namespace> \
--skip-api \
--skip-sentinel
```
Expand Down Expand Up @@ -251,15 +251,16 @@ The script leverages Helm's built-in namespace management:

- **Installation**: Namespace is automatically created by Helm using the `--create-namespace` flag
- **Uninstallation**: Resources are removed by `helm uninstall`, but the namespace is **not deleted**
- **Uniqueness**: Each deployment requires a unique namespace to prevent GCP Pub/Sub resource collisions.

If you want to completely remove the namespace after uninstallation:

```bash
# Uninstall components
./deploy-scripts/deploy-clm.sh --action uninstall --namespace test-env
./deploy-scripts/deploy-clm.sh --action uninstall --namespace <unique_namespace>

# Manually delete namespace if desired
kubectl delete namespace test-env
kubectl delete namespace <unique_namespace>
```

This design allows you to:
Expand All @@ -275,7 +276,7 @@ Use `--dry-run --verbose` flags to see what the script would do without making c

```bash
./deploy-scripts/deploy-clm.sh --action install \
--namespace test \
--namespace <unique_namespace> \
--dry-run \
--verbose
```
Expand All @@ -291,7 +292,7 @@ kubectl logs -n <namespace> <pod-name>
View script execution with bash trace:

```bash
bash -x deploy-scripts/deploy-clm.sh --action install --namespace test
bash -x deploy-scripts/deploy-clm.sh --action install --namespace <unique_namespace>
```

## Integration with E2E Tests
Expand All @@ -302,10 +303,10 @@ Before running E2E tests, deploy the CLM components:

```bash
# Deploy test environment
./deploy-scripts/deploy-clm.sh --action install --namespace e2e-test
./deploy-scripts/deploy-clm.sh --action install --namespace <unique_namespace>

# Configure E2E test API URL
EXTERNAL_IP=$(kubectl get svc hyperfleet-api -n $NAMESPACE_NAME -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
EXTERNAL_IP=$(kubectl get svc hyperfleet-api -n $NAMESPACE -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
export HYPERFLEET_API_URL="http://${EXTERNAL_IP}:8000"

# Run E2E tests
Expand All @@ -317,7 +318,7 @@ export HYPERFLEET_API_URL="http://${EXTERNAL_IP}:8000"
After tests complete:

```bash
./deploy-scripts/deploy-clm.sh --action uninstall --namespace e2e-test
./deploy-scripts/deploy-clm.sh --action uninstall --namespace <unique_namespace>
```

## Script Output
Expand Down
64 changes: 41 additions & 23 deletions deploy-scripts/deploy-clm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
# (API, Sentinel, and Adapters) using Helm for E2E testing environments.
#
# Usage:
# ./deploy-clm.sh --action install --namespace hyperfleet-e2e
# ./deploy-clm.sh --action uninstall --namespace hyperfleet-e2e --dry-run
# ./deploy-clm.sh --action install --namespace <unique_namespace>
# ./deploy-clm.sh --action uninstall --namespace <unique_namespace> --dry-run
#
# Set NAMESPACE in .env file or use --namespace flag.
# Each deployment requires a unique namespace to prevent GCP Pub/Sub resource collisions.

set -euo pipefail

Expand Down Expand Up @@ -38,7 +41,7 @@ fi
# ============================================================================

ACTION="${ACTION:-}"
NAMESPACE="${NAMESPACE:-hyperfleet-e2e}"
NAMESPACE="${NAMESPACE:-}"
DRY_RUN="${DRY_RUN:-false}"
VERBOSE="${VERBOSE:-false}"

Expand Down Expand Up @@ -124,13 +127,16 @@ Automated deployment script for HyperFleet CLM components (API, Sentinel, Adapte

CONFIGURATION:
This script loads configuration from ${SCRIPT_DIR}/.env file.
You can override any .env value using command-line flags.
Command-line flags override .env values.

NAMESPACE should be unique to prevent GCP Pub/Sub collisions.
Recommended: set NAMESPACE=hyperfleet-e2e-\$USER in .env file.

REQUIRED FLAGS:
--action <action> Action to perform: install or uninstall

OPTIONAL FLAGS:
--namespace <namespace> Kubernetes namespace (default: hyperfleet-e2e)
--namespace <namespace> Kubernetes namespace (default from .env: ${NAMESPACE})

# Component Selection
--skip-api Skip API installation
Expand Down Expand Up @@ -187,38 +193,37 @@ ENVIRONMENT VARIABLES:
- API_ADAPTERS_NODEPOOL Adapters for API nodepool config (set per test case)

EXAMPLES:
# Install all components with default settings
${0##*/} --action install --namespace hyperfleet-e2e
# Install with .env defaults
${0##*/} --action install

# Install with explicit namespace
${0##*/} --action install --namespace <unique_namespace>

# Install with custom image tags
${0##*/} --action install \\
--namespace test-env \\
--namespace <unique_namespace> \\
--api-image-tag v1.0.0 \\
--sentinel-image-tag v1.0.0 \\
--adapter-image-tag v1.0.0

# Install only API and Sentinel
${0##*/} --action install --skip-adapter
${0##*/} --action install --namespace <unique_namespace> --skip-adapter

# Dry-run uninstallation
${0##*/} --action uninstall --namespace hyperfleet-e2e --dry-run --verbose
# Dry-run to preview actions
${0##*/} --action uninstall --namespace <unique_namespace> --dry-run --verbose

# Delete Kubernetes resources (Helm releases + namespace)
${0##*/} --action uninstall --namespace hyperfleet-e2e --delete-k8s-resources
# Delete Kubernetes resources
${0##*/} --action uninstall --namespace <unique_namespace> --delete-k8s-resources

# Delete GCP Pub/Sub resources (topics and subscriptions)
${0##*/} --action uninstall --namespace hyperfleet-e2e --delete-cloud-resources
# Delete GCP Pub/Sub resources
${0##*/} --action uninstall --namespace <unique_namespace> --delete-cloud-resources

# Complete cleanup: delete everything (k8s + cloud resources)
${0##*/} --action uninstall --namespace hyperfleet-e2e --all
# Complete cleanup: delete everything
${0##*/} --action uninstall --namespace <unique_namespace> --all

# Or explicitly specify both
${0##*/} --action uninstall --namespace hyperfleet-e2e \\
--delete-k8s-resources \\
--delete-cloud-resources

# Install with custom image repositories
# Install with custom image repository
${0##*/} --action install \\
--namespace <unique_namespace> \\
--api-image-repo myregistry.io/hyperfleet-api \\
--api-image-tag dev-123

Expand Down Expand Up @@ -352,6 +357,19 @@ parse_arguments() {
exit 1
fi

# Validate NAMESPACE variable is set
if [[ -z "${NAMESPACE}" ]]; then
log_error "Missing required flag: --namespace or env variable NAMESPACE"
echo
print_usage
exit 1
fi
Comment thread
coderabbitai[bot] marked this conversation as resolved.

if (( ${#NAMESPACE} > 63 )) || [[ ! "${NAMESPACE}" =~ ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ ]]; then
log_error "Invalid namespace: '${NAMESPACE}'. Must match DNS-1123 label format and be <= 63 chars."
exit 1
fi

if [[ "${ACTION}" != "install" && "${ACTION}" != "uninstall" ]]; then
log_error "Invalid action: ${ACTION}. Must be 'install' or 'uninstall'"
exit 1
Expand Down