feat: add file-server tools (#72)
Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
parent
2108989c74
commit
c1381ba0e5
17
Makefile
17
Makefile
|
|
@ -1,10 +1,10 @@
|
|||
all: help
|
||||
|
||||
# Run markdown lint
|
||||
markdownlint:
|
||||
@echo "Begin to markdownlint."
|
||||
@./hack/markdownlint.sh
|
||||
.PHONY: markdownlint
|
||||
# Build file-server image.
|
||||
docker-build-file-server:
|
||||
@echo "Begin to use docker build file-server image."
|
||||
docker build -t file-server:latest -f ./tools/file-server/Dockerfile .
|
||||
.PHONY: docker-build-file-server
|
||||
|
||||
# Run code lint
|
||||
lint: markdownlint
|
||||
|
|
@ -12,6 +12,12 @@ lint: markdownlint
|
|||
@golangci-lint run
|
||||
.PHONY: lint
|
||||
|
||||
# Run markdown lint
|
||||
markdownlint:
|
||||
@echo "Begin to markdownlint."
|
||||
@./hack/markdownlint.sh
|
||||
.PHONY: markdownlint
|
||||
|
||||
# Clear compiled files
|
||||
clean:
|
||||
@go clean
|
||||
|
|
@ -19,6 +25,7 @@ clean:
|
|||
.PHONY: clean
|
||||
|
||||
help:
|
||||
@echo "make docker-build-file-server build file-server image"
|
||||
@echo "make lint run code lint"
|
||||
@echo "make markdownlint run markdown lint"
|
||||
@echo "make clean clean"
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ module github.com/dragonflyoss/perf-tests/benchmark
|
|||
go 1.22.4
|
||||
|
||||
require (
|
||||
github.com/google/uuid v1.4.0
|
||||
github.com/sirupsen/logrus v1.9.3
|
||||
github.com/spf13/cobra v1.8.1
|
||||
github.com/spf13/viper v1.19.0
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nos
|
|||
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
|
||||
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ import (
|
|||
"fmt"
|
||||
"net/url"
|
||||
"path"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type FileSizeLevel string
|
||||
|
|
@ -58,6 +60,7 @@ func (f *fileServer) GetFileURL(fileSizeLevel FileSizeLevel, tag string) (*url.U
|
|||
// Add tag query parameter.
|
||||
query := u.Query()
|
||||
query.Set("tag", tag)
|
||||
query.Set("uuid", uuid.New().String())
|
||||
u.RawQuery = query.Encode()
|
||||
return u, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ func (d *dragonfly) downloadFileByProxy(ctx context.Context, podExec *util.PodEx
|
|||
|
||||
// getClientPods returns the client pods.
|
||||
func (d *dragonfly) getClientPods(ctx context.Context) ([]string, error) {
|
||||
pods, err := util.GetPods(ctx, d.namespace, "app=client")
|
||||
pods, err := util.GetPods(ctx, d.namespace, "component=client")
|
||||
if err != nil {
|
||||
logrus.Errorf("failed to get pods: %v", err)
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
FROM nginx:alpine
|
||||
|
||||
RUN dd if=/dev/zero of=/usr/share/nginx/html/nano bs=1 count=1
|
||||
|
||||
RUN dd if=/dev/zero of=/usr/share/nginx/html/micro bs=1K count=10
|
||||
|
||||
RUN dd if=/dev/zero of=/usr/share/nginx/html/small bs=1M count=1
|
||||
|
||||
RUN dd if=/dev/zero of=/usr/share/nginx/html/medium bs=1M count=10
|
||||
|
||||
RUN dd if=/dev/zero of=/usr/share/nginx/html/large bs=1G count=1
|
||||
|
||||
RUN dd if=/dev/zero of=/usr/share/nginx/html/xlarge bs=1G count=10
|
||||
|
||||
RUN dd if=/dev/zero of=/usr/share/nginx/html/xxlarge bs=1G count=30
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: file-server
|
||||
spec:
|
||||
selector:
|
||||
app: dragonfly
|
||||
component: file-server
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- name: nginx
|
||||
port: 80
|
||||
protocol: TCP
|
||||
targetPort: 80
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: file-server
|
||||
spec:
|
||||
serviceName: file-server
|
||||
selector:
|
||||
matchLabels:
|
||||
app: dragonfly
|
||||
component: file-server
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: dragonfly
|
||||
component: file-server
|
||||
spec:
|
||||
containers:
|
||||
- name: file-server
|
||||
image: dragonflyoss/file-server:latest
|
||||
imagePullPolicy: "IfNotPresent"
|
||||
ports:
|
||||
- containerPort: 80
|
||||
Loading…
Reference in New Issue