Skip to content

Instantly share code, notes, and snippets.

View mvisonneau's full-sized avatar

Maxime VISONNEAU mvisonneau

View GitHub Profile
@mvisonneau
mvisonneau / make.sh
Created February 1, 2021 18:07
Compile kubernetes/dns/node-cache
git clone https://github.com/kubernetes/dns.git
cd dns
git checkout 1.17.0
make containers CONTAINER_BINARIES=node-cache
make containers CONTAINER_BINARIES=node-cache ARCH=arm64
docker tag gcr.io/k8s-staging-dns/k8s-dns-node-cache-amd64:1.17.0 mvisonneau/k8s-dns-node-cache-amd64:1.17.0
docker tag gcr.io/k8s-staging-dns/k8s-dns-node-cache-arm64:1.17.0 mvisonneau/k8s-dns-node-cache-arm64:1.17.0
docker push mvisonneau/k8s-dns-node-cache-amd64:1.17.0
docker push mvisonneau/k8s-dns-node-cache-arm64:1.17.0
@mvisonneau
mvisonneau / ami-cost-estimate.sh
Last active April 26, 2023 08:26
AMI cost estimate
#!/usr/bin/env bash
REGIONS=$(aws ec2 describe-regions | jq -r '.Regions[].RegionName' | sort)
TOTAL_SIZE=0
TOTAL_COST=0
for REGION in $REGIONS; do
SIZE=$(AWS_REGION=$REGION aws ec2 describe-snapshots --owner-ids self --query "Snapshots[*].{Description:Description,VolumeSize:VolumeSize}" | jq '[.[] | select( (.Description|startswith("Copied for DestinationAmi")) or (.Description|startswith("Created by CreateImage")) ) | .VolumeSize] | add')
@mvisonneau
mvisonneau / gitlab_to_jira.py
Created August 11, 2017 15:54
GitLab to Jira issue sync
#!/usr/bin/env python
import gitlab
from jira import JIRA
import urllib3
## Disable urllib3 ssl checks warnings
urllib3.disable_warnings( urllib3.exceptions.InsecureRequestWarning )
## GitLab config
@mvisonneau
mvisonneau / gen_eni_max_pods.sh
Last active December 19, 2022 10:22
dynamically regenerate eni-max-pods.txt
export AWS_DEFAULT_REGION=eu-west-1
aws ec2 describe-instance-types \
| jq -r --arg FIRST_INTERFACE_INDEX 1 \
'.InstanceTypes[] |
"\(.InstanceType) \(((.NetworkInfo.MaximumNetworkInterfaces-($FIRST_INTERFACE_INDEX|tonumber))*.NetworkInfo.Ipv4AddressesPerInterface)-1)"' \
| sort
# You can also use this uglier one to cap to a certain amount (eg: 110)
# We also remove 2 IPs which are used for cilium router & health
@mvisonneau
mvisonneau / gist:a2e738ea6523303c5322
Created November 10, 2014 14:19
Free space from locked files without restarting process
root@hostname:/var/log# df -h | grep lv_var
/dev/rootvg/lv_var 992M 943M 0 100% /var
root@hostname:~# pidof mysqld
17431
root@hostname:~# lsof -p 17431 | grep deleted
mysqld 17431 mysql 1w REG 252,5 1 32994 /var/log/mysql/error.log.1 (deleted)
mysqld 17431 mysql 2w REG 252,5 1 32994 /var/log/mysql/error.log.1 (deleted)
mysqld 17431 mysql 4w REG 252,5 1 32987 /var/log/mysql/mysql-slow.log.1 (deleted)
@mvisonneau
mvisonneau / get.sh
Last active May 6, 2020 10:50
Dynamically retrieve all EC2 instance types ENI limits (per region)
aws ec2 describe-instance-types \
| jq '[
.InstanceTypes[] | {
type: .InstanceType,
maxInterfaces: .NetworkInfo.MaximumNetworkInterfaces,
maxIPV4PerInterface: .NetworkInfo.Ipv4AddressesPerInterface,
maxIPV6PerInterface: .NetworkInfo.Ipv6AddressesPerInterface
}
]'
@mvisonneau
mvisonneau / k8s_current_namespace.sh
Created May 1, 2019 16:47
Figure out what is the current namespace configured within the current context using kubectl & jq
kubectl config view -o json | jq -r ".contexts[] | select( .name | contains(\"$(kubectl config current-context)\")) | .context.namespace"

Keybase proof

I hereby claim:

  • I am mvisonneau on github.
  • I am mvisonneau (https://keybase.io/mvisonneau) on keybase.
  • I have a public key ASAnYgnjFyYRTM9h4cm50HzL0-KHzpgDn3VaInODqduNpwo

To claim this, I am signing this object:

{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [ 0.003723371097,51.53195199 ]
},
"properties": {
@mvisonneau
mvisonneau / vault-aws-ec2-login
Created July 10, 2018 10:50
vault-aws-ec2-login
#!/usr/bin/env bash
if [[ -z ${VAULT_ADDR} ]]; then
echo "VAULT_ADDR must be set"
exit 1
fi
pkcs7=$( curl -s http://169.254.169.254/latest/dynamic/instance-identity/pkcs7 | tr -d '\n' )
iam_instance_profile=$( curl -s http://169.254.169.254/latest/meta-data/iam/info | jq -r .InstanceProfileArn | cut -d '/' -f2 )
nonce=$( openssl rand -base64 36 )