Skip to content

Instantly share code, notes, and snippets.

View stevehenderson's full-sized avatar

Steve Henderson stevehenderson

View GitHub Profile
@stevehenderson
stevehenderson / cloudbuild_debugging.yaml
Created May 7, 2022 18:52
Google CloudBuild folder location debugging
# Add the following step to kick some helpful debugging about what's in your google cloud build container!
- id: "Read Values"
name: ubuntu
dir: '/workspace'
entrypoint: bash
args:
- -c
- |
# Read from "/workspace"
echo "Where am I " $(pwd)
@stevehenderson
stevehenderson / hostToIP.go
Created April 23, 2022 14:48
Replace K8s namespace with IP
//
// Looks up a host using the resolver and returns an IP.
// Utility function for testing against K8s over VPN.
// Resolver should be the POD ip of kube-dns
//
func hostToIP(host string, resolver string) string {
fmt.Printf("Looking up %s using resolver %s\n", host, resolver)
r := &net.Resolver{
PreferGo: true,
Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
@stevehenderson
stevehenderson / install_elastic.sh
Created March 25, 2022 03:03
Install Elasticsearch Ubuntu 20
curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
sudo apt update
sudo apt install elasticsearch
@stevehenderson
stevehenderson / uptime_bot_heartbeat.py
Last active March 22, 2022 03:36
UptimeBot Heartbeat Script
import requests
import time
def contact_monitor():
print("Calling the monitor...")
r= requests.get("https://heartbeat.uptimerobot.com/m11111111-11111111111111111111111111")
while 1==1:
time.sleep(30)
try:
@stevehenderson
stevehenderson / StatefuleSetGetAll.go
Created March 18, 2022 14:37
Get K8s StatefulSet
import (
appsv1 "k8s.io/api/apps/v1"
)
// StatefulSetGetAll returns all STS for the managed cluster
func (mgr *manager) StatefulSetGetAll() *appsv1.StatefulSetList {
stslister, err := mgr.k8sclient.AppsV1().StatefulSets("").List(context.TODO(), metav1.ListOptions{})
if err != nil {
fmt.Println("error getting StatefulSetGetAll: ", err)
}
@stevehenderson
stevehenderson / revprox.go
Created March 11, 2022 15:22 — forked from JalfResi/revprox.go
Simple reverse proxy in Go
package main
import(
"log"
"net/url"
"net/http"
"net/http/httputil"
)
func main() {
@stevehenderson
stevehenderson / default.conf
Created March 6, 2022 05:46
Elastic Kibana XPACK Behind Reverse NGINX Proxy
server {
listen 443 ssl;
server_name ~^kibanasub\.;
root /www/cluster;
ssl_certificate /etc/nginx/certificates/cert1.pem;
ssl_certificate_key /etc/nginx/certificates/privkey1.pem;
ssl_protocols TLSv1.2 TLSv1.3;
@stevehenderson
stevehenderson / github_container_registry.md
Created January 29, 2022 17:35
Github Container Registry

Github Docker Container registry

Set up Docker for github package repo access (One time step):

You'll need a PAT with package write permissions

Then:

@stevehenderson
stevehenderson / graphqlclientlog.md
Created January 23, 2022 15:31
How to increase the machinebox/graphql logging

When using the GraphQL machinebox go library, you can tak control of logging as follows:

graphqlclient.Log = func(s string) { log.Printf("YO: %s",s) }
@stevehenderson
stevehenderson / git_clone_docker.md
Last active January 18, 2022 15:28
Prevent Docker from Caching Git Clone

Issue: When pulling from github inside docker, it won't update the cached docker image.

You can force it to by using the git api to pull down the latest commit meta data and saving that to the image. This works and stays in synch with every new update to your repo, which you want to pull. No commits mean no new meta data so your docker will use the cached version. If you commits, this makes a new SHA which gets pulled in the API, invalidating cached

ADD https://$GIT_PAT@api.github.com/repos/some_org/some_repo/git/refs/heads cachebust
RUN git clone https://$GIT_PAT_IN@github.com/some_org/some-repo-git.git