Skip to content

Instantly share code, notes, and snippets.

View bygui86's full-sized avatar
🎱
Playing with something new!

Matteo Baiguini bygui86

🎱
Playing with something new!
View GitHub Profile
@bygui86
bygui86 / prom-k8s-request-limits.md
Created May 4, 2022 10:46 — forked from max-rocket-internet/prom-k8s-request-limits.md
How to display Kubernetes request and limit in Grafana / Prometheus properly

CPU: percentage of limit

A lot of people land when trying to find out how to calculate CPU usage metric correctly in prometheus, myself included! So I'll post what I eventually ended up using as I think it's still a little difficult trying to tie together all the snippets of info here and elsewhere.

This is specific to k8s and containers that have CPU limits set.

To show CPU usage as a percentage of the limit given to the container, this is the Prometheus query we used to create nice graphs in Grafana:

sum(rate(container_cpu_usage_seconds_total{name!~".*prometheus.*", image!="", container_name!="POD"}[5m])) by (pod_name, container_name) /
######################################################################
# Production-Ready Kubernetes Clusters Using Crossplane Compositions #
# https://youtu.be/uMC2QQfMctg #
######################################################################
# Referenced videos:
# - Crossplane - GitOps-based Infrastructure as Code through Kubernetes API: https://youtu.be/n8KjVmuHm7A
# - How To Shift Left Infrastructure Management Using Crossplane Composites: https://youtu.be/AtbS1u2j7po
#################
@bygui86
bygui86 / README.md
Created October 13, 2021 07:54 — forked from jimangel/README.md
Enable audit logging on a kind cluster

Enable auditing on KinD

TODO

  • Use a webhook vs. file backend (maybe cloudrun?)
  • This might only be possible if Docker is running as root - need to test

Config

Make a temporary directory to host files to be mounted in KinD.

@bygui86
bygui86 / argo-cd-bootstrap.sh
Created April 30, 2021 17:21 — forked from mikesparr/argo-cd-bootstrap.sh
Bootstrapping GKE cluster, cert manager, and Argo CD
#!/usr/bin/env bash
source .env
# export PROJECT_ID=<from .env>
# export AUTH_NETWORK=<from .env>
export GCP_REGION=us-central1
export GCP_ZONE=us-central1-b
export CLUSTER_VERSION="1.16.13-gke.1"
@bygui86
bygui86 / hosts
Created December 13, 2020 22:32 — forked from consti/hosts
/etc/hosts to block shock sites etc.
# This hosts file is brought to you by Dan Pollock and can be found at
# http://someonewhocares.org/hosts/
# You are free to copy and distribute this file for non-commercial uses,
# as long the original URL and attribution is included.
#<localhost>
127.0.0.1 localhost
127.0.0.1 localhost.localdomain
255.255.255.255 broadcasthost
::1 localhost
@bygui86
bygui86 / jq-cheetsheet.md
Created November 2, 2020 14:33 — forked from olih/jq-cheetsheet.md
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@bygui86
bygui86 / CKAD.md
Created February 23, 2020 15:43 — forked from veggiemonk/CKAD.md
CKAD exam preparation
@bygui86
bygui86 / kubedump.sh
Created July 25, 2019 15:47 — forked from negz/kubedump.sh
Dump Kubernetes cluster resources as YAML
#!/usr/bin/env bash
set -e
CONTEXT="$1"
if [[ -z ${CONTEXT} ]]; then
echo "Usage: $0 KUBE-CONTEXT"
exit 1
fi
URL="http://stackoverflow.com/"
# store the whole response with the status at the and
HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X POST $URL)
# extract the body
HTTP_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g')
# extract the status
HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
#!/bin/sh
#
# This script adds 2 spring repositories to Nexus using curl
#
NEXUS_URL="http://${EVENTDRIVENMICROSERVICESPLATFORM_NEXUS_1_PORT_8081_TCP_ADDR}:${EVENTDRIVENMICROSERVICESPLATFORM_NEXUS_1_PORT_8081_TCP_PORT}/nexus"
POST_REPO_SERVICE="/service/local/repositories"
GET_REPO_SERVICE="/service/local/repositories"
PUT_PUBLIC_REPO_SERVICE="/service/local/repo_groups/public"