Skip to content

Instantly share code, notes, and snippets.

View seancheung's full-sized avatar
😅

Sean seancheung

😅
  • Hangzhou, Zhejiang/China
View GitHub Profile
@seancheung
seancheung / kubeadm-install-offline.md
Created September 13, 2018 04:39 — forked from jgsqware/kubeadm-install-offline.md
Offline Kubeadm install

On master and nodes

Pull images form internet access laptop

docker pull gcr.io/google_containers/kube-apiserver-amd64:v1.5.0
docker pull gcr.io/google_containers/kube-controller-manager-amd64:v1.5.0
docker pull gcr.io/google_containers/kube-proxy-amd64:v1.5.0
docker pull gcr.io/google_containers/kube-scheduler-amd64:v1.5.0
docker pull weaveworks/weave-npc:1.8.2
docker pull weaveworks/weave-kube:1.8.2
@seancheung
seancheung / batchexec
Created November 8, 2017 09:49
exec commands on multiple remotes
#!/bin/bash
USERNAME=$(whoami)
declare -a HOSTS=(
hostname1
hostname2
hostname3)
for i in "${HOSTS[@]}"
@seancheung
seancheung / git-distributed-update.md
Last active November 8, 2017 07:59
git distributed update

create bare repo and workdir on master and slaves

cd ~
git init --bare projectname.git
mkdir projectname

create post-receive hooks on each slave

@seancheung
seancheung / multicopy
Created November 8, 2017 07:45
copy to multiple servers with scp
#!/bin/bash
USERNAME=username
WORK_DIR=/path/to/workdir
declare -a HOSTS=("hostname1" "hostname2" "hostname3")
function copy_files()
{
scp -r "$WORK_DIR" "$USERNAME"@"$1":"$WORK_DIR"
@seancheung
seancheung / post-receive
Created November 8, 2017 07:42
git post-receive hook(docker)
#!/bin/sh
WORK_BRANCH=production
WORK_DIR=/path/to/workdir
COMPOSE_FILE=/path/to/docker-compose.yml
SU_PWD=sudo_pass
SERVICE=service_name
CMD=command
restart()
@seancheung
seancheung / enable_bbr.sh
Created October 28, 2017 15:04
enable google bbr
#!/bin/bash
# get the latest linux kernel at http://kernel.ubuntu.com/~kernel-ppa/mainline/
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.14-rc6/linux-image-4.14.0-041400rc6-generic_4.14.0-041400rc6.201710230731_amd64.deb
# install the kernel
dpkg -i linux-image-4.*.deb
# update grub
# for linode, change kernel in boot settings to GRUB 2
#!/bin/bash
# step 1: 安装必要的一些系统工具
sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
# step 2: 安装GPG证书
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# Step 3: 写入软件源信息
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# Step 4: 更新并安装 Docker-CE
@seancheung
seancheung / .eslintrc.json
Last active September 7, 2017 02:06
es6-lint
{
"env": {
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 8
},
"rules": {
@seancheung
seancheung / slice.sh
Last active June 2, 2017 19:13
Slice images for making comic
#!/bin/bash
slice() {
DIR=$(gm identify -format %d "$1")
FILENAME=$(gm identify -format %t "$1")
EXTENSION=$(gm identify -format %e "$1")
WIDTH=$(gm identify -format %w "$1")
OFFSET=$((WIDTH/2))
if [ "$DIR" ]; then
FILENAME="${DIR}/${FILENAME}"
#/bin/sh
# Remove all stopped containers
docker rm $(docker ps -aq)
# Remove all untagged images
docker rmi $(docker images | grep "^<none>" | awk "{print $3}")