cloud-org / edge-proxy

2022第三届云原生编程挑战赛-赛道2:针对边缘计算场景的ACK@Edge高效的边缘自治方案 队伍: 唔想返工
6 stars 1 forks source link
edge-proxy go golang kubernetes tianchi

Table of Contents generated with DocToc

edge-proxy

arch design

notice

仓库共包含 5 个分支,对应 5 个不同的解决方案

tree

├── config        // use kubeconfig for benchmark local test
├── health        // for apiserver health check livez
└── types         // define struct for apiserver list result
├── cachemgr.go         // cache apiserver list result
├── cachemgr_test.go    // unit test
├── checker.go          // remote server health check
├── common.go           // const define
├── filter.go           // for filter benchmark
├── handler.go          // edge-proxy handler
├── infra.go            // apiserver interface define
├── local.go            // local proxy for consistency benchmark
└── remote.go           // remote proxy
├── benchmark-consistency.go
├── benchmark-filter.go
├── benchmark-functional.go
├── benchmark-resourceusage.go // use pprof and timer for benchmark

build binary

make build

make build 命令会生成两个二进制:edge-proxy 和 benchmark, 存放在目录:_output/local/bin/{GOOS}/{GOARCH}/

local test use minikube not in cluster(use kubeconfig)

export server_addr=$(kubectl config view --minify -o=jsonpath="{.clusters[*].cluster.server}")
export ns=$(kubectl get cm kube-root-ca.crt -o=jsonpath="{.metadata.namespace}")
./edge-proxy --server-addr ${server_addr} --use-kubeconfig true --enable-sample-handler true --disk-cache-path ~/.kube/cloudnative-challenge/cache
./benchmark --namespace ${ns} --use-kubeconfig

docker build and push

make docker-build IMAGE_REPO=registry.cn-shanghai.aliyuncs.com/cloud-native-edge-proxy IMAGE_TAG=v0.0.1 REGION=cn

edge ack cluster test

alias kubectl='kubectl --kubeconfig ~/.kube/cloudnative-challenge/config'

docker-build and gen manifest yaml file

make docker-build 命令用于生成并push edge-proxy镜像 和并且产生用于本地测试的 manifest 文件

参数解析:

make docker-build IMAGE_REPO=registry.cn-shanghai.aliyuncs.com/cloudnative-challenge IMAGE_TAG=v1.0 REGION=cn DOCKER_USERNAME=** DOCKER_PASSWD=**

make docker-build 命令执行成功, 会自动 push 镜像到对应的阿里云镜像仓库中,并且在_output/ 目录下生成 manifest.yaml 文件。 manifest.yaml 文件里主要包括了测试的pod资源对象。

deploy benchmark pod

kubectl apply -f _output/manifest.yaml

执行后, 会在对应命名空间下生成名字为 benchmark 的 pod 对象,此 pod 包含了两个容器, 一个是 edge-proxy 的容器, 一个是 benchmark 的容器, 可以使用 kubectl 命令查看:

kubectl get pod benchmark -o yaml

# 查看 bench-mark 容器日志: 
kubectl logs -f benchmark bench-mark

# 查看 edge-proxy 容器日志:
kubectl logs -f benchmark edge-proxy

retest

  1. 修改 edge-proxy 代码逻辑
  2. 执行 make docker-build 命令, 重新构建镜像,并 push 镜像
  3. 删掉测试 pod
kubectl delete -f _output/manifest.yaml
  1. 重新创建测试 pod
kubectl apply -f _output/manifest.yaml

acknowledgement