infraops

📦 Application deployment

← Back to README

🏗️ Prepare the cluster

Install doctl, kubectl, and the Pulumi CLI. On a new cluster, save kubeconfig if needed, confirm the intended context, and create the lean namespace once.

make -C area/apps save-config
kubectl config current-context
make -C area/apps setup

Once lean exists, install the cluster add-ons. For public Ingresses, set up ingress TLS before the apps update. Preview and apply Cloudflare DNS changes before deploying an app with a new public hostname. Contour’s load balancer allows Cloudflare CIDRs, so use a proxied record for this ingress.

[!CAUTION] make -C area/apps delete deletes the entire lean namespace, including its Secrets and persistent volume claims. See application storage for the effects on retained disks.

⚙️ Deployment configuration

Edit apps.hjson to configure an application’s image version, replicas, resources, and rollout strategy. Pulumi reads area/apps/<namespace>/<app>.yaml into a ConfigMap and mounts it at /etc/<app>/<app>.yaml. A config-only change requires a rollout because existing pods use a subPath mount. The files under area/apps/fiction/ are examples. For YAML fields, service endpoints, and runtime behavior, see the application’s own docs.

Set replicas explicitly. Omission means zero pods. The default rolling strategy allows one extra pod and one unavailable pod. A single replica can become unavailable during rollout or disruption. Use strategy: recreate to terminate old pods before creating replacements during a rollout. Expect downtime with recreate. For workloads that require a single writer, also use one replica and account for possible overlap during pod replacement outside a deployment rollout. See the Application schema and application storage.

NetworkPolicies restrict ingress to each application’s configured ports and allow egress. See the network policy decision.

Application release pipelines bump image versions in apps.hjson. When adding an app, update the release helper with its supported name, verification and rollout commands, and load eligibility. The helper currently supports the lean namespace. See the release handoff for the shared release image.

🔐 Create application Secrets

Create the required <secretName>-secret objects in the app’s namespace before deploying. The apps stack references existing Secrets. Listed volumes mount at /etc/secrets/<secretName>. Environment references of the form secret:<secretName>/<key> select a key from the same named Secret.

The following helpers create Secrets in the existing lean namespace. Supply readable, nonempty credential files outside the repository and confirm your kubeconfig context before running either command.

Abgleich

make -C area/apps abgleich-secret \
  github_app_private_key_file=/absolute/path/to/private-key.pem \
  github_webhook_secret_file=/absolute/path/to/github-webhook-secret \
  openai_api_key_file=/absolute/path/to/openai-api-key

See the deployed YAML for the mounted file paths and Abgleich configuration for service credential requirements.

Einblick

Before rollout, verify that edge access controls restrict both the log browser and the HTTP query API to authorized users. Einblick serves both without an application login.

Apply the Cloudflare stack first. Verify the R2 bucket’s expiration and lock against cf.hjson, then create the credentials with Object Read & Write access scoped to that bucket. See the R2 guide for how rules take effect.

make -C area/apps einblick-secret \
  r2_access_key_id_file=/absolute/path/to/access \
  r2_secret_access_key_file=/absolute/path/to/secret

See the deployed YAML for the mounted file paths and Einblick operations for backup and recovery.

Rotate credentials

Both helpers fail if their Secret already exists. Before replacing a Secret, verify all the new files. If you delete and recreate it, a replacement pod cannot start during the interval when the Secret is absent. Restart the app after rotation so it loads the new credentials.

🧪 Deploy and check

Run the update through Make to record which apps the checks should cover. Install jq for update selection, curl for verification, vegeta for load checks, and kube-score and kubescape for live manifest linting. Kubescape requires access to GitHub policies or a usable local policy cache. Run from the repository root.

make area=apps pulumi-preview
make area=apps pulumi-update
make -C area/apps verify
make -C area/apps load
make -C area/apps lint

The checks use the ignored area/apps/.release-selection.json from the last successful update at the current Git revision. Failed updates and missing, invalid, or stale selections cause the checks to fail.

Update result Check behavior
No relevant resource changes Skip checks
App config or resource changes Check affected apps
Shared or unlabelled resources change Expand to supported apps and namespace-wide manifest scans
App deleted Exclude it from checks
App scaled to zero Lint it and skip verification and load
Unknown app or namespace Fail selection until helper support is added

Verification uses bounded HTTP requests for apps with URL checks. Load checks run for apps with scenarios and require every request to succeed. Load reports are ignored files under area/apps/lean/*.bin. See the release helper for current coverage.

To check an existing deployment independently of the last update, use the *-all targets.

make -C area/apps verify-all
make -C area/apps load-all
make -C area/apps lint-all

lint-all checks live manifests throughout the namespace. The kube-score wrapper leaves replica count and pod placement to operators. The Kubescape wrapper uses the allcontrols framework and reports resource-level findings. The checked-in control settings and exceptions define registry and digest rules and namespace exceptions for SELinux and image signing. Cluster and operator controls excluded by the wrapper still require separate review. When refreshing defaults with kubescape download controls-inputs, preserve imageRepositoryAllowList and imageDigestExemptRepositories because --controls-config replaces defaults. Image and host scans are outside live manifest linting. Use (cd area/apps && ./release images) for changed images, or (cd area/apps && ./release images-all) for all supported apps.

🔄 Restart applications

For a single app, use a command such as (cd area/apps && ./release rollout-web), then check kubectl -n lean rollout status deployment/web. The make -C area/apps rollout target limits restarts to the changed apps when the Git diff contains only app version bumps. Otherwise it restarts all supported apps. It compares the current commit to its parent, falling back to origin/master when the parent is unavailable. Override the comparison with APPS_RELEASE_BASE and APPS_RELEASE_HEAD, or use rollout-all to restart all supported apps explicitly. Post-update checks use the Pulumi selection independently of the Git diff. Set APPS_RELEASE_DRY_RUN=true to print actions. Selective checks still need a valid selection.