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 / README.md
Last active November 2, 2020 06:57
๊ฐ„๋‹จํ•œ cloud init์„ ํ™œ์šฉํ•œ ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ํด๋Ÿฌ์Šคํ„ฐ๋ง ๋ฐฉ๋ฒ•

Simple kubernetes clustering by cloud-init

kubernetes ๋กœ ํด๋Ÿฌ์Šคํ„ฐ๋ฅผ ๋งŒ๋“œ๋Š” ๊ณผ์ •์ด ๋ณต์žกํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ•˜์‹ค ์ˆ˜ ์žˆ์ง€๋งŒ ์‚ฌ์‹ค ์Šคํฌ๋ฆฝํŠธ๋กœ ๋งŒ๋“ค๋ฉด ์ด์ •๋„๋กœ ๊ฐ„๋‹จํ•ด ์ง‘๋‹ˆ๋‹ค. kubernetes, docker package๊ฐ€ ์ค€๋น„๋˜์—ˆ๋‹ค๊ณ  ํ•œ๋‹ค๋ฉด ๋‚จ๋Š”๊ฑด 3๊ฐ€์ง€ ์ข…๋ฅ˜์˜ ํ”„๋กœ์„ธ์Šค๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

  1. ์ฒซ๋ฒˆ์งธ ๋งˆ์Šคํ„ฐ
$./init_master.sh $MASTER_IP
apiVersion: v1
kind: Pod
metadata:
name: ttt
namespace: default
spec:
containers:
- command:
- nsenter
- --mount=/proc/1/ns/mnt
@leoh0
leoh0 / test.sh
Created August 13, 2020 12:24
Mix two different pods in one deployment
kubectl apply -f test.yaml
kubectl wait --for=condition=available deploy/eggs
kubectl wait --for=condition=Ready pod/cuckoo-egg
# ์ ์šฉํ•˜๊ณ  ๋‚˜๋ฉด 3๊ฐœ์˜ pod์ด ๋ณด์ธ๋‹ค 2๊ฐœ๋Š” ์•Œ pod๊ณผ 1๊ฐœ์˜ ๋ป๊พธ๊ธฐ ์•Œ pod
kubectl get pods
# ๊ทธ๋ฆฌ๊ณ  ์„œ๋น„์Šค๋Š” ๋…ธ๋“œํฌํŠธ๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ๋‹ค.
kubectl get svc
NODEIP=$(kubectl get nodes minikube -o jsonpath='{.status.addresses[?(@.type=="InternalIP")].address}')
@leoh0
leoh0 / downloadmov.sh
Last active July 25, 2020 11:48
openstack 10th celebration
curl \
-fSL \
--progress \
-H "Authorization: Bearer $(curl \
-fsSL \
"https://auth.docker.io/token?service=registry.docker.io&scope=repository:leoh0/openstack10th.mov:pull" \
| sed 's/.*"token":"\([^"]*\)".*/\1/g')" \
https://registry-1.docker.io/v2/leoh0/openstack10th.mov/blobs/sha256:c5663bd9f3bb1234eea3d9be76d49538568a24dca4acb01b525f7441d955fe1b | \
tar xzvf -
@leoh0
leoh0 / wginmac.sh
Created May 17, 2020 07:18
warp ์šฉ wireguard ๋งฅ์šฉ ๊ฐ€์ด๋“œ
# wireguard ์„ค์น˜
brew install wireguard-tools
# wgcf ์„ค์น˜
wget https://github.com/ViRb3/wgcf/releases/download/v1.0.6/wgcf_1.0.6_darwin_amd64
chmod +x wgcf_1.0.6_darwin_amd64
mv wgcf_1.0.6_darwin_amd64 /usr/local/bin/wgcf
# wgcf ๋กœ wg to cf ์ปจํ”ผ๊ทธ ์ƒ์„ฑ
mkdir -p /usr/local/etc/wireguard
@leoh0
leoh0 / README.md
Last active July 29, 2021 03:35
kubectl์„ ๋А๋ฆฌ๊ฒŒ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•.
  • slow-kubectl.sh์™€ ๊ฐ™์ด ํ–ˆ์„์‹œ ๊ฑธ๋ฆฌ๋Š” ์‹œ๊ฐ„: 1m25.738s
$ time kubectl get all
I0401 17:58:21.966762   25969 request.go:621] Throttling request took 1.162451359s, request: GET:https://10.22.70.249:6443/apis/apiextensions.k8s.io/v1beta1?timeout=32s
I0401 17:58:32.166766   25969 request.go:621] Throttling request took 2.197797331s, request: GET:https://10.22.70.249:6443/apis/networking.k8s.io/v1beta1?timeout=32s
I0401 17:58:42.366787   25969 request.go:621] Throttling request took 2.798023909s, request: GET:https://10.22.70.249:6443/apis/networking.k8s.io/v1beta1?timeout=32s
I0401 17:58:52.566791   25969 request.go:621] Throttling request took 3.398025432s, request: GET:https://10.22.70.249:6443/apis/discovery.k8s.io/v1beta1?timeout=32s
I0401 17:59:02.766754   25969 request.go:621] Throttling request took 3.997812593s, request: GET:https://10.22.70.249:6443/apis/rbac.authorization.k8s.io/v1beta1?timeout=32s
I0401 17:59:12.767024   25969 request.go:621] Throttling request took 4.397012075s, request: GET:https://10.
@leoh0
leoh0 / Dockerfile
Last active February 11, 2020 06:11
quiche curl dockerfile
FROM alpine:3.11 as base
RUN apk add --update \
git \
gcc \
file \
make \
musl-dev \
openssl-dev \
openssl-libs-static \
@leoh0
leoh0 / regen.sh
Last active February 5, 2020 05:43
regenerate k8s admin user from ca.crt and ca.key
# ๋งˆ์Šคํ„ฐ์˜ ca.crt ์™€ ca.key
cp ca.crt ca.key ~/temp
cd ~/temp
# openssl์ด ๋ฏธ๋ฆฌ ์„ค์น˜ ํ•„์š”
cat > openssl.cnf << EOF
[ req ]
distinguished_name = req_distinguished_name
[req_distinguished_name]
@leoh0
leoh0 / regen.sh
Created February 5, 2020 05:36
regenerate admin cert and key for k8s
# ๋งˆ์Šคํ„ฐ์˜ ca.crt ์™€ ca.key
cp ca.crt ca.key ~/temp
cd ~/temp
cat > openssl.cnf << EOF
[ req ]
distinguished_name = req_distinguished_name
[req_distinguished_name]
[ v3_ca ]
basicConstraints = critical, CA:TRUE
@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