Skip to content

Instantly share code, notes, and snippets.

View oilbeater's full-sized avatar
🎯
Focusing

Mengxin Liu oilbeater

🎯
Focusing
View GitHub Profile
@oilbeater
oilbeater / manifest.sh
Created June 28, 2024 02:08
release kube-ovn images
#!/bin/bash
set -x
docker manifest rm kubeovn/kube-ovn:${VERSION}
docker manifest rm kubeovn/vpc-nat-gateway:${VERSION}
docker pull kubeovn/kube-ovn:${VERSION}-x86
docker pull kubeovn/kube-ovn:${VERSION}-arm
docker pull kubeovn/vpc-nat-gateway:${VERSION}-x86
docker pull kubeovn/vpc-nat-gateway:${VERSION}-arm
@oilbeater
oilbeater / gist:6e8c7359cc4283168e567ecfa6743a08
Created April 30, 2024 07:59
describe how linux memory management work with watermark
Linux memory management is a complex system designed to efficiently allocate and manage system memory resources across various processes. The concept of watermarks is crucial in this system, playing a significant role in balancing memory allocation and ensuring system stability. Here's a simplified explanation of how memory management works in Linux, particularly focusing on the role of watermarks:
### 1. **Memory Zones**
Linux divides physical memory into several zones, such as DMA (Direct Memory Access), DMA32, and Normal zones. These divisions are based on memory addressing limitations of hardware devices and other architectural requirements.
### 2. **Pages**
The fundamental unit of memory management in Linux is the page. Memory allocation requests from processes are handled in terms of pages.
### 3. **Watermarks**
Each memory zone in Linux has defined watermarks, which are thresholds used to manage memory pressure and availability. There are typically three watermark levels in each zone:
@oilbeater
oilbeater / close.sh
Last active March 8, 2024 10:58
shut down when ssh idle for more than 5 minutes
#!/bin/bash
# docker run --name=close --network=host --privileged --restart=always -d close:v0.0.1
while true; do
if [ -f dump ]; then
rm dump
fi
timeout 5m tcpdump -nn tcp and port 22 and greater 44 -w dump
yum install -y yum-utils
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io
systemctl enable docker
systemctl start docker
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
#!/usr/bin/env bash
set -euo pipefail
REGISTRY="index.alauda.cn/alaudak8s"
POD_CIDR="10.16.0.0/16" # Do NOT overlap with NODE/SVC/JOIN CIDR
SVC_CIDR="10.96.0.0/12" # Do NOT overlap with NODE/POD/JOIN CIDR
JOIN_CIDR="100.64.0.0/16" # Do NOT overlap with NODE/POD/SVC CIDR
VERSION="v1.0.0"
echo "[Step -1] Delete flannel and galaxy resource on host"
@oilbeater
oilbeater / prome-http-handler
Created February 11, 2020 02:41
Prometheus HTTP Handler
package main
import (
"net/http"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
func main() {
http.Handle("/metrics", promhttp.Handler())
@oilbeater
oilbeater / resolv-conf-reset.md
Last active November 18, 2019 02:14
generated by networkmanager resolv.conf

edit /etc/sysconfig/network-scripts/ifcfg-eth0

it will looks like

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
8.2.3. HTTP log format
----------------------
The HTTP format is the most complete and the best suited for HTTP proxies. It
is enabled by when "option httplog" is specified in the frontend. It provides
the same level of information as the TCP format with additional features which
are specific to the HTTP protocol. Just like the TCP format, the log is usually
emitted at the end of the session, unless "option logasap" is specified, which
generally only makes sense for download sites. A session which matches the
"monitor" rules will never logged. It is also possible not to log sessions for
@oilbeater
oilbeater / cali_rule.sh
Created July 2, 2017 06:11
Modify calico route rules.
#!/bin/bash
while :
do
address=`ifconfig bond0 | grep inet | grep -v inet6|awk '{print $2}'`
echo $address
ip route | grep cali | grep -v src | while read -r line ;
do
ip route replace $line src $address
@oilbeater
oilbeater / dummy-web-server.py
Last active June 23, 2017 03:29 — forked from bradmontgomery/dummy-web-server.py
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/usr/bin/env python
"""
Very simple HTTP server in python.
Usage::
./dummy-web-server.py [<port>]
Send a GET request::
curl http://localhost