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 / heat-basic-image-deployment.yaml
Last active January 2, 2020 03:36
Create cirros image by heat template
# http://docs.openstack.org/developer/heat/template_guide/hot_spec.html#heat-template-version
heat_template_version: 2014-10-16
# This template is the equivalent of the command set:
# $ wget http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
# $ glance image-create --name='cirros image' --container-format=bare --disk-format=qcow2 < cirros-0.3.5-x86_64-disk.img
# or:
# $ glance --os-image-api-version 1 image-create --name='cirros image' --container-format=bare --disk-format=qcow2 --location http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
@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