cylonchau / pod-proxier

pod调试代理
1 stars 0 forks source link

how tu use it #1

Closed Faker523 closed 2 months ago

Faker523 commented 3 months ago

can you speak clearly how to use this tool? tks

cylonchau commented 2 months ago

First, build the image

git clone xxx
# select your kubernetes version
# this step must be installed go
bash hack/mod.sh 1.28.12
# build image
docker build -t my-running-haproxy:x . 

second change configuration

change haproxy.cfg

change your password here, this is haproxy dataplane need.

userlist haproxy-dataplaneapi
  user admin insecure-password 1fc917c7ad66487470e466c0ad40ddd45b9f7730a4b43e1b2542627f0596bbdc

thrid change kubernetes deployment

Note the start paramter

  /apps/pod-proxier-gateway
  --v 5
  --jprofiler-port-name=test
# this is map port, you can throght this port access to pod port
  --default-map-port=8848
# pod name , just this configration (in deployment spec port name) can be work
  --jprofiler-port-name=jprofiler
  --resync-time=60

set you map port container

this example is pod mapping, pls change deployment ports section.

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: portest
  name: portest
  namespace: kube-system
spec:
  selector:
    matchLabels:
      app: portest
  template:
    metadata:
      labels:
        app: portest
    spec:
      containers:
      - image: nginx:latest
        imagePullPolicy: Always
        name: nginx
        ports:
        - containerPort: 8080
          name: web
          protocol: TCP
        - containerPort: 8085
          name: jprofiler # only this can be mapping.
          protocol: TCP

enable port map

query

curl host:3343/api/v1/mapping?pod_name=xxx

create a mapping

this example is mapping pod in 600s, exceed 600s, expired.

curl -XPOST host:3343/api/v1/mapping?pod_name={ns_name}/{podname}&time=600

curl -XPOST host:3343/api/v1/mapping?pod_name=kube-system/portest&time=600

curl pod-proxier:8848 == curl portest:8085

Noted: pod-proxier can worked in-cluser on out-cluster, if run out-cluster, you need provide kubeconfig

Faker523 commented 2 months ago

ok tks, i will try it,