DEV Community

Billy Walker for Kupe Cloud

Posted on Originally published at kupe.cloud

Kupe Apps: production-ready deployments from one resource

Originally published on the Kupe Cloud blog.

Kubernetes already has the pieces of a well-run web service. A rolling update can bring new pods up before it takes old ones away. A readiness probe keeps traffic off a pod until it can answer. An HPA adds pods when CPU climbs, and a topology spread keeps one node drain from taking every copy at once. Each of those is a separate object with its own fields, though, and learning how a Deployment, a Service, a route, a ServiceAccount and an HPA fit together is a lot to ask of someone who wants to ship an API this afternoon.

Kupe Apps is our shortcut through that learning curve. For each environment of your app you describe one resource: the image, the port it listens on, how much CPU and memory it needs and how many copies to run. Kupe turns that into the standard Kubernetes objects, with the defaults we’d set by hand, and deploys them into your Kupe cluster. Releasing a new version, changing a variable or adding pods then becomes an edit to that one resource, in the console, the CLI or Terraform.

What Kupe creates in your cluster

Each environment gets its own namespace, app-<app>-<environment>, and inside it:

  • a Deployment that adds one new pod at a time and removes an old pod only once a new one is ready
  • startup and readiness checks (TCP by default, or an HTTP path you choose) and an optional liveness check
  • pods spread across nodes where the cluster allows it
  • a Service, a ServiceAccount with no API token mounted, and an HTTPS route to a generated address, plus up to five of your own domains
  • an HPA, when you turn autoscaling on

The pods run as non-root with a read-only root filesystem, every Linux capability dropped and privilege escalation off. If your app needs to write scratch files, /tmp is writable.

All of it is ordinary Kubernetes, and you can look at it. kubectl get deploy,svc,httproute,hpa -n app-shop-production shows exactly what Kupe made for the production environment of an app called shop. The app’s settings are the source of truth, so a hand edit made with kubectl gets put back. Make the change through Kupe and the next release carries it.

Releases you can follow and undo

Change the image or a setting and Kupe starts a new release. You can watch it in the Releases tab, and it only counts as successful once every pod is ready on the new version and the address is in place. If a release fails and there’s an earlier successful one, Kupe makes one attempt to bring that release back. The failed release stays in the history with the reason it failed, so you can still see what went wrong once the app is serving again.

Some bugs only show up after a release passes its checks. Restore release puts an earlier release’s image and settings back. Secrets are the exception: old secret values aren’t kept, so the restored release reads your secrets as they are now. The releases and recovery guide covers both paths.

Environments, databases and scaling

Say you’re shipping a small API. Give it staging and production environments, each with its own image, variables, secrets and address. Try a build in staging, open its URL, then deploy the same image to production. Both sit under one app, so when someone asks what’s running where, there’s one place to look.

Connect one of your Kupe managed PostgreSQL databases and its connection URL arrives in DATABASE_URL. Kupe creates the credentials and removes them when you disconnect, and it never changes the database itself. You can also create a database from the app wizard while you set the app up.

Turn on autoscaling and Kupe adds an HPA that scales on average CPU use, between the minimum and maximum pods you choose, up to 10. Leave it off and you set a fixed number of replicas.

The same settings work from a terminal. With no flags, kupe app deploy asks which image to deploy, then which app and environment. In Terraform, an autoscaled production environment looks like this:

resource "kupe_app_environment" "production" {
  app     = kupe_app.shop.name
  name    = "production"
  cluster = "europe"

  runtime = {
    image       = data.kupe_app_image.shop.reference
    port        = 8080
    autoscaling = { min_pods = 2, max_pods = 6 }
  }
}
Enter fullscreen mode Exit fullscreen mode

Dashboards for every app

Kupe’s built-in monitoring has two dashboards for apps. Apps shows each environment’s status, releases succeeded and failed over time, and how recoveries went. App workloads goes down to the pods: how many are ready, container restarts, CPU and memory against requests and limits, CPU throttling, out-of-memory kills and network traffic. Kupe also raises an alert when an environment is degraded or a deployment is blocked, and you can route both alerts to your own receivers.

When you need more than an app

Apps cover the most common use case: a service built from a container image that answers requests. When you need something they don’t do yet, your cluster is still standard Kubernetes. Write your own Helm chart or manifests and deploy them to the same cluster, next to your apps. Nothing about using Apps locks you out of that.

Most of what’s next on our list already works on Kupe that way. Persistent volumes, images from private registries outside Kupe, background workers and migration Jobs all run in your cluster today, and every container’s logs already reach your logs dashboard. We’re bringing each of them into Apps, so you get them from the same single resource: persistent storage, private registries, background workers, database migrations that run as part of a release, and logs and activity for each app in the console.

Deploy Hello Kupe first

Apps are available now. Kupe is free throughout alpha, and we don’t plan a separate charge for Apps: an app runs on the cluster resources you already have.

For a first go, deploy Hello Kupe, our little memory game. The quickstart takes its public image to a playable URL from the console, the CLI or Terraform.

Top comments (0)