Skip to content

Instantly share code, notes, and snippets.

View mikejoh's full-sized avatar
☁️
👨🏻‍🏭🛠️

Mikael Johansson mikejoh

☁️
👨🏻‍🏭🛠️
View GitHub Profile
@mikejoh
mikejoh / tmux.md
Created September 1, 2021 09:24
TMUX setup revisited

~/.tmux.conf:

# Bindings
unbind C-b
unbind '"'
unbind %
set -g prefix C-a
bind C-a send-prefix
bind-key R source ~/.tmux.conf \; display-message "tmux.conf reloaded."
bind e setw synchronize-panes on
@mikejoh
mikejoh / kvm-on-ubuntu.md
Last active February 5, 2022 21:25
KVM on Ubuntu 20.04 using (Ubuntu) cloud images

Running virtual machines on KVM and Ubuntu 20.04 using (Ubuntu) cloud images

  1. Check: egrep -c '(vmx|svm)' /proc/cpuinfo
  2. Check: sudo kvm-ok
  3. Install:
sudo apt update
sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager cloud-image-utils
  1. Add yourself to the libvirt and kvm groups:
@mikejoh
mikejoh / monitor-calico-felix-using-prom-op-in-k8s.md
Last active November 14, 2024 16:26
Monitor Calico Felix using the Prometheus Operator (Kubernetes)

Monitor Calico Felix using Prometheus Operator

Make sure you have these settings enabled in felix, in this case using enviornment variables:

FELIX_PROMETHEUSMETRICSENABLED = True
FELIX_PROMETHEUSMETRICSPORT = "9091"
FELIX_PROMETHEUSGOMETRICSENABLED = True
FELIX_PROMETHEUSPROCESSMETRICSENABLED = True
@mikejoh
mikejoh / cpu-profiling-calico-node.md
Created February 24, 2021 20:15
CPU profiling calico-node (felix) v3.16.5 running in a Kubernetes Pod using pprof

CPU profiling calico-node (felix) v3.16.5 running in a Kubernetes Pod using pprof

Create a pprof profile:

kubectl exec -it -n kube-system calico-node-abcd -c calico-node -- sv -w 60 2 felix

List all files in /tmp/:

kubectl exec -it -n kube-system calico-node-abcd -c calico-node -- ls -l /tmp
@mikejoh
mikejoh / promql.md
Last active August 12, 2023 18:46
PromQL Queries

Various good-to-have PromQL queries

List the number of top 100 metrics and how many data points are saved

topk(100, count by (__name__, job)({__name__=~".+"}))

Calculate required disk space by Prometheus

Formula:

@mikejoh
mikejoh / kubectl-one-liners.md
Last active March 13, 2024 08:02
Yet another kubectl one-liners

kubectl one-liners

Enable kubectl completion (needs the bash-completion package):

source <(kubectl completion bash)

Dry-run, outputs Service (--expose) and a Deployment in yaml:

kubectl run --image=apache \ 
--port=80 \
@mikejoh
mikejoh / everything-elasticsearch.md
Last active October 1, 2019 06:01
Everything Elasticsearch

Everything Elasticsearch

Architecture

Work in progress

If you install Elasticsearch as-is the node will by default have the following roles:

  • Data
  • Master
@mikejoh
mikejoh / jenkins-logstash-plugin.md
Last active July 11, 2019 14:08
Configure the Jenkins logstash plugin

Configure the Jenkins Logstash plugin as code

Not all plugins are compatible with the Configurations as Code plugin, the Logstash plugin can be enabled via CasC but the indexer type cannot be configured. This groovy-hook can be used as a workaround, in this example i've configured the indexer type as Elasticsearch.

Compatibility with CasC can be tracked here.

This script can be added to the init.groovy.d/ directory within Jenkins, scripts added to this directory will be executed in the very end of the Jenkins initialization.

Remember that the URI is hardcoded in the example below, if you have some experience running Jenkins as Code you might already have a property file that you read through for each groovy-script to configure different parts of Jenkins aswell as plugins.

@mikejoh
mikejoh / docker-one-liners.md
Created August 20, 2018 08:15
Docker one-liners

Docker one-liners

Get a shell in a container (e.g. when failing)

docker run -ti --entrypoint /bin/bash IMAGE_NAME

@mikejoh
mikejoh / tmux-one-liners.md
Last active August 8, 2018 19:35
tmux one-liners

tmux one-liners

To enter command mode in tmux do: Prefix + :

Set background color in current pane (command mode)

select-pane -P 'bg=red'

Synchronize commands across panes (command mode)