Skip to content

Instantly share code, notes, and snippets.

View germainlefebvre4's full-sized avatar

Germain Lefebvre germainlefebvre4

  • Lille
View GitHub Profile
@germainlefebvre4
germainlefebvre4 / kubernetes-crds-to-html.sh
Last active April 12, 2024 09:46
A script to render a digest HTML page to read Kubernetes CRDs
#!/bin/bash
# Prerequisites:
# - yq: https://github.com/mikefarah/yq
# - yaml2json: https://github.com/bronze1man/yaml2json
# - generate-schema-doc: https://github.com/coveooss/json-schema-for-humans
FILE=$1
if [ ! -d html ] ; then
mkdir html

Keybase proof

I hereby claim:

  • I am germainlefebvre4 on github.
  • I am germainlefebvre4 (https://keybase.io/germainlefebvre4) on keybase.
  • I have a public key whose fingerprint is EF01 FEAE 7710 9DFD D5B5 4016 82A5 547B CDB4 2C8E

To claim this, I am signing this object:

@germainlefebvre4
germainlefebvre4 / wsl2-sync-minikube-services-windows-host.sh
Last active June 18, 2020 13:30
Minikube & WSL2 - Access to your kubernetes (namespaced) services with a browser from your WSL2 machine (here Ubuntu).
#!/bin/bash
# IMPORTANT #1: Run WSL machine as administrator.
# IMPORTANT #2: Disable read-only on Windows hosts file (c:\Windows\System32\drivers\etc`hosts)
# and allow Write right to current user.
# IMPORTANT #3: Install apache2 package and activate proxy module
# apt update
# apt install -y apache2
# service apache2 start
# a2enmod proxy_http
@germainlefebvre4
germainlefebvre4 / Dockerfile
Created April 9, 2020 22:45
Build docker image for python app based on pipenv development
FROM python:3.8-alpine AS base
FROM base as builder
RUN apk update && \
apk add py-pip && \
pip install pipenv
# Update pipenv libs
COPY Pipfile* ./
#!/usr/bin/python2
import subprocess
from time import sleep
APP_NAME="app-python"
APP_VERSION="v1"
# Get current pods
COMMAND="kubectl get pods | grep %s | awk '{print $1}'" % (APP_NAME)
@germainlefebvre4
germainlefebvre4 / aws-billing_influxdb.py
Last active April 19, 2019 12:41
Collect billing costs for each AWS Accounts registered and push dataset in InfluxDB
#!/usr/bin/env python
# Author: Germain LEFEBVRE [Ineat]
# Prerequisites
# 00 - Create API Access Key in AWS Accounts to monitor
# 00 - Fill ~/.aws/credentials with API Access Keys
# 01 - Fill ./config.yml 'aws_account' dict with aws profiles or access/secret key as following:
# aws_accounts:
# - name: Ineat iLab
# profile: INEAT_ILAB
# Request your access_token (expires every 10-15 minutes)
curl -X POST -s "https://auth.tado.com/oauth/token" -d client_id=tado-web-app -d grant_type=password -d client_secret=xxxxxxxxx -d 'username=my@email.com' -d 'password=myPassword' -d scope=home.user
{"access_token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1YzIyOTliNmQ2MDE4MDAwMDg4ZGJhNGEiLCJ0YWRvX2hvbWVzIjpbeyJpZCI6MjgzNzg3fV0sImlzcyI6InRhZG8iLCJsb2NhbGUiOiJmciIsImF1ZCI6InBhcnRuZXIiLCJuYmYiOjE1NDU4NjI4NTQsInRhZG9fc2NvcGUiOlsiaG9tZS51c2VyIl0sInRhZG9fdXNlcm5hbWUiOiJnZXJtYWluLmxlZmVidnJlNEBnbWFpbC5jb20iLCJuYW1lIjoiR2VybWFpbiBMZWZlYnZyZSIsImV4cCI6MTU0NTg2MzQ1NCwiaWF0IjoxNTQ1ODYyODU0LCJ0YWRvX2NsaWVudF9pZCI6InRhZG8td2ViLWFwcCIsImp0aSI6IjEzYzdlOTA4LTQzOWEtNDA5OC04OWMyLTZmNWFlYjhlODM5NyIsImVtYWlsIjoiZ2VybWFpbi5sZWZlYnZyZTRAZ21haWwuY29tIn0.Otrk9iAM3AM3suRTGgYh9FcTL1onsD3wEbHAHhBv1RD9mTnFv_Uds-NOXtZJpWApq_R0i5d-Lfy64UCdN3EW5DEb8QaCyvwmjOpgFEU1WvRNamh_dZGzB_AwCkI10qVe5qSpKL-_I51zxUsLmhOubfUJZE9wjBNVDMXVyq8vX-rzFIrJH3dfdgTalYyUYlrU3oBs2Q5eSCzR8dh09fBfIC_vy
# Install Kubernetes Cluster
# Targets: Master + Workers
# Prepare system
# Disable SELinuw
setenforce 0
sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
# Disable Swap
# Uninstall everything
docker stop $(docker ps -aq)
docker rm $(docker ps -aq)
yum remove -y kubeadm kubelet kubectl
yum remove -y docker-ce docker
rm -rf /etc/kubernetes/ /var/lib/kubelet/ /etc/systemd/system/kubelet.service.d /etc/systemd/system/multi-user.target.wants/kubelet.service /var/lib/kubelet/ /var/log/containers /var/log/pods /usr/bin/kubelet /usr/libexec/kubernetes /etc/systemd/system/kubelet.service /etc/yum.repos.d/kubernetes.repo
rm -rf /var/lib/docker
# My dependencies
yum install -y telnet mlocate
# Prepare system
setenforce 0
swapoff `cat /etc/fstab | grep swap | awk '{print $1}'`
cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF