MicroticaMicrotica

Applications (SDK)

Deploy, scale, and inspect Kubernetes applications with the SDK's apps namespace, including the scaling helpers that merge config safely.

The apps namespace manages applications deployed to Kubernetes — the microservices running inside your environments' clusters.

Locating an app

Many methods take an AppLocator that pins an app to a cluster and namespace:

TypeScript
const locator = {
  name: "api",
  clusterId: "ck-1",
  namespace: "microtica",
  projectId,
};

When you don't know the cluster and namespace, findDeployments resolves them. Scope it to one environment, or search the whole project:

TypeScript
const matches = await microtica.apps.findDeployments("api", projectId, { env: envId });
// [{ clusterId, namespace, envId, imageRepository, registry, version }]

Methods

MethodReturns
apps.listInEnv(envId, projectId)Apps in an environment, grouped by namespace.
apps.listInProject(projectId)Apps across the whole project.
apps.get(name, projectId, version?)One app's microservice document.
apps.getStatus(locator)Pod-level deployment status.
apps.findDeployments(name, projectId, opts?)Where an app is deployed.
apps.getScaling(locator)Current CPU, memory, and replica settings.
apps.updateScaling(locator, overrides, opts?)Merge scaling changes and redeploy.
apps.deployApp(decl)Apply an app to its cluster.
apps.declare(decl)Register an app and config without applying.
apps.updateConfig(decl)Update stored config without redeploying.
apps.lastDeploy(name, projectId, opts?)The app's most recent deploy to an env.
apps.logs(projectId, name, opts?)An app log stream.

Scale an app

getScaling reads the current settings; updateScaling merges your overrides onto them and redeploys. The values are integers — millicores for CPU, MiB for memory.

TypeScript
const current = await microtica.apps.getScaling(locator);
// { cpu: 500, memory: 512, minReplicas: 1, maxReplicas: 3, … }

const { previous, current: updated } = await microtica.apps.updateScaling(
  locator,
  { cpu: 1000, maxCpu: 1000, memory: 1024, maxMemory: 2048 },
  { envId },
);

updateScaling round-trips sensitive config entries safely and validates the result before deploying — it throws a kind: "validation" error if the CPU request would exceed its limit, or minReplicas would exceed maxReplicas. The AppScaling shape covers cpu, maxCpu, memory, maxMemory, minReplicas, maxReplicas, cpuUtilization, and memoryUtilization.

Use updateScaling for scaling, not deployApp. It merges against the live config and preserves secrets. A raw deployApp replaces the entire config set on every call.

Deploy an app

deployApp applies an app to its cluster, creating secrets and rolling the deployment. It's idempotent — deploying the image that's already live returns alreadyDeployed: true. declare registers the app without touching the cluster (secrets are dropped and must be re-supplied on the next deploy); updateConfig upserts config without redeploying.

TypeScript
await microtica.apps.deployApp({
  locator,
  request: {
    deployment: {
      image: "<tag-or-url>",
      configurations: [
        { key: "DOMAIN_NAME", value: "api.example.com" },
        { key: "DB_PASSWORD", value: "<secretName:KEY>", sensitive: true },
      ],
    },
  },
});

Find an app's last deploy

lastDeploy returns one curated record of the most recent deploy of an app to an environment, or undefined when nothing matches.

TypeScript
const last = await microtica.apps.lastDeploy("api", projectId, { envId });
// last?.deployedAt, last?.commitSha, last?.status, …

Next steps

On this page