Skip to content

Instantly share code, notes, and snippets.

View paulojmdias's full-sized avatar
🚀

Paulo Dias paulojmdias

🚀
View GitHub Profile
---
apiVersion: v1
kind: ConfigMap
metadata:
name: stunnel-script
namespace: kube-system
data:
stunnel.sh: |
#!/bin/sh
WAIT_TIME=60 # Time in seconds to wait before polling stunnel processes
@yermulnik
yermulnik / tf_vars_sort.awk
Last active April 22, 2024 09:30
Sort Terraform (HCL) file by Resource Block Names using GNU `awk`
#!/usr/bin/env -S awk -f
# https://gist.github.com/yermulnik/7e0cf991962680d406692e1db1b551e6
# Tested with GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.2.0)
# Usage: /path/to/tf_vars_sort.awk < variables.tf | tee sorted_variables.tf
# Note: "chmod +x /path/to/tf_vars_sort.awk" before use
# No licensing; yermulnik@gmail.com, 2021-2023
{
# skip blank lines at the beginning of file
if (!resource_type && length($0) == 0) next
# Note: real path is inventory_plugins/dummy.py (adjacent to playbook)
from ansible.plugins.inventory import BaseInventoryPlugin
DOCUMENTATION = """
name: dummy
author: Olvier Clavel (@zeitounator)
short_description: Dummy inventory demo plugin for https://stackoverflow.com/questions/66820243
description:
- This is an inventory plugin for pure demo and test.
- Do not use in production.
@m1keil
m1keil / README.md
Last active February 16, 2024 17:00
Configure Kibana to use SAML with Google Workspace (Google Apps, G Suite)

The following worked with Elastic Cloud, Elasticsearch & Kibana v7.6.0. It should be pretty close for other kinds of deployments. Before starting, make sure you have the right license level that allows SAML.

Create SAML App in Google Workspace:

  • Navigate to the SAML apps section of the admin console
  • Click the Add button and choose to "Add custom SAML app"
  • Write down the Entity ID and download the Idp metadata file
  • Choose application name, description and add logo
  • In the "Service Provider Details" screen add the following:
@max-rocket-internet
max-rocket-internet / prom-k8s-request-limits.md
Last active April 15, 2024 08:06
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) /
@eddiecorrigall
eddiecorrigall / jenkins_build_skip.md
Last active April 8, 2022 10:01
Jenkins: Build only when necessary

Build Only When Necessary

In testing environments, it is not always useful repeating tasks which can cost developers valuable time. Within a project its safe to assume that not all files are changed, so why rebuild?

This tutorial outlines a method to reduce unnecessarly build steps. Use your best judgement of course. It might be useful to add in a build on occassion to ensure third party dependencies are available and will not disrupt a production deployment.

Jenkins Setup

The git plugin in Jenkins provides several useful environment variables which can be used to avoid build tasks. Make sure you setup the git plugin before going any further.

@lukecav
lukecav / DNS Prefetch domains
Last active March 30, 2024 20:53
WP Rocket - Advanced Options Prefetch DNS requests examples
//maps.googleapis.com
//maps.gstatic.com
//fonts.googleapis.com
//fonts.gstatic.com
//ajax.googleapis.com
//apis.google.com
//google-analytics.com
//www.google-analytics.com
//ssl.google-analytics.com
//youtube.com
@gokulkrishh
gokulkrishh / media-query.css
Last active May 5, 2024 08:25
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
/* CSS */
@crisidev
crisidev / grafana-dashboard-exporter
Created October 7, 2015 20:35
Command to export all grafana 2 dashboard to JSON using curl
KEY=XXXXXXXXXXXX
HOST="https://metrics.crisidev.org"
mkdir -p dashboards && for dash in $(curl -k -H "Authorization: Bearer $KEY" $HOST/api/search\?query\=\& |tr ']' '\n' |cut -d "," -f 5 |grep slug |cut -d\" -f 4); do
curl -k -H "Authorization: Bearer $KEY" $HOST/api/dashboards/db/$dash > dashboards/$dash.json
done