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 / kubectl-root-in-host-nopriv.pks.sh
Created May 6, 2021 05:06 — forked from jjo/kubectl-root-in-host-nopriv.sh
Yeah. Get a root shell at any Kubernetes *node* via `privileged: true` + `nsenter` sauce. PodSecurityPolicy will save us. DenyExecOnPrivileged didn't (kubectl-root-in-host-nopriv.sh exploits it)
#!/bin/sh
# Launch a Pod ab-using a hostPath mount to land on a Kubernetes node cluster as root
# without requiring `privileged: true`, in particular can abuse `DenyExecOnPrivileged`
# admission controller.
# Pod command in turn runs a privileged container using node's /var/run/docker.sock.
#
# Tweaked for PKS nodes, which run their docker stuff from different
# /var/vcap/... paths
node=${1}
case "${node}" in
@leoh0
leoh0 / README.md
Last active March 22, 2021 11:52
쿠버네티스 안에서 특정 트래픽을 특정 노드로 보내는 "무난하지 않은" 방법

쿠버네티스 안에서 특정 트래픽을 특정 노드로 보내는 "무난하지 않은 방법"

우선 이걸 보기전에 쿠버네티스 안에서 특정 트래픽을 특정 노드로 보내는 "무난한" 방법을 보는게 좋다. 대충, 나가야 하는 노드에 squid 같은 reverse proxy를 두고 보내는 팟에서 해당 pod으로 http_proxy등을 이용해서 트래픽을 보내는 방법 과 같은 전통적인 방법이다.

그렇다면 "무난하지 않은" 방법은 무엇일까? 여기서 사용하는 방법들은 악용의 소지들이 다분하고 어느정도 k8s의 보안홀들을 이용하는 방법들이다.

우선 위와 같은 방법은 트래픽을 보내는 pod의 사용자가 온전히 보내야 하는 트래픽을 신경써야 하는 상태이다. 그렇다면 이렇게 하지 않는 방법은 무엇일까?

@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 / 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 / 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 / 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:
@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 \