Skip to content

Instantly share code, notes, and snippets.

smijar /
Created March 24, 2023 04:25
Prometheus histogram instrumentation example

to run example

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

# 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 / 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 (
# 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
name: nginx
smijar /
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":"", "password":"password"}' | jq -r '.token')
curl -H "Content-Type:application/json" -H "Authorization: Bearer $JWT_TOKEN" $@
smijar / albums.go
Created December 15, 2022 03:10
Gin Gonic REST sample
package main
import (
// album represents data about a record album.
type album struct {
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
smijar / examples.ref
Last active September 30, 2022 01:40
Multipass VM with nginx, docker, kind
# description
below we show some examples of running containers under docker with KKM
# examples
$ docker run -d --rm -p 8080:8080 --runtime=krun --name spring-boot-hello kontainguide/spring-boot-hello:1.0
$ curl http://localhost:8080
# python
$ docker run -d --rm -p 5000:5000 --runtime=krun --name py-flask-hello kontainguide/py-flask-hello:1.0

install knative plugins locally

# ref:
echo "installing knative with kind cluster..."
echo "downloading kn CLI"
sudo curl -s -Lo /usr/local/bin/kn
sudo chmod +x /usr/local/bin/kn
sleep 2

patching knative cluster for allowing addition of "runtime class" kind for functions

export config map to see what is in it

kubectl get configmap/config-features -n knative-serving -o yaml

then patch it with a merge

echo "patching configmap/config-features to enable podspec.runtimeclassname for installing KM..."