Kubernetes clusters
From nothing to an app on Kubernetes with an HTTPS address and a database, in a handful of commands.
kvbox runs the cluster; you use kubectl. This page goes from nothing to an app online with a database behind it. The Kubernetes guide has every command and limit.
Make the cluster
kvbox k8s create prod --size sTwo nodes of size s (2 vCPU and 4 GB of RAM each), about $31 a month. It takes a few minutes: the command waits until every node is Ready, then prints what a month of the cluster costs. --nodes asks for another number, and m and l are bigger nodes (Sizes).
Get the kubeconfig
kvbox k8s kubeconfig prod > prod.yaml
export KUBECONFIG=$PWD/prod.yaml
kubectl get nodesThe file makes whoever holds it the cluster's administrator: keep it like a password and do not commit it.
Run your app
Anything Kubernetes runs: a deployment, a Helm chart, your own manifests. Here, two copies of nginx behind a service:
kubectl create deployment shop --image=nginx --replicas=2
kubectl expose deployment shop --port=80Put it on the internet
A cluster has no public address until you claim one. Then an Ingress with that host name says which app answers:
kvbox k8s proxy claim prod shop # https://shop.kvbox.app
kubectl create ingress shop --class=traefik --rule="shop.kvbox.app/*=shop:80"kvbox makes and renews the certificate, so the Ingress has no tls part. For your own domain, kvbox k8s domain add prod shop.example prints the DNS records to set.
Give it a database
What a pod writes to the cluster's own storage lives on one node's disk and is in no backup. Keep data you cannot lose in a managed Postgres and link the cluster to it:
kvbox pg create orders
kvbox k8s link prod orderslink prints the address pods use, orders.<account>.kvbox and the port. It goes in a connection string as it is.
Add nodes when you need them
kvbox k8s pool resize prod default --nodes 4New nodes join by themselves. Asking for fewer drains each node first, so its pods move to the others. For nodes of another size, add a second pool: kvbox k8s pool add prod --size l.
Remove it
kvbox k8s rm prodIt asks first, then removes the nodes, the master and everything in the cluster. The database is its own thing and stays.