Skip to content

Instantly share code, notes, and snippets.

View hartfordfive's full-sized avatar

Alain Lefebvre hartfordfive

View GitHub Profile
@hartfordfive
hartfordfive / gist:2cd190f1e1cd2ecdf04bfee57b34c464
Created August 17, 2023 14:15 — forked from ipedrazas/gist:403df2ed30ea8682e2b709ddc1c24bcf
curl internal service kubernetes kubectl proxy
# To call from outside the cluster a service type `ClusterIP`
# We use `kubectl proxy`
kubectl proxy
# Then, the service can be accessed by calling:
curl http://localhost:8001/api/v1/namespaces/status/services/x01-kstatus-api:5000/proxy/api/jobs
# This is
# curl http://localhost:8001/api/v1/namespaces/[NAMESPACE]/services/[SERVICE:PORT]/proxy/[QUERY_STRING]
@hartfordfive
hartfordfive / wsgiref_flask.py
Created April 27, 2023 21:31 — forked from 5j9/wsgiref_flask.py
running flask app using python's built-in wsgiref
# call this server using the following js command from the browser console:
# (await fetch('http://localhost:5000/', {method: "POST", body: '5'})).text()
# note: wsgiref is only good for development and in that case Werkzeug is
# usually preferred. See http://mitsuhiko.pocoo.org/wzdoc/wsgihowto.html
from wsgiref.simple_server import make_server
from flask import Flask, request, Response
app = Flask(__name__)
@hartfordfive
hartfordfive / README.md
Last active October 11, 2022 17:14 — forked from roidelapluie/gist:8c67e9c8fb18b310a4a90cb92a23056b
Prometheus alert on business days
  1. Implement the defined alerting conditions
  2. Set the following rule in the alerts: vector(1) and on() business_hour
@hartfordfive
hartfordfive / build-plugin-pack.sh
Created August 2, 2022 13:24
Create logstash offline plugin pack via a docker container
#!/bin/bash
logstash_version=8.1.3
logstash_plugin_release=1
logstash_plugin_pack_dir=/tmp/logstash
logstash_image=docker.elastic.co/logstash/logstash:${logstash_version}
logstash_input_plugin=$(echo '
logstash-input-beats
logstash-integration-kafka
@hartfordfive
hartfordfive / HttpProxy.go
Created July 8, 2022 01:07 — forked from yowu/HttpProxy.go
A simple HTTP proxy by Golang
package main
import (
"flag"
"io"
"log"
"net"
"net/http"
"strings"
)
@hartfordfive
hartfordfive / README.md
Last active January 12, 2023 12:25
Git pre-commit hook to verify committer email

Description

The goal of this hook is to allow you catch when you're committing with an email you shouldn't on a public repositories. In some cases, certain companies need to seperate their internal coporate email accounts from those that might be used for committing to public repositories.

Setting up.

The UNWANTED_EMAIL_SUFFIX should be the suffix (after the @ sign) of the email address you do not want to appear in the git logs. The DESIRED_AUTHOR_EMAIL and DESIRED_AUTHOR_NAME are the respective email and name you want to show up in the git logs.

Finding Elasticsearch Loggers

Description

In cases of advanced troubleshooting of Elasticsearch issues, it may be necessary at times to increase the verbosity of a specific logger within Elasticsearch. Unlike with Logstash, the loggers in Elasticsearch aren't specifically documented as there are far too many (thousands+).

Note: Running this tool will result in the cloning of the Elasticsearch repo locally if it doesn't already exist within the specified repo_dir

Command Usage

Syntax: es-logger-finder -r <PATH_TO_ELASTICSEARCH_GIT_DIR> -v <ES_MAJOR_MINOR_VERSION> -p '<LOGGER_PATTERN>' -c <CACHE_FILE_DIR> [-f|-d]
@hartfordfive
hartfordfive / eck-elasticsearch-diagnostics.sh
Created November 19, 2021 20:00
Script to create a diagnostic for Elasticsearch running with ECK
#!/bin/bash
show_help()
{
SCRIPT_NAME=$(basename $0)
echo "Generate a diagnostics dump of Elasticsearch cluster running on ECK."
echo
echo "Syntax: $SCRIPT_NAME -n <K8S_NAMESPACE> -c <ES_CLUSTER> -s <NODESET> [-h|-d]"
echo "options:"
echo "-c | --cluster Specify the Elasticsearch cluster"
@hartfordfive
hartfordfive / self-signed-certificate-with-custom-ca.md
Created February 9, 2021 19:47 — forked from fntlnz/self-signed-certificate-with-custom-ca.md
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096