Skip to content

Instantly share code, notes, and snippets.

View migueleliasweb's full-sized avatar

Miguel Elias dos Santos migueleliasweb

  • Sydney, Australia
  • 05:05 (UTC -12:00)
View GitHub Profile
@qlawmarq
qlawmarq / clone-k8s-deployment.sh
Created July 18, 2023 05:00
Clone kubernetes(k8s) deployment
# The following is an example of a command to clone an development(ex-app-development) as an production(ex-app-production).
kubectl get deployment ex-app-development -o json \
| jq '.metadata.name = "ex-app-production"' \
| kubectl apply -f -
@robbertvanginkel
robbertvanginkel / index.js
Last active April 12, 2025 15:18
gRPC on workers
// Turn on gRPC for domain using
// https://developers.cloudflare.com/support/network/understanding-cloudflare-grpc-support/#enable-grpc, then CF
// rewrites grpc requests to grpc-web (like a reverse envoy filter, see https://blog.cloudflare.com/road-to-grpc/#converting-to-http-1-1)
// which can be handled by workers. Does not work with workers.dev.
export default {
async fetch(request, env, context) {
// Use a stream so CF doesn't add content-lenght
// which would prevent grpc-web -> grpc conversion.
const { readable, writable } = new TransformStream();
let writer = writable.getWriter();
@lukeplausin
lukeplausin / auto_configure_aws_cli_sso_roles.sh
Last active February 3, 2025 09:28
Automatically configure AWS SSO configuration file for all available accounts and roles
#!/bin/bash -e
# How to use this script:
# 1. Follow these instructions to configure a single AWS account to do initial login with SSO
# https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html
# 2. Export AWS_PROFILE=... and then run "aws sso login" to get an SSO token
# 3. Once signed in with AWS SSO, run this script to automatically list out all the other accounts and roles and add them to your config file
# If you want to filter roles / accounts in the process, or validate config before committing it, you can customise the script to do this.

Parse the kubernetes manifest in yaml or json, don't care a manifest type.

Examples:

package main

import (
	"bytes"
	"context"

Create a multi-node kind cluster and with a different kubernetes version than default

The instructions in this tutorial are not WSL2 specific, but if you would like to see how to get started with kind in WSL2 (and afterwards follow along with this tutorial), do have a look at this video.

How to create a local multi-node Kubernetes cluster with kind

In order to create a multi-node cluster with kind, we need to create a configuration file. Let's say we want to create a 3 node cluster, 1 control-plane and 2 workers, we would then create the following configuration file (you can save it as kind-config.yaml):

kind: Cluster
#!/usr/bin/ruby
require 'json'
require 'net/http'
require 'shellwords'
require 'time'
require 'uri'
require 'yaml'
@target_sidecar_image = YAML.load(YAML.load(`kubectl --namespace=istio-system get configmap istio-sidecar-injector -o yaml`)['data']['config'])['template'].match(/.*(eu.gcr.io\/at-artefacts\/platform-istio-proxy.*)".*/)[1]
@miguelmota
miguelmota / command_exists.go
Last active October 31, 2024 04:48
Golang check if command exists
package main
import (
"log"
"os/exec"
)
func main() {
path, err := exec.LookPath("ls")
if err != nil {
@posener
posener / go-table-driven-tests-parallel.md
Last active April 24, 2025 20:46
Be Careful with Table Driven Tests and t.Parallel()

Be Careful with Table Driven Tests and t.Parallel()

We Gophers, love table-driven-tests, it makes our unittesting structured, and makes it easy to add different test cases with ease.

Let’s create our table driven test, for convenience, I chose to use t.Log as the test function. Notice that we don't have any assertion in this test, it is not needed to for the demonstration.

func TestTLog(t *testing.T) {
	t.Parallel()
@olpoco
olpoco / fedora.md
Last active March 3, 2018 10:24
Installing Fedora 23 on Macbook Pro Retina 2016, and attaching Airport Extreme

Installing Fedora on Macbook Pro retina

  1. Download Fedora 23 iso, create a usb bootable media Follow instructions here Basically,
  2. use diskutil list to figure out which drive is the usb, on macbook pro with 1 hardrive, the usb is /dev/disk2
  3. umount the disk using diskutil unmountDisk /dev/disk2 or use Mac's Disk Utility (just umount, don't eject, umount removes it from directory structure and eject disconncet it altogether)
  4. use dd(a low level cp) to write iso content into the usb drive, sudo dd if=~/Downloads/Fedora-Live-Desktop-x86_64-20-1.iso of=/dev/disk2 bs=1m, this will take a bit of time, make sure you wait until it's done, additionally compare the size or checksum to make sure all has been copied (not that necessary since if it weren't copied, it'll err at boot time)
  5. use Disk Utility to shrink Mac's harddrive
@vdm
vdm / ixgbevf-upgrade.sh
Last active November 28, 2019 21:35
ixgbevf 2.16.1 upgrade for AWS EC2 SR-IOV "Enhanced Networking" on Ubuntu 14.04 (Trusty) LTS
ssh [email protected] "bash -s -x" -- <ixgbevf-upgrade.sh