CrunchyData Postgres Operator snippets
Specification Available here Example usage Available here
Specification Available here Example usage Available here
Debugging Helm Templates To debug Helm templates, navigate to the Helm chart directory and run: helm template test . --dry-run --debug \ --values values.yaml \ --values values/dev.yaml > output.yaml This command renders the templates with specified values and outputs the result to output.yaml. The --dry-run and --debug flags provide valuable debugging information.
Spec Explorer kube-spec.dev: A handy tool for exploring Kubernetes resource specifications. Link: https://kubespec.dev Running a One-Time Job from a CronJob To execute a job based on an existing CronJob, use the following command: kubectl create job --from=cronjob/<cronjob-name> <job-name> -n <namespace-name> Source: https://stackoverflow.com/a/50041304 Spawning a Curl Container for Debugging To quickly spin up a curl container with specific security and resource constraints, use: kubectl run debug-curl \ --image=curlimages/curl \ --overrides='{ "apiVersion": "v1", "spec": { "securityContext": { "runAsNonRoot": true, "runAsUser": 1000, "runAsGroup": 1000 }, "containers": [ { "name": "debug-curl", "image": "curlimages/curl", "resources": { "requests": { "cpu": "100m", "memory": "128Mi" }, "limits": { "cpu": "200m", "memory": "256Mi" } }, "command": ["/bin/sh", "-c", "sleep infinity"] } ] } }' This command creates a debug-curl pod with a non-root user context and resource requests/limits. Connect to the shell using: kubectl exec pod/debug-curl sh Delete container using kubectl delete pod/debug-curl Getting Kubernetes Events To view Kubernetes events sorted by creation timestamp, use: ...
1. Monitor CPU Usage Use Kubernetes-native tools like kubectl top to check CPU usage for the PostgreSQL pod: kubectl top pod <postgres-pod-name> -n <namespace> Check if the CPU usage is consistently high or spiking. 2. Check PostgreSQL Metrics Use PostgreSQL’s built-in statistics and monitoring tools: pg_stat_activity: Identify active queries and their states. SELECT * FROM pg_stat_activity; pg_stat_statements: Identify the most resource-intensive queries. SELECT query, calls, total_exec_time, rows, 100.0 * total_exec_time / sum(total_exec_time) over () as percentage FROM pg_stat_statements ORDER BY total_exec_time DESC; Reset pg_stat_statements: ...
Context You want to declare an array of options. It should not change during the runtime of your program. To enforce non-mutability you declare it using const assertion. const options = ["Foo", "Bar", "Baz"] as const; const assertion means that you ask compiler to use the narrowest or most specific type. So options is not string[] but a readonly, 3-elements tuple. Problem Now you want to create a type that reflects literal strings listed in this options tuple. ...
A friend of mine has recently intrigued me with a question about TypeScript. He asked: Why TypeScript is not consistent in the following situation? Imagine you have a type Foo and type Bar which extends Foo. Why, when passing instance of Bar into a function accepting Foo, TypeScript does not complain, but when we try to declare a variable of type Foo but with extra keys specified, it does complain. ...