Metadata-Version: 2.4
Name: pumpwood-deploy-static-pages
Version: 0.0.1
Summary: Package to assist deploy Pumpwood static pages on K8s
License: BSD-3-Clause License
License-File: LICENSE
Author: André Andrade Baceti
Author-email: a.baceti@murabei.com
Requires-Python: >=3.6
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Dist: pumpwood-deploy
Project-URL: Homepage, https://github.com/Murabei-OpenSource-Codes/pumpwood-deploy-static-pages
Description-Content-Type: text/markdown

# pumpwood-deploy-static-pages

Satellite deploy package for **Pumpwood static page** containers on
Kubernetes. It generates Deployment and Service manifests for nginx-style
static images on port 80 — then hands them to
[`pumpwood-deploy`](https://github.com/Murabei-OpenSource-Codes/pumpwood-deploy)
for apply.

Developed by [Murabei Data Science](https://murabei.com). BSD-3-Clause.

<p align="center" width="60%">
  <img src="static_doc/sitelogo-horizontal.png" /> <br>

  <a href="https://en.wikipedia.org/wiki/Cecropia">
    Pumpwood is a native Brazilian tree
  </a> with a symbiotic relation to ants (Murabei)
</p>

---

## What it deploys

| Manifest | Kubernetes resources |
|----------|----------------------|
| `pumpwood_static_pages__{image}` | Deployment + Service `pumpwood-static-pages--{image}` |

Add one ``PumpWoodStaticPagesMicroservice`` per static page image. Each
instance renders a single manifest file containing both the Deployment
and the ClusterIP Service listening on port 80.

```mermaid
flowchart LR
    subgraph pkg [pumpwood-deploy-static-pages]
        A[PumpWoodStaticPagesMicroservice]
    end
    subgraph core [pumpwood-deploy]
        B[DeployPumpWood]
    end
    subgraph cluster [Cluster]
        SP[pumpwood-static-pages--image]
        LB[load-balancer / Kong]
    end
    A --> B
    B --> SP
    SP --> LB
```

---

## Prerequisites

This package does **not** stand alone. Before static page pods can
start, the cluster should already provide:

| Resource | Provided by |
|----------|-------------|
| `dockercfg` image pull secret | Cluster or `DeployPumpWood` setup |
| API gateway / ingress (typical) | [`pumpwood-deploy-ingress-api-gateway`](https://github.com/Murabei-OpenSource-Codes/pumpwood-deploy-ingress-api-gateway) or AWS ALB |

No Postgres, RabbitMQ, or package-level Secret is required. The pod sets
``SERVICE_HOST`` to the in-cluster service name
``pumpwood-static-pages--{image}``.

---

## Installation

```bash
pip install pumpwood-deploy-static-pages
```

Requires `pumpwood-deploy`.

---

## Quick start

```python
import os
import simplejson as json
from dotenv import load_dotenv
from pumpwood_deploy.deploy import DeployPumpWood
from pumpwood_deploy_static_pages import (
    PumpWoodStaticPagesMicroservice)

with open("secrets/production.json", "r") as file:
    secrets = json.loads(file.read())
load_dotenv()

deploy = DeployPumpWood(
    model_user_password=secrets["microservices--model"],
    rabbitmq_secret=secrets["rabbitmq_secret"],
    hash_salt=secrets["hash_salt"],
    k8_provider="aws",
    k8_deploy_args={
        "region": "us-east-1",
        "cluster_name": "my-cluster",
    },
    k8_namespace="pumpwood",
)

deploy.add_microservice(
    PumpWoodStaticPagesMicroservice(
        image="pumpwood-docs-static",
        version=os.getenv("PUMPWOOD_DOCS_STATIC"),
        repository="my-registry.example.com",
        replicas=1,
    ))

deploy.add_microservice(
    PumpWoodStaticPagesMicroservice(
        image="pumpwood-help-static",
        version=os.getenv("PUMPWOOD_HELP_STATIC"),
        repository="my-registry.example.com",
    ))

deploy.create_deploy_files()
deploy.deploy_microservices()
```

### Environment variables

```bash
PUMPWOOD_DOCS_STATIC=1.0.0
PUMPWOOD_HELP_STATIC=1.0.0
```

If the rendered manifest matches what is already on the cluster, `kubectl
apply` produces no changes — safe for rolling image updates.

---

## Configuration reference

### Required

| Parameter | Description |
|-----------|-------------|
| `image` | Docker image name (also used in K8s resource names) |
| `version` | Container image tag |

### Optional

| Parameter | Default | Description |
|-----------|---------|-------------|
| `repository` | GCR default | Docker registry |
| `replicas` | `1` | Number of pod replicas |
| `requests_memory` | `20Mi` | Memory request |
| `requests_cpu` | `1m` | CPU request |
| `limits_memory` | `512Mi` | Memory limit |
| `limits_cpu` | `500m` | CPU limit |

---

## Networking

Each Service exposes port **80** and targets container port **80**.
Register routes in Kong or your ingress so traffic reaches
``pumpwood-static-pages--{image}`` inside the namespace.

---

## Related packages

| Package | Role |
|---------|------|
| [`pumpwood-deploy`](https://github.com/Murabei-OpenSource-Codes/pumpwood-deploy) | Orchestrator, Kong, RabbitMQ |
| [`pumpwood-deploy-auth`](https://github.com/Murabei-OpenSource-Codes/pumpwood-deploy-auth) | Authorization microservice |
| [`pumpwood-deploy-frontend`](https://github.com/Murabei-OpenSource-Codes/pumpwood-deploy-frontend) | React UI |
| [`pumpwood-deploy-ingress-api-gateway`](https://github.com/Murabei-OpenSource-Codes/pumpwood-deploy-ingress-api-gateway) | NGINX API gateway |

Full platform documentation:
[Murabei Open Source — pumpwood-deploy](https://murabei-opensource-codes.github.io/pumpwood-deploy/).

---

## Development

```bash
pip install -e ../pumpwood-deploy
pip install -e .

PYTHONPATH="src:../pumpwood-deploy/src" python3 -c "
from pumpwood_deploy_static_pages import PumpWoodStaticPagesMicroservice
PumpWoodStaticPagesMicroservice('docs-static', '1.0.0').create_deployment_file()
"

ruff check src/
```

---

## License

BSD-3-Clause — see [LICENSE](LICENSE).

