Skip to content

Instantly share code, notes, and snippets.

View tuxfight3r's full-sized avatar
:octocat:
Working from home

Mohan Balasundaram tuxfight3r

:octocat:
Working from home
View GitHub Profile
@tuxfight3r
tuxfight3r / kubect_patch.md
Last active January 20, 2024 19:40
kubectl configmap json patch

use kubectl to patch configmap via json patch operations (add/remove/replace/test)

## Add a new key to the existing configmap
$ kubectl patch cm demo-app-config --type json --patch '[{ "op": "add", "path": "/data/TEST_VALUE", "value": "test_key" }]'
configmap/demo-app-config patched

$ kubectl get cm demo-app-config -o json | jq .data.TEST_VALUE
"test_key"
@tuxfight3r
tuxfight3r / 1.my_filter.py
Created March 14, 2017 12:31
ansible custom filters demo
#place the file in your ansible playbook director under filter_plugins
#/home/user/my_playbook.yml
#/home/user/filter_plugins/my_filters.py
#!/usr/bin/python
class FilterModule(object):
def filters(self):
return {
'a_filter': self.a_filter,
'another_filter': self.b_filter
@tuxfight3r
tuxfight3r / kcat.md
Last active December 4, 2023 22:10
KafkaCat configuration for AWS MSK

KafkaCat Configuration for AWS MSK

Set the below environment variable with the following values

NOTE: Kafkacat is renamed to kcat recently and the config variable should be KCAT_CONFIG for version 1.7 onwards.

# you can export the variable or present the config with -F parameter for kafkacat
export KAFKACAT_CONFIG=/home/tools/persistent/kcat/kafkacat_config

Contents of kafkacat configuration

@tuxfight3r
tuxfight3r / consume_message.md
Last active November 17, 2023 15:37
consume message from kafka topic from any given offset

Consume kafka messages from a specific offset

There are 2 ways of consuming kafka messages from a given topic at a specific offset.

Consume the messages from any offset by creating consumer group

get_group_offset(){
  # describe a given group and sort by partition
/home/tools/confluent/bin/kafka-consumer-groups --bootstrap-server ${KAFKA_BROKER} --command-config ${CONFIG} --timeout 15000 --group $1 --describe | sort -k2,3
}
@tuxfight3r
tuxfight3r / ipxe_with_dhcp.txt
Last active October 25, 2023 03:34
ipxe kickstart over http - dhcp and static configuration
#clone the repo
git clone http://git.ipxe.org/ipxe.git
cd ipxe/src
cat >ubuntu-amd64-installer.ipxe <<EOF
#!ipxe
dhcp
echo Starting Ubuntu x64 installer for ${hostname}
set base-url http://archive.ubuntu.com/ubuntu/dists/trusty/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64
kernel ${base-url}/linux
@tuxfight3r
tuxfight3r / git-gpg-sign.txt
Created February 24, 2021 15:01
signing git commits with GPG keys.
# generate a key if you don't have one already
gpg --full-gen-key
# list the keys in long format and copy the key id after sec rsa4096/<KEY>
gpg --list-secret-keys --keyid-format LONG
# export the public key and post into your git profile (ui)
gpg --armor --export 127CAA89CEA6BE66
@tuxfight3r
tuxfight3r / sfdisk.sh
Created March 6, 2017 16:01
use sfdisk to create scripted partitions
##create one big partition
echo ';' | sfdisk /dev/sdc
##create one big partition with specific partition type
#creates W95 FAT32 (LBA)
echo ',,c;' | sfdisk /dev/sdd
#creates lvm type
echo ',,8e;' | sfdisk /dev/sdd
@tuxfight3r
tuxfight3r / journald-splunk
Created February 6, 2018 16:10
custom splunk journald logrotate
# Rotate client logs
# log file already has this context set.
# -rw-r-----. root root system_u:object_r:var_log_t:s0 /var/log/journald_splunk.log
# -rw-r-----. root root system_u:object_r:var_log_t:s0 /var/log/journald_splunk.log-2018020315
/var/log/journald_splunk.log {
hourly
maxsize 3M
rotate 3
missingok
@tuxfight3r
tuxfight3r / git commands.txt
Last active August 29, 2023 06:58 — forked from kmorcinek/git commands.txt
Useful Git Commands
# good git book
http://git-scm.com/book
# Discard uncommitted changes in a specific file
git checkout file_name
# Clear everything not in repo
git checkout -- .
# A way to quickly move to the previous commit in a git branch. This also way for "deleting" last commit.
@tuxfight3r
tuxfight3r / jenkins-decrypt.groovy
Created September 23, 2015 11:36
Decrypting Jenkins Password
#To Decrypt Jenkins Password from credentials.xml
#<username>jenkins</username>
#<passphrase>your-sercret-hash-S0SKVKUuFfUfrY3UhhUC3J</passphrase>
#go to the jenkins url
http://jenkins-host/script
#In the console paste the script
hashed_pw='your-sercret-hash-S0SKVKUuFfUfrY3UhhUC3J'