Skip to content

Instantly share code, notes, and snippets.

View protosam's full-sized avatar
🎉
just building on k8s

Sam protosam

🎉
just building on k8s
  • San Antonio, TX
View GitHub Profile

Bash can connect to stuff without the need for curl or nc.

exec 3<> /dev/tcp/google.com/80
echo -e 'GET / HTTP/1.1\r\nhost: www.google.com\r\nConnection: close\r\n\r\n' >&3
cat <&3

# result: 
# HTTP/1.1 200 OK
# Expires: -1
#!/bin/bash
# detect mac os
if ! uname | grep -i -q darwin; then
echo "ERROR: Only Mac OS is supported."
exit 1
fi
# kill docker desktop
DOCKER_DESKTOP_PID=$(ps aux | grep '/Applications/Docker\.app/Contents/MacOS/Docker$' | awk '{print $2}')
@protosam
protosam / 0 - BASH Scripting Tricks.md
Last active May 12, 2023 21:18
BASH Scripting Tricks

BASH Scripting Tricks

Overview

This example shows how to generate something like a random password and keeping it consistent during upgrades.

Note About Better Security

IF YOU CAN, you should let helm generate a random secret during every upgrade and update the app to rotate the password from old one to new one. There are many options available by means of jobs and hooks to figure this out.

Walkthrough

Create a new helm chart with with no templates.

% helm create chart-name

Mac OS uses LibreSSL. Getting OpenSSL can be done with brew:

brew install openssl

After which, an alias can be used for openssl commands:

ls -lah $(echo /opt/homebrew/Cellar/openssl@*/*/bin/openssl)
alias openssl=/opt/homebrew/Cellar/openssl@1.1/1.1.1s/bin/openssl

Simple makefile to simplify building and installing this vscode extension locally: github.com/tintinweb/vscode-interactive-graphviz

Build from specific branch:

CHECKOUT=110-formatter-deletes-comments-and-all-whitespace-on-save make build

Install the vsix that was packaged:

make install
$ curl -o ~/.shrc https://gist.githubusercontent.com/protosam/74ac72cbbf27c51296a87aa55acab71d/raw/.shrc.sh
$ ln -s ~/.shrc ~/.bashrc
$ ln -s ~/.shrc ~/.zshrc
$ curl -o ~/.profiles.d/kubernetes https://gist.githubusercontent.com/protosam/74ac72cbbf27c51296a87aa55acab71d/raw/profiles.d.kubernetes.sh

These notes were compiled from a fresh installation on Ubuntu 20.04. The resulting Openstack installation is really just good for local development.

The network was on Google Wifi pucks. There is some additional notes about how to handle accessing the Openstack network in the routes section

My network network details are as follows.

  • Gateway 192.168.86.1
  • Subnet 192.168.86.0/24
  • Host IP 192.168.86.152
    • This was through DHCP and will cause problems if the computer ever loses it's lease.

Relevant Resources

User accounts are a part of the user.openshift.io group. The kinds available are

groups / group
identities / identity
users / user
useridentitymappings / useridentitymapping

Users have identities mapped directly on the user CR. The useridentitymapping CR seems to be just API related.

@protosam
protosam / about.md
Last active February 28, 2022 20:23
This is a script I wrote to automatically restart godoc whenever Go code is updated on my Macbooks. It is stored at ~/bin/godoc and ~/bin/ is a part of my Linux path.

This is a script I wrote to automatically restart godoc whenever Go code is updated on my Macbooks. It is stored at ~/bin/godoc and ~/bin/ is a part of my Linux path.