Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
7ab1fc46
Commit
7ab1fc46
authored
Oct 11, 2016
by
Mik Vyatskov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add logs generator
parent
71249bb8
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
200 additions
and
0 deletions
+200
-0
.linted_packages
hack/.linted_packages
+1
-0
known-flags.txt
hack/verify-flags/known-flags.txt
+2
-0
Dockerfile
test/images/logs-generator/Dockerfile
+24
-0
Makefile
test/images/logs-generator/Makefile
+33
-0
README.md
test/images/logs-generator/README.md
+58
-0
logs_generator.go
test/images/logs-generator/logs_generator.go
+82
-0
No files found.
hack/.linted_packages
View file @
7ab1fc46
...
@@ -223,6 +223,7 @@ test/images/clusterapi-tester
...
@@ -223,6 +223,7 @@ test/images/clusterapi-tester
test/images/entrypoint-tester
test/images/entrypoint-tester
test/images/fakegitserver
test/images/fakegitserver
test/images/goproxy
test/images/goproxy
test/images/logs-generator
test/images/mount-tester
test/images/mount-tester
test/images/n-way-http
test/images/n-way-http
test/images/port-forward-tester
test/images/port-forward-tester
...
...
hack/verify-flags/known-flags.txt
View file @
7ab1fc46
...
@@ -570,3 +570,5 @@ www-prefix
...
@@ -570,3 +570,5 @@ www-prefix
zone-name
zone-name
garbage-collector-enabled
garbage-collector-enabled
viper-config
viper-config
log-lines-total
run-duration
test/images/logs-generator/Dockerfile
0 → 100644
View file @
7ab1fc46
# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM
gcr.io/google_containers/ubuntu-slim:0.4
MAINTAINER
Mik Vyatskov <vmik@google.com>
COPY
logs-generator /
CMD
/logs-generator --logtostderr \
--log-lines-total=${LOGS_GENERATOR_LINES_TOTAL} \
--run-duration=${LOGS_GENERATOR_DURATION}
\ No newline at end of file
test/images/logs-generator/Makefile
0 → 100644
View file @
7ab1fc46
# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
TAG
=
v0.1.0
PREFIX
=
gcr.io/google_containers
all
:
build
build
:
binary container
binary
:
go build
-a
--ldflags
'-w'
-o
logs-generator .
container
:
docker build
-t
$(PREFIX)
/logs-generator:
$(TAG)
.
push
:
gcloud docker push
$(PREFIX)
/logs-generator:
$(TAG)
clean
:
rm
-f
logs-generator
\ No newline at end of file
test/images/logs-generator/README.md
0 → 100644
View file @
7ab1fc46
# Logs Generator
## Overview
Logs generator is a tool to create predictable load on the logs delivery system.
Is generates random lines with predictable format and predictable average length.
Each line can be later uniquely identified to ensure logs delivery.
## Usage
Tool is parametrized with the total number of number that should be generated and the duration of
the generation process. For example, if you want to create a throughput of 100 lines per second
for a minute, you set total number of lines to 6000 and duration to 1 minute.
Parameters are passed through environment variables. There are no defaults, you should always
set up container parameters. Total number of line is parametrized through env variable
`LOGS_GENERATOR_LINES_TOTAL`
and duration in go format is parametrized through env variable
`LOGS_GENERATOR_DURATION`
.
Inside the container all log lines are written to the stdout.
Each line is on average 100 bytes long and follows this pattern:
```
2000-12-31T12:59:59Z <id> <method> /api/v1/namespaces/<namespace>/endpoints/<random_string> <random_number>
```
Where
`<id>`
refers to the number from 0 to
`total_lines - 1`
, which is unique for each
line in a given run of the container.
## Image
Image is located in the public repository of Google Container Registry under the name
```
gcr.io/google_containers/logs-generator:v0.1.0
```
## Examples
```
docker run -i \
-e "LOGS_GENERATOR_LINES_TOTAL=10" \
-e "LOGS_GENERATOR_DURATION=1s" \
gcr.io/google_containers/logs-generator:v0.1.0
```
```
kubectl run logs-generator \
--generator=run-pod/v1 \
--image=gcr.io/google_containers/logs-generator:v0.1.0 \
--restart=Never \
--env "LOGS_GENERATOR_LINES_TOTAL=1000" \
--env "LOGS_GENERATOR_DURATION=1m"
```
[

]()
\ No newline at end of file
test/images/logs-generator/logs_generator.go
0 → 100644
View file @
7ab1fc46
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
main
import
(
"flag"
"fmt"
"time"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/util/rand"
)
var
(
httpMethods
=
[]
string
{
"GET"
,
"POST"
,
"PUT"
,
}
namespaces
=
[]
string
{
"kube-system"
,
"default"
,
"ns"
,
}
)
var
(
linesTotal
=
flag
.
Int
(
"log-lines-total"
,
0
,
"Total lines that should be generated by the end of the run"
)
duration
=
flag
.
Duration
(
"run-duration"
,
0
,
"Total duration of the run"
)
)
func
main
()
{
flag
.
Parse
()
if
*
linesTotal
<=
0
{
glog
.
Fatalf
(
"Invalid total number of lines: %d"
,
*
linesTotal
)
}
if
*
duration
<=
0
{
glog
.
Fatalf
(
"Invalid duration: %v"
,
*
duration
)
}
generateLogs
(
*
linesTotal
,
*
duration
)
}
// Outputs linesTotal lines of logs to stdout uniformly for duration
func
generateLogs
(
linesTotal
int
,
duration
time
.
Duration
)
{
delay
:=
duration
/
time
.
Duration
(
linesTotal
)
rand
.
Seed
(
time
.
Now
()
.
UnixNano
())
tick
:=
time
.
Tick
(
delay
)
for
id
:=
0
;
id
<
linesTotal
;
id
++
{
glog
.
Info
(
generateLogLine
(
id
))
<-
tick
}
}
// Generates apiserver-like line with average length of 100 symbols
func
generateLogLine
(
id
int
)
string
{
method
:=
httpMethods
[
rand
.
Intn
(
len
(
httpMethods
))]
namespace
:=
namespaces
[
rand
.
Intn
(
len
(
namespaces
))]
podName
:=
rand
.
String
(
rand
.
IntnRange
(
3
,
5
))
url
:=
fmt
.
Sprintf
(
"/api/v1/namespaces/%s/pods/%s"
,
namespace
,
podName
)
status
:=
rand
.
IntnRange
(
200
,
600
)
return
fmt
.
Sprintf
(
"%d %s %s %d"
,
id
,
method
,
url
,
status
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment