Kafka Snippets

Start an Image with kcat / kafka-cat for Debugging kubectl -n NAMESPACE run "$(whoami)-debug" -it --rm \ --image=confluentinc/cp-kafkacat:6.1.9 \ --restart=Never \ -- bash Dockerfile for Kafka Analysis Container with different Tools With jq, kafka console tools, schema registry tools and kafkacat installed …​. Dockerfile FROM confluentinc/cp-kafka:6.2.1 as cp-kafka FROM confluentinc/cp-schema-registry:6.2.1 as cp-schema-registry FROM debian:10-slim ARG DEBIAN_FRONTEND=noninteractive # Install necessary tools RUN apt-get update && apt-get install -y \ curl \ jq \ yq \ && rm -rf /var/lib/apt/lists/* # Install kafkacat binary RUN apt-get update && apt-get install -y kafkacat && rm -rf /var/lib/apt/lists/* # Copy Kafka binaries COPY --from=cp-kafka /usr/bin/kafka-* /usr/bin/ COPY --from=cp-schema-registry /usr/bin/schema-registry* /usr/bin/ # Copy entrypoint script COPY entrypoint.sh /usr/bin/entrypoint.sh RUN chmod +x /usr/bin/entrypoint.sh ENTRYPOINT ["/usr/bin/entrypoint.sh"] ...

March 1, 2010 · 7 min · 1366 words · Micha Kops

Linux Snippets

These are not only linux snippets but also bash snippets and snippets using tools that run under Linux, *nix or sometimes even MacOSX, I should reorder this article someday ;) Settings for more reliable bash scripts set -euo pipefail this gives us …​ -e: exit script if a single command fails -u: exit script if an unset variable is used -o pipefail: return value of a pipeline is the status of the last command to exit with a non-zero status, or zero if no command exited with a non-zero status ...

March 1, 2010 · 17 min · 3578 words · Micha Kops

Postgres Snippets

Administration & Configuration Connections Show Max Connections (value and source) SELECT setting, source, sourcefile, sourceline FROM pg_settings WHERE name = 'max_connections'; Set Max Connections ALTER system SET max_connections = 250; Kill Connections for a Database SELECT pg_terminate_backend(pid) FROM pg_catalog.pg_stat_activity -- we don't want to kill our own connection WHERE pid != pg_backend_pid() -- we don't want to kill connections to other databases AND datname = 'MYDATABASE' Show Statement Timeout Settings for All Users SELECT r.rolname, (SELECT unnest(s.setconfig) FROM pg_db_role_setting s WHERE s.setrole = r.oid AND s.setconfig::text LIKE '%statement_timeout%' LIMIT 1) AS statement_timeout FROM pg_roles r WHERE r.rolcanlogin ORDER BY r.rolname; ...

March 1, 2010 · 11 min · 2278 words · Micha Kops