Skip to content

Instantly share code, notes, and snippets.

@tennix
tennix / fluent-bit-config.yaml
Created May 6, 2020 04:04
fluend/fleunt-bit log parser config for TiDB
apiVersion: v1
kind: ConfigMap
metadata:
name: fluent-bit-config
labels:
app: fluent-bit
data:
fluent-bit-service.conf: |-
[SERVICE]
Flush 1
@tennix
tennix / README.md
Created October 22, 2019 12:49
k8s dns checker

To verify if the DNS service is normal in a Kubernetes cluster. We can deploy a simple service to diagnose this:

$ kubectl apply -f nginx.yaml
$ kubectl exec -it web-0 sh # enter web-0 pod to resolve the other two pods domain name.
/ # nslookup web-1.nginx
/ # nslookup web-2 nginx
@tennix
tennix / dashbord-to-jsonnet.py
Last active April 7, 2024 08:35
Convert Grafana dashboard json to jsonnet
#!/usr/bin/env python
import json
from jinja2 import Template
# git clone https://github.com/pingcap/tidb-docker-compose
# cd tidb-docker-compose
# git clone https://github.com/tennix/grafonnet-lib -b table
# python dashboard-to-jsonnet.py > pd.jsonnet
# jsonnet -J grafonnet-lib pd.jsonnet > config/dashboards/generated-pd.json
with open('config/dashboards/pd.json', 'r') as f:
data = json.load(f)
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
selector:
matchLabels:
app: nginx
replicas: 3
template:
@tennix
tennix / startup-script-ds.yaml
Created February 13, 2019 12:47
Optimize GKE local SSD disk
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: startup-script
namespace: kube-system
labels:
app: startup-script
spec:
template:
metadata:
@tennix
tennix / local_volume_provisioner-gce_ssd.yaml
Last active March 21, 2020 14:50
local volume provisioner for gke local ssd with nobarrier mount option
# This file is copied from https://github.com/kubernetes-incubator/external-storage/blob/master/local-volume/provisioner/deployment/kubernetes/gce/provisioner_generated_gce_ssd_count.yaml
# but namespace is changed to `kube-system` and add a disk-remounter init container
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: "local-scsi"
provisioner: "kubernetes.io/no-provisioner"
volumeBindingMode: "WaitForFirstConsumer"
---
@tennix
tennix / disk-benchmark-statefulset.yaml
Created August 28, 2018 03:40
TiDB benchmark on GKE
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: disk-benchmark
spec:
replicas: 1
selector:
matchLabels:
app: disk-benchmark
serviceName: disk-benchmark
@tennix
tennix / latency.txt
Created March 10, 2016 02:57 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@tennix
tennix / springer-free-maths-books.md
Created December 29, 2015 11:52 — forked from bishboria/springer-free-maths-books.md
Springer have made a bunch of books available for free, here are the direct links