Skip to content

Instantly share code, notes, and snippets.

View pydevops's full-sized avatar
🏠
Working from home

Victor Yang pydevops

🏠
Working from home
View GitHub Profile
@mikesparr
mikesparr / cloudbuild-merge.yaml
Created August 21, 2020 03:54
Google Cloud Build PR merge
steps:
# Build image and push to GCR
- name: 'gcr.io/cloud-builders/docker'
id: Build
args:
- 'build'
- '-t'
- 'gcr.io/$PROJECT_ID/$_SERVICE_NAME:$SHORT_SHA'
- '.'
# TODO: look into [images]

Links:

https://kubernetes.io/docs/reference/kubectl/cheatsheet/
https://medium.com/faun/be-fast-with-kubectl-1-18-ckad-cka-31be00acc443
https://github.com/twajr/ckad-prep-notes#tasks-from-kubernetes-doc
https://github.com/saaguero/ckad-notes
https://github.com/dgkanatsios/CKAD-exercises
https://github.com/lucassha/CKAD-resources
https://eax.me/vim-commands/
https://discuss.kubernetes.io/t/kubectl-tips-and-tricks/
@mikesparr
mikesparr / gsutil-commands.md
Last active December 31, 2021 01:52
Google Cloud Storage Commands

Security

Assign IAM roles to buckets:

gsutil iam ch user:(user_email):(role1,role2) gs://(BUCKET)

Remove IAM role from bucket:

gsutil iam ch -d user:(user_email):(role1,role2) gs://(BUCKET)

Remove all roles from bucket for given user:

gsutil iam ch -d user:(user_email) gs://(BUCKET)

@max-rocket-internet
max-rocket-internet / prom-k8s-request-limits.md
Last active March 30, 2025 02:08
How to display Kubernetes request and limit in Grafana / Prometheus properly

CPU: percentage of limit

A lot of people land when trying to find out how to calculate CPU usage metric correctly in prometheus, myself included! So I'll post what I eventually ended up using as I think it's still a little difficult trying to tie together all the snippets of info here and elsewhere.

This is specific to k8s and containers that have CPU limits set.

To show CPU usage as a percentage of the limit given to the container, this is the Prometheus query we used to create nice graphs in Grafana:

sum(rate(container_cpu_usage_seconds_total{name!~".*prometheus.*", image!="", container_name!="POD"}[5m])) by (pod_name, container_name) /
@ruanbekker
ruanbekker / multipass_k3s_single_node.md
Created January 6, 2020 23:39
K3S Single Node with Multipass
@ruanbekker
ruanbekker / multipass_create_vm.md
Created January 6, 2020 23:26
Provision a VM with Multipass

Install Multipass on Mac

$ brew cask install multipass

Create a SSH Key

$ sh-keygen -b 2048 -f ~/.ssh/multipass -t rsa -q -N ""
@lucj
lucj / k3s-multipass.sh
Created December 17, 2019 21:16
Setup a k3s kubernetes cluster using Multipass VMs
for node in node1 node2 node3;do
multipass launch -n $node
done
# Init cluster on node1
multipass exec node1 -- bash -c "curl -sfL https://get.k3s.io | sh -"
# Get node1's IP
IP=$(multipass info node1 | grep IPv4 | awk '{print $2}')
@embano1
embano1 / README.MD
Created October 17, 2019 14:54
Bill kind

kindcfg

kind: Cluster
apiVersion: kind.sigs.k8s.io/v1alpha3
nodes:
- role: control-plane
  extraPortMappings:
  - containerPort: 5432
    hostPort: 5432
@robscott
robscott / kube-proxy-iptables-probability.md
Last active April 19, 2020 21:59
kube-proxy iptables probability

This shows the probabilities generated by kube-proxy 1.16 and rendered by iptables for the first 20 of 10k endpoints.

-A KUBE-SVC-DXWK7ADUC7EUTU7Z -m statistic --mode random --probability 0.00009999983 -j KUBE-SEP-JPQESVWHRDCVFZWN
-A KUBE-SVC-DXWK7ADUC7EUTU7Z -m statistic --mode random --probability 0.00009999983 -j KUBE-SEP-43X62NTQK7P33IRX
-A KUBE-SVC-DXWK7ADUC7EUTU7Z -m statistic --mode random --probability 0.00009999983 -j KUBE-SEP-RO4MGPWQFAAAQSOM
-A KUBE-SVC-DXWK7ADUC7EUTU7Z -m statistic --mode random --probability 0.00009999983 -j KUBE-SEP-U4U4WCN32VCO5JFK
-A KUBE-SVC-DXWK7ADUC7EUTU7Z -m statistic --mode random --probability 0.00009999983 -j KUBE-SEP-C4TELCOQRZ66JRHV
-A KUBE-SVC-DXWK7ADUC7EUTU7Z -m statistic --mode random --probability 0.00009999983 -j KUBE-SEP-ARSDZGCR5JG6RCWU
-A KUBE-SVC-DXWK7ADUC7EUTU7Z -m statistic --mode random --probability 0.00009999983 -j KUBE-SEP-QN4E7AOM7AQ62UWM
-A KUBE-SVC-DXWK7ADUC7EUTU7Z -m statistic --mode random --probability 0.00009999983 -j KUBE-SEP-3XQQML7Z2W4L2AI
@ryu1kn
ryu1kn / README.md
Last active March 7, 2025 07:31
Getting GCP access token from a service account key JSON file

Getting GCP access token from a service account key

Use your service account's key JSON file to get an access token to call Google APIs.

Good for seeing how things work, including the creation of JWT token.

To create a JWT token, you can replace create-jwt-token.sh script with tools like step.

If you just want to get an access token for a service account,