Skip to content

Instantly share code, notes, and snippets.

View niedbalski's full-sized avatar
👋
Be humble. Stay focused.

Jorge Niedbalski niedbalski

👋
Be humble. Stay focused.
View GitHub Profile
@niedbalski
niedbalski / mongo.sh
Created February 10, 2015 20:20
Connect to Juju Mongodb
$ juju ssh 0
machine-0# sudo apt-get install mongodb-clients
machine-0# mongo --ssl -u admin -p $(grep oldpassword /var/lib/juju/agents/machine-0/agent.conf | awk -e '{print $2}') localhost:37017/admin
MongoDB shell version: 2.4.9
connecting to: localhost:37017/admin
juju:PRIMARY> db = db.getSiblingDB("juju")
juju
1. Set Up an OIDC Identity Provider in AWS
Create an OIDC Identity Provider in AWS IAM:
Navigate to the IAM section in the AWS Management Console.
Choose "Identity Providers," then "Create Provider."
Select "OpenID Connect" as the provider type.
For the provider URL, you need the OIDC discovery endpoint URL from your k3s cluster. This URL is typically obtained from your Kubernetes cluster's API server configuration.
Add the thumbprint of the OIDC provider's SSL certificate.
2. Configure k3s for OIDC
Configure k3s with OIDC Details:
@niedbalski
niedbalski / lookup.lua
Created July 31, 2023 15:05
lookup.lua
function forward_lookup(hostname)
local ip = ""
local success, socket = pcall(require, "socket")
if success then
ip = socket.dns.toip(hostname)
end
print(ip, success, socket)
return ip
end
@niedbalski
niedbalski / recover-rabbit.sh
Created July 5, 2017 16:04
Recover a rabbitmq cluster after partitioning
Some notes from engineering.
1) Identify the partition
Mnesia('rabbit@juju-machine-30-lxd-11'): ** ERROR ** mnesia_event got {inconsistent_database, running_partitioned_network, 'rabbit@juju-machine-29-lxd-9'}
$ sudo rabbitmqctl cluster_status
2) Pick the most reliable node as the master.
@niedbalski
niedbalski / purge-queues.py
Last active December 4, 2022 13:01
purge-queues.py
#!/usr/bin/env python
"""
Purge and delete rabbit queues by prefix and message
amount.
Usage:
{0} prefix 1
"""
@niedbalski
niedbalski / recover-lost-agent.py
Last active October 10, 2022 04:51
recover a lost Juju agent
#!/usr/bin/env python
"""
This is a tool for recovering a lost juju unit
Usage:
{0} controller-ip unit-from unit-to basedir
"""
import subprocess
import shlex
@niedbalski
niedbalski / all-data.sh
Last active July 29, 2022 16:52
juju-get-all-data-relation.sh
$ juju run --unit nova-compute/0 "relation-ids amqp"
amqp:30
$ juju run --unit nova-compute/0 "relation-list -r amqp:30"
rabbitmq-server/0
$ juju run --unit nova-compute/0 "relation-get -r amqp:30 - rabbitmq-server/0"
hostname: 10.1.1.17
password: 4T6fg9VjqN9BBLXdBBfyHscxpkBzby698GsXf88LwnRnmqd46TVfbPCMmrRCHpS5
private-address: 10.1.1.17
@niedbalski
niedbalski / traceroute.go
Last active December 8, 2021 13:16
A small traceroute written in go
package main
import (
//"bufio"
"fmt"
"golang.org/x/net/icmp"
"golang.org/x/net/internal/iana"
"golang.org/x/net/ipv4"
"log"
"net"
from jinja2 import Environment
import yaml
import sys
RULE_TPL = """
ALERT {{ alert }}
IF {{ expr }}
FOR {{ for }}
LABELS {
severity="page"
@niedbalski
niedbalski / no-madvise.c
Created August 19, 2015 13:12
madvise tests
niedbalski@theos-mobile:~$ cat test-madvise.c
#include <sys/mman.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
int main(void) {
size_t size = sysconf(_SC_PAGE_SIZE) * 6; //24K