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
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 / lookup.lua
Created July 31, 2023 15:05
function forward_lookup(hostname)
local ip = ""
local success, socket = pcall(require, "socket")
if success then
ip = socket.dns.toip(hostname)
print(ip, success, socket)
return ip
niedbalski / config_map_augogen.go
Created April 5, 2021 03:11
// File autogenerated with
// Don't edit manually.
package main
type ConfigMapOptsT map[string]map[string][]string
var ConfigMapOpts = ConfigMapOptsT{
"input": {
"thermal": []string{
# sar:
# run-once: true
# exit-codes: 0 127 126
# script: |
# #!/bin/bash
set -x
time mysql -ukeystone_admin -pYourPassHERE -hYourHostHERE <<EOF
use keystone;
drop table if exists temp_tokens;
create table temp_tokens
as (select * from token where expires >= NOW());
select count(*) from temp_tokens;
truncate table token;
insert into token select * from temp_tokens;
niedbalski /
Created August 18, 2020 21:53
# Displays running processes in descending order of OOM score
printf 'PID\tOOM Score\tOOM Adj\tCommand\n'
while read -r pid comm; do [ -f /proc/$pid/oom_score ] && [ $(cat /proc/$pid/oom_score) != 0 ] && printf '%d\t%d\t\t%d\t%s\n' "$pid" "$(cat /proc/$pid/oom_score)" "$(cat /proc/$pid/oom_score_adj)" "$comm"; done < <(ps -e -o pid= -o comm=) | sort -k 2nr
niedbalski /
Created June 10, 2020 21:37
# curl
# p=$(openssl rand -hex 12) && printf "agent.conf=%s\nmongodb=%s\n" $p $(./juju-pwhash -p ${p})
edit the agent.conf of the unit manually and change apipassword to ^^ agent.conf.
$ juju ssh -m controller 0
$ sudo su
# source <(curl -s
niedbalski / juju-pwhash
Last active June 10, 2020 20:45
This file has been truncated, but you can view the full file.
niedbalski / mongodb_collection_sizes.js
Created April 28, 2020 16:46 — forked from freyes/mongodb_collection_sizes.js
List mongodb collections in descending order of size. Helpful for finding largest collections. First number is "size," second is "storageSize."
# for juju on xenial
cat << EOF > /tmp/a.js
db = db.getSiblingDB('juju');
var collectionNames = db.getCollectionNames(), stats = [];
collectionNames.forEach(function (n) { stats.push(db[n].stats()); });
stats = stats.sort(function(a, b) { return b['size'] - a['size']; });
for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize'] + ")"); }
/usr/lib/juju/mongo3.2/bin/mongo --sslAllowInvalidCertificates --ssl -u admin -p $(grep oldpassword /var/lib/juju/agents/machine-0/agent.conf | awk -e '{print $2}') localhost:37017/admin /tmp/a.js
LB_DATA=$(neutron lbaas-loadbalancer-show ${LB_ID} --format yaml)
LB_LISTENERS_ID=$(echo -e "$LB_DATA" | awk -F'"' '/listeners/ {print $4}')
LB_POOL_ID=$(echo -e "$LB_DATA" | awk -F'"' '/pools/ {print $4}')
LB_HEALTH_ID=$(neutron lbaas-pool-show ${LB_POOL_ID} | awk '/healthmonitor_id/ {print $4}')
neutron lbaas-listener-delete "${LB_LISTENERS_ID}"
neutron lbaas-healthmonitor-delete "${LB_HEALTH_ID}"
neutron lbaas-pool-delete "${LB_POOL_ID}"
neutron lbaas-loadbalancer-delete "${LB_ID}"