Note: These are beta projects, use at your own discretion
- Andrew Naylor's user-space prometheus-based Workflow Monitoring Toolchain
Before installing Helm Charts, you will need:
- Have a valid install of
kubectlandhelm-- we provide helper scripts that will download these toopt/bin; - Obtain the
kubeconfigfrom the Spin cluster where your project runs (either the "development" or "production" cluster). Remeber to use the entrypoint script when running the scripts in this project.
We want to ensure that the scripts have have predictable behavior, regardless of the execution context (e.g. where scripts are being run from). Bash kinda sucks at this (especially when handling relative paths) -- an imperfect (but acceptable) solution is to use a launcher script: entrypoint.sh which takes the command to run as its arguments. This can be run either as a standalone script, or in interactive mode.
entrypoint.sh sets two environment variables __PREFIX__, and __DIR__:
__PREFIX__contains the location of the project root (i.e. whereentrypoint.shis saved)__DIR__contains the location of he script being run
Standalone mode is invoked by passing the path to the script you want to run
(relative the entrypoint.sh) as its arguments
./entrypoint.sh opt/util/get_kubectl.sh -n linux -a amd64
Interactive mode is invoked whenever the command passed to entrypoint.sh is
not a script in this project (i.e.the absolute path does not start with
$__PREFIX__). Most often this is used to launch a shell:
./entrypoint.sh bash
This would drop you into a shell containing __PREFIX__.
Note
In interactive mode $__PREFIX__/opt/bin:$__PREFIX__/opt/util are appended to
PATH. Furthemore __DIR__ is unset (which might cause some scripts -- which are not meant to operate in interactive mode -- to
fail).
KUBECONFIG is a YAML file containing the deteails of the k8s cluster, such as its address, and your own authentication credentials. It can be downloaded from the Spin.
- Login to rancher2.spin.nersc.gov;
- click the cluster name (as of May 12, 2024, either "development" or "production");
- hover the mouse pointer over the "page" icon on the top right of the page, it should say "Download KubeConfig", click it to download.
- create
$HOME/.kubedirectory if not existing, and save the downloaded file to$HOME/.kube/config; alternatively, you can set theKUBECONFIGenvironment variable to the path to the downloaded YAML file.
Using kubectl, create a kubeconfig secret in the targeted namespace
(replace <targeted_namespace> and <path to kubeconfig> accordingly):
kubectl -n <targeted_namespace> create secret generic kubeconfig --from-file=kubeconfig=<path to kubeconfig>kubectl get namespaces
kubectl get deployments -n <name of namespace>
kubectl logs deployments/<deployment name> -n <name of namespace>
kubectl get pods -n <name of namespace>
kubectl exec <name of pod> -n <name of namespace> -- <command>
If you want to "drop into" interactive shell on pod
kubectl exec <name of pod> -n <name of namespace> -it -- /bin/bash
helm install <app name> ./<chart path> -n <name of namespace> [--debug] [--dry-run]
helm uninstall <app name> -n <name of namespace>
kubectl scale -n <name of namespace> --replicas <number of replicas> deployment/<name of deployment>
This guide describes how to create namespaces on Spin.
Take a look at our examples for mysql and postgresql
For a basic setup, see Digitical Ocean's tutorial on How to Deploy Postgres on K8s. An enterprise-scale deployment is described in Cloudraft's tutorial on How to Build Scalable and Reliable PostgreSQL Systems on Kubernetes.
Neon has a Git repo on Postgres Autoscaling. A detailed description of setting up a scalabe Postgres cluster on K8s is given in this Medium article. Also note that K8s operators can be used for autscaling, for example Crunchy data's K8s operator