Skip to content

Commit

Permalink
[gold] Getting traceserver ready for K8s
Browse files Browse the repository at this point in the history
The first instance will the be the Lottie server.
This is still WIP.

Bug: skia:
Change-Id: Iaa634c42fecb195642a072d97848be68e1276bc8
Reviewed-on: https://skia-review.googlesource.com/143062
Commit-Queue: Stephan Altmueller <stephana@google.com>
Reviewed-by: Ben Wagner <benjaminwagner@google.com>
  • Loading branch information
saltmueller authored and Skia Commit-Bot committed Jul 26, 2018
1 parent 0470131 commit 385a695
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -104,3 +104,4 @@ promk/tmp
# kube
**/chat_config.txt
.vscode
tracedb/build
9 changes: 9 additions & 0 deletions tracedb/Makefile
@@ -1,3 +1,5 @@
KGO := CGO_ENABLED=0 GOOS=linux go build

default:
go install -v ./go/traceserver
go install -v ./go/tracetool
Expand All @@ -17,3 +19,10 @@ default:
mv $(GOPATH)/bin/chromevr_gold_ingestion $(GOPATH)/bin/chromevr_gold_ingestion_old
cp $(GOPATH)/bin/skia_ingestion $(GOPATH)/bin/chromevr_gold_ingestion
rm $(GOPATH)/bin/chromevr_gold_ingestion_old

.PHONY: k8s-binaries
k8s-binaries:
mkdir -p ./build
rm -f ./build/*
$(KGO) -o build/traceserver_k8s -a ./go/traceserver/main.go
$(KGO) -o build/skia_ingestion_k8s -a ./go/skia_ingestion/main.go
9 changes: 9 additions & 0 deletions tracedb/dockerfiles/Dockerfile_traceserver
@@ -0,0 +1,9 @@
FROM gcr.io/skia-public/basealpine:3.7

USER root

COPY . /

USER skia

ENTRYPOINT ["/usr/local/bin/gold-traceserver"]
11 changes: 10 additions & 1 deletion tracedb/go/traceserver/main.go
Expand Up @@ -3,7 +3,9 @@ package main

import (
"flag"
"log"
"net"
"net/http"
"os"
"path/filepath"
"runtime/pprof"
Expand All @@ -13,13 +15,15 @@ import (
"go.skia.org/infra/go/sklog"
tracedb "go.skia.org/infra/go/trace/db"
"go.skia.org/infra/go/trace/service"
"go.skia.org/infra/go/util"
"google.golang.org/grpc"
)

// flags
var (
cpuprofile = flag.String("cpuprofile", "", "Write cpu profile to file.")
db_file = flag.String("db_file", "", "The name of the BoltDB file that will store the traces.")
httpPort = flag.String("http_port", ":9091", "The http port where ready-ness endpoints are served.")
local = flag.Bool("local", false, "Running locally if true. As opposed to in production.")
port = flag.String("port", ":9090", "The port to serve the gRPC endpoint on.")
promPort = flag.String("prom_port", ":20000", "Metrics service address (e.g., ':10110')")
Expand Down Expand Up @@ -73,5 +77,10 @@ func main() {
})
}

select {}
// Set up the http handler to indicate ready-ness and start serving.
http.HandleFunc("/ready", func(w http.ResponseWriter, r *http.Request) {
_, err := w.Write([]byte("ready"))
util.LogErr(err)
})
log.Fatal(http.ListenAndServe(*httpPort, nil))
}
19 changes: 19 additions & 0 deletions tracedb/k8s_build_traceserver
@@ -0,0 +1,19 @@
#!/bin/bash

set -x -e

# Builds and uploads a container image for traceserver.

APPNAME="gold-traceserver"

# Copy files into the right locations in ${ROOT}.
copy_release_files()
{
INSTALL="install -D --verbose --backup=none"
INSTALL_DIR="install -d --verbose --backup=none"

${INSTALL} --mode=644 -T ./dockerfiles/Dockerfile_traceserver ${ROOT}/Dockerfile
${INSTALL} --mode=755 -T ./build/traceserver_k8s ${ROOT}/usr/local/bin/gold-traceserver
}

source ../bash/docker_build.sh

0 comments on commit 385a695

Please sign in to comment.