Skip to content

Instantly share code, notes, and snippets.

@smijar
smijar / k3d-install-dashboard.md
Created April 22, 2020 00:50
k3d-install-dashboard

ref

https://rancher.com/docs/k3s/latest/en/installation/kube-dashboard/

install

Deploying the Kubernetes Dashboard

GITHUB_URL=https://github.com/kubernetes/dashboard/releases
VERSION_KUBE_DASHBOARD=$(curl -w '%{url_effective}' -I -L -s -S ${GITHUB_URL}/latest -o /dev/null | sed -e 's|.*/||')
kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/${VERSION_KUBE_DASHBOARD}/aio/deploy/recommended.yaml
@smijar
smijar / install-jdk-on-centos.snippets
Last active January 20, 2024 02:40
Installing JDK 7 or 8 on centos 7/8
# from https://www.digitalocean.com/community/tutorials/how-to-install-java-on-centos-and-fedora
# JDK 7
#------
# Change to your home directory and download the Oracle Java 7 JDK RPM with these commands:
cd ~
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.rpm"
# Then install the RPM with this yum command (if you downloaded a different release, substitute the filename here):
sudo yum localinstall jdk-7u79-linux-x64.rpm
@smijar
smijar / k3d-create-cluster-no-traefik.sh
Last active January 9, 2024 17:38
k3d create cluster without traefik and serverlb
# Possibly obsolete: k3d create --name testcls1 --workers 3
k3d create --name testcls1 --workers 3 --server-arg "--no-deploy=traefik" --server-arg "--no-deploy=servicelb"
# UPDATE: in newer versions onwards, this has evolved to (thanks to comments below):
k3d cluster create --k3s-arg "--no-deploy=traefik@server:*"
@smijar
smijar / k3d-lb-demo.md
Last active July 13, 2023 01:14
k3d loadbalancer demo
@smijar
smijar / readme.md
Created March 24, 2023 04:25
Prometheus histogram instrumentation example

to run example

# term 1
cd histo-example
go clean && go build .
./histo-example

# term 2 - run some load
for i in {1..100000};do curl http://localhost:2112/hello1; curl http://localhost:2112/hello2; sleep 0.5; done
@smijar
smijar / metrics_example1.go
Last active March 22, 2023 18:26
golang example to instrument code to generate and client library to Parse (extra) Prometheus metrics
package metrics_examples
import (
"net/http"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
# To deploy: kubectl apply -f nginx-hello-world-deployment.yaml
# Access it with the API as a proxy:
# $ kubectl proxy
# Then in your browser: http://localhost:8001/api/v1/namespaces/default/services/nginx:/proxy/#!/
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
@smijar
smijar / jcurl.sh
Created January 6, 2023 18:57
Retrieves JWT token and uses it for "curl" calls
export JWT_TOKEN=$(curl -s -H "Content-Type:application/json" -XPOST http://localhost:8080/tokenz -d '{"email":"youremail@youremaildomain.app", "password":"password"}' | jq -r '.token')
curl -H "Content-Type:application/json" -H "Authorization: Bearer $JWT_TOKEN" $@
@smijar
smijar / albums.go
Created December 15, 2022 03:10
Gin Gonic REST sample
package main
import (
"net/http"
"github.com/gin-gonic/gin"
)
// album represents data about a record album.
type album struct {
@smijar
smijar / envs.txt
Last active November 17, 2022 15:19
Using pandas to read CSV and convert each row into a dictionary
canadacentral env-1 demogroup-1
westus env-2 demogroup-1
westus env-3 demogroup-1
westus env-4 demogroup-1
westus env-5 demogroup-1
uksouth env-1 demogroup-2
canadacentral env-2 demogroup-2
canadacentral env-3 demogroup-2
canadacentral env-4 demogroup-2