Skip to content

Instantly share code, notes, and snippets.

View rodrigo-galba's full-sized avatar

Rodrigo Galba rodrigo-galba

  • Brazil
View GitHub Profile
@rodrigo-galba
rodrigo-galba / README.md
Created September 30, 2021 17:50
Kubernetes - force remove hanging namespace
sudo apt install jq
(
NAMESPACE=hanging-namespace
kubectl proxy &
kubectl get namespace $NAMESPACE -o json |jq '.spec = {"finalizers":[]}' >temp.json
curl -k -H "Content-Type: application/json" -X PUT --data-binary @temp.json 127.0.0.1:8001/api/v1/namespaces/$NAMESPACE/finalize
@rodrigo-galba
rodrigo-galba / refresh-certs.sh
Created June 21, 2021 18:46 — forked from ktsakalozos/refresh-certs.sh
Refresh MicroK8s Certs
#!/bin/bash
set -eu
export SNAP_NAME="microk8s"
export SNAP_DATA="/var/snap/microk8s/current/"
export SNAP="/snap/microk8s/current/"
export PATH="$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH"
source $SNAP/actions/common/utils.sh
@rodrigo-galba
rodrigo-galba / README.md
Created June 14, 2021 21:34
Terraform: Get LOCK id

How to get the lock ID for terraform?

I need to force a unlock, but how to get the lock id?

$ terraform destroy
Acquiring state lock. This may take a few moments...

Error: Error locking state: Error acquiring the state lock: 2 error(s) occurred:
@rodrigo-galba
rodrigo-galba / README.md
Last active June 14, 2021 14:41
Alert manager cluster mode

Alert manager cluster mode

Given 2 servers,

1 - Configure the Two Alertmanager Instances to Form a Cluster

  1. On both servers, edit the Alertmanager unit file:
sudo vi /etc/systemd/system/alertmanager.service
@rodrigo-galba
rodrigo-galba / README.md
Last active June 11, 2021 14:08
Prometheus + Push gateway setup

Prometheus + Push gateway setup

sudo useradd -M -r -s /bin/false pushgateway
wget https://github.com/prometheus/pushgateway/releases/download/v1.2.0/pushgateway-1.2.0.linux-amd64.tar.gz
tar xvfz pushgateway-1.2.0.linux-amd64.tar.gz
sudo cp pushgateway-1.2.0.linux-amd64/pushgateway /usr/local/bin/
sudo chown pushgateway:pushgateway /usr/local/bin/pushgateway
sudo vi /etc/systemd/system/pushgateway.service
@rodrigo-galba
rodrigo-galba / README.md
Created June 7, 2021 02:05
Kube state metrics + Prometheus

Kube state metrics setup

git clone https://github.com/kubernetes/kube-state-metrics.git
cd kube-state-metrics/
kubectl apply -f kubernetes
git checkout v1.8.0
cd ~
vi kube-state-metrics-nodeport-svc.yml
@rodrigo-galba
rodrigo-galba / README.md
Created June 7, 2021 01:30
Docker cAdvisor with Prometheus

Docker cAdvisor with Prometheus

docker run -d --restart always --name cadvisor -p 8080:8080 -v "/:/rootfs:ro" -v "/var/run:/var/run:rw" -v "/sys:/sys:ro" -v "/var/lib/docker/:/var/lib/docker:ro" google/cadvisor:latest
curl localhost:8080/metrics
ssh cloud_user@<PROMETHEUS_SERVER_PUBLIC_IP>
sudo vi /etc/prometheus/prometheus.yml
@rodrigo-galba
rodrigo-galba / README.md
Last active June 14, 2021 14:45
Apache metrics + Prometheus

Apache metrics + Prometheus

Apache setup

sudo useradd -M -r -s /bin/false apache_exporter
wget https://github.com/Lusitaniae/apache_exporter/releases/download/v0.7.0/apache_exporter-0.7.0.linux-amd64.tar.gz
tar xvfz apache_exporter-0.7.0.linux-amd64.tar.gz
sudo cp apache_exporter-0.7.0.linux-amd64/apache_exporter /usr/local/bin/
sudo chown apache_exporter:apache_exporter /usr/local/bin/apache_exporter
@rodrigo-galba
rodrigo-galba / README.md
Last active November 11, 2020 19:29
AWS DevOps tools

AWS DevOps productivity tools

Except from https://globaldatanet.com/blog/devops-tools-you-should-have-on-your-belt

🏗 AWS CodeBuild Local Builds - Simulate a CodeBuild environment locally to quickly troubleshoot the commands and settings located in the BuildSpec file.

🧰 AWS Toolkit for Visual Studio Code is an extension for working with AWS services such as AWS Lambda.

👩🏻‍✈️ AWS Copilot CLI is a tool for developers to create, release, and manage production-ready containerized applications on Amazon ECS and AWS Fargate.

@rodrigo-galba
rodrigo-galba / app.py
Last active June 18, 2020 05:46
Dumb python script to enter data
"""
How to use it:
$ APP_NODE=1 python app.py
"""
import mysql.connector
import time, os
host="abc.us-east-1.rds.amazonaws.com"
user="cloudops"
password="lab"