Skip to content

Instantly share code, notes, and snippets.

View leoh0's full-sized avatar
🕶️
Working

Eohyung Lee leoh0

🕶️
Working
View GitHub Profile
@leoh0
leoh0 / add_port_to_master.sh
Last active August 7, 2020 00:04
Example of adding another port to master server, this script is for IPTABLE backend only. If you create this to IPVS backend cluster then you will break all of the cluster.
############# CAUTION!!! #############
# DON'T USE THIS YAML TO IPVS CLUSTER
# IT WILL BREAK ALL OF THE CLUSTER
############# CAUTION!!! #############
apiVersion: v1
kind: Service
metadata:
name: pf
spec:
externalIPs:
@leoh0
leoh0 / default-backend-to-legacy-service.sh
Created September 24, 2019 06:01
default backend to legacy service
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: default-backend-to-legacy-service
spec:
backend:
serviceName: legacy-service
servicePort: 80
---
@leoh0
leoh0 / multi.sh
Last active September 18, 2019 09:17
k8s get multi shell & get multiple pods logs based on its label
# NOTE: Please install kubectl, fzf, stern, tmux first before using this functions
# NOTE: 사용전에 kubectl, fzf, stern, tmux 를 먼저 설치하세요.
# Choose multiple pods using `TAB` and then get their shells using `ENTER`.
# TAB으로 pod들을 선택하고 ENTER로 그 pod들의 shell을 동시에 얻습니다.
function multi_login() {
pods=$(kubectl get pods --all-namespaces | sed '1d' | fzf -x -m -e +s --reverse --bind=left:page-up,right:page-down --no-mouse | awk '{print $1","$2}')
if [[ $pods != "" ]]; then
init="true"
tmuxname=k8s-ns-$(date +%s)
@leoh0
leoh0 / README.md
Last active September 9, 2019 08:08
google cloud shell을 이용해서 proxy 서버로 사용해서 공짜로 vpn처럼 이용하기

google cloud shell을 이용해서 proxy 서버로 사용해서 공짜로 vpn처럼 이용하기

google cloud shell은 public ip가 없는 private ip만 있는 container입니다. 즉 외부 접근은 google client들을 통해서만 접근이 가능한데 이런 자원들을 가지고 외부에 접근 하는 proxy만드는 법에 대한 소개입니다.

MYNOTEBOOK 이 내가 접속하고 있는 chrome을 띄울 pc라고 보시면 됩니다. 물론 보통은 포트포워딩 해서 접속 할 수 있게 열어야 한다고 보시면 됩니다.

docker run -ti \
@leoh0
leoh0 / create_pod_by_curl_in_pod.sh
Last active April 21, 2020 22:56
pod 안에서 pod 만들기 예제
# pod 생성을 위한 준비
kubectl create sa a
kubectl create role a --verb=create --resource=pod
kubectl create rolebinding a --role=a --serviceaccount=default:a
# pod 하나 생성
cat << EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
curl -s \
--cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt \
-H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" \
-H 'Content-Type: application/json' \
-d'{"apiVersion":"v1","kind":"Pod","metadata":{"name":"nginx"},"spec":{"containers":[{"name":"nginx","image":"nginx","ports":[{"containerPort":80}]}]}}' \
https://kubernetes.default.svc/api/v1/namespaces/$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)/pods
@leoh0
leoh0 / README.md
Last active April 25, 2019 11:15
github contribution as a calendar

Setup

# COMMIT_USERNAME is for your commit user name
export COMMIT_USERNAME="Eohyung Lee"

# COMMIT_USERNAME is for your commit email
export COMMIT_USEREMAIL=liquidnuker@gmail.com

# GITHUB_USERNAME is for github user name(or organization name)
#!/bin/bash
curl -fSL \
--progress \
-H "Authorization: Bearer $(curl -fsSL \
"https://auth.docker.io/token?service=registry.docker.io&scope=repository:leoh0/kakaotalk:pull" | \
sed 's/.*"token":"\([^"]*\)".*/\1/g')" \
https://registry-1.docker.io/v2/leoh0/kakaotalk/blobs/sha256:030ac842b5fc9f2a86056a93bbf8c4f706b33db131952f1f571c28013f266bfc | \
tar xzvf -
#!/bin/bash
function ensure_privileged_or_exit() {
grep -xq $'CapBnd:\t0000003fffffffff' /proc/self/status || \
(echo -e "[ERROR] Run with --privileged option." ; exit 1)
}
### Main
ensure_privileged_or_exit
@leoh0
leoh0 / install.sh
Last active March 21, 2019 08:50
install manjaro
#!/bin/bash
set -e
set -o pipefail
# install.sh
# This script installs my basic setup for a manjaro laptop
# Choose a user account to use for this installation
get_user() {
if [ -z "${TARGET_USER-}" ]; then