-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Raul Sevilla <[email protected]>
- Loading branch information
1 parent
90720b2
commit cc5c55c
Showing
18 changed files
with
598 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: cloud-bulldozer | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
|
||
jobs: | ||
|
||
build-containers: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install dependencies | ||
run: sudo apt-get install qemu-user-static podman fuse-overlayfs | ||
|
||
- name: Login in quay | ||
run: podman login quay.io -u ${QUAY_USER} -p ${QUAY_TOKEN} | ||
env: | ||
QUAY_USER: ${{ secrets.QUAY_USER }} | ||
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }} | ||
|
||
- name: Build binary and push containers | ||
run: make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
PLATFORMS = linux/ppc64le,linux/arm64,linux/amd64,linux/s390x | ||
PLATFORMS = linux/amd64,linux/ppc64le,linux/arm64,linux/s390x | ||
ENGINE ?= podman | ||
ORG ?= cloud-bulldozer | ||
REGISTRY ?= quay.io | ||
REG = $(REGISTRY)/$(ORG) | ||
REPOS = etcd-perf nginx | ||
REPOS = perfapp etcd-perf nginx | ||
|
||
all: build push | ||
|
||
build: | ||
for repo in $(REPOS); do \ | ||
$(ENGINE) build --jobs=4 --platform=$(PLATFORMS) --manifest=$(REG)/$$repo:latest $$repo; \ | ||
@for repo in $(REPOS); do \ | ||
echo -e "\033[2mBuilding $$repo\033[0m"; \ | ||
$(ENGINE) build --jobs=4 --platform=$(PLATFORMS) --manifest=$(REG)/$$repo:latest $$repo; \ | ||
done | ||
|
||
push: | ||
for repo in $(REPOS); do \ | ||
$(ENGINE) manifest push $(REG)/$$repo:latest $(REG)/$$repo:latest; \ | ||
echo -e "\033[2mPushing $$repo\033[0m"; \ | ||
$(ENGINE) manifest push $(REG)/$$repo:latest $(REG)/$$repo:latest; \ | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM registry.access.redhat.com/ubi8/ubi:latest as builder | ||
ARG TARGETARCH | ||
RUN dnf clean all && dnf install -y golang | ||
COPY . /perfApp | ||
RUN cd perfApp && GOARCH=${TARGETARCH} CGO_ENABLED=0 go build -o perfApp cmd/perfApp/perfApp.go | ||
|
||
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest | ||
MAINTAINER Raúl Sevilla | ||
|
||
COPY --from=builder perfApp/perfApp /usr/bin/perfApp | ||
CMD perfApp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# vim: ft=make ts=4 | ||
|
||
SRC=$(shell find . -name *.go) | ||
BINARY=perfApp | ||
GO_BUILD_RECIPE:=CGO_ENABLED=0 go build | ||
ARCHS=amd64 ppc64le arm64 s390x | ||
|
||
build: clean | ||
mkdir -p build | ||
for arch in $(ARCHS); do \ | ||
CGO_ENABLED=0 GOOS=linux GOARCH=$$arch go build -o build/$(BINARY)-$$arch cmd/perfApp/perfApp.go; \ | ||
done | ||
|
||
clean: | ||
rm -rf build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Performance application | ||
|
||
## Available workloads | ||
|
||
- Health: Returns 200. Does not need postgres connectivity. Available at `/health` | ||
- Ready: Inserts a timestamp record in the ts table. Available at `/ready` | ||
- Euler aproximation: Computes an Euler number approximation and writes compute time in the euler table. Available at `/euler` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package main | ||
|
||
import ( | ||
"net/http" | ||
"os" | ||
"os/signal" | ||
"strconv" | ||
"syscall" | ||
|
||
log "github.com/sirupsen/logrus" | ||
|
||
"github.com/prometheus/client_golang/prometheus/promhttp" | ||
"ocp.performance.io/perfapp/internal/perf" | ||
"ocp.performance.io/perfapp/pkg/euler" | ||
"ocp.performance.io/perfapp/pkg/health" | ||
"ocp.performance.io/perfapp/pkg/ready" | ||
"ocp.performance.io/perfapp/pkg/utils" | ||
) | ||
|
||
var tables []map[string]string | ||
|
||
func main() { | ||
customFormatter := new(log.TextFormatter) | ||
customFormatter.TimestampFormat = "2006-01-02 15:04:05" | ||
customFormatter.FullTimestamp = true | ||
log.SetFormatter(customFormatter) | ||
c := make(chan os.Signal, 1) | ||
signal.Notify(c, syscall.SIGINT) | ||
go handleInterrupt(c) | ||
if os.Getenv("POSTGRESQL_HOSTNAME") != "" { | ||
go func() { | ||
if os.Getenv("POSTGRESQL_RETRY_INTERVAL") != "" { | ||
retryInt, err := strconv.Atoi(os.Getenv("POSTGRESQL_RETRY_INTERVAL")) | ||
if err != nil { | ||
utils.ErrorHandler(err) | ||
} | ||
perf.DB.RetryInt = retryInt | ||
} | ||
perf.Connect2Db() | ||
tables = append(tables, euler.Tables, ready.Tables) | ||
if err := perf.CreateTables(tables); err != nil { | ||
utils.ErrorHandler(err) | ||
} | ||
}() | ||
http.HandleFunc("/euler", euler.Handler) | ||
http.HandleFunc("/ready", ready.Handler) | ||
} | ||
http.Handle("/metrics", promhttp.Handler()) | ||
http.HandleFunc("/health", health.Handler) | ||
log.Printf("Listening at 8080") | ||
if err := http.ListenAndServe(":8080", nil); err != nil { | ||
utils.ErrorHandler(err) | ||
} | ||
} | ||
|
||
func handleInterrupt(c <-chan os.Signal) { | ||
<-c | ||
log.Println("Interrupt signal received") | ||
os.Exit(0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
kind: Template | ||
apiVersion: template.openshift.io/v1 | ||
labels: | ||
template: perf-app | ||
metadata: | ||
name: perf-app | ||
objects: | ||
- kind: Deployment | ||
apiVersion: apps/v1 | ||
metadata: | ||
name: postgres-${IDENTIFIER} | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
name: postgres-${IDENTIFIER} | ||
spec: | ||
containers: | ||
- name: postgresql | ||
image: registry.redhat.io/rhscl/postgresql-10-rhel7:latest | ||
ports: | ||
- containerPort: 5432 | ||
protocol: TCP | ||
env: | ||
- name: POSTGRESQL_USER | ||
value: ${POSTGRESQL_USER} | ||
- name: POSTGRESQL_PASSWORD | ||
value: ${POSTGRESQL_PASSWORD} | ||
- name: POSTGRESQL_DATABASE | ||
value: ${POSTGRESQL_DATABASE} | ||
resources: {} | ||
imagePullPolicy: Always | ||
capabilities: {} | ||
securityContext: | ||
capabilities: {} | ||
privileged: false | ||
restartPolicy: Always | ||
serviceAccount: '' | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
name: postgres-${IDENTIFIER} | ||
triggers: | ||
- type: ConfigChange | ||
strategy: | ||
type: RollingUpdate | ||
- kind: Deployment | ||
apiVersion: apps/v1 | ||
metadata: | ||
name: perfapp-${IDENTIFIER} | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
name: perfapp-${IDENTIFIER} | ||
spec: | ||
containers: | ||
- name: perfapp | ||
image: quay.io/cloud-bulldozer/perfapp:latest | ||
readinessProbe: | ||
httpGet: | ||
path: ${LIVENESS_ENDPOINT} | ||
port: 8080 | ||
periodSeconds: 30 | ||
failureThreshold: 1 | ||
timeoutSeconds: 60 | ||
initialDelaySeconds: 30 | ||
ports: | ||
- containerPort: 8080 | ||
protocol: TCP | ||
env: | ||
- name: POSTGRESQL_USER | ||
value: ${POSTGRESQL_USER} | ||
- name: POSTGRESQL_PASSWORD | ||
value: ${POSTGRESQL_PASSWORD} | ||
- name: POSTGRESQL_DATABASE | ||
value: ${POSTGRESQL_DATABASE} | ||
- name: POSTGRESQL_HOSTNAME | ||
value: postgresql-${IDENTIFIER} | ||
- name: POSTGRESQL_PORT | ||
value: '5432' | ||
- name: POSTGRESQL_RETRY_INTERVAL | ||
value: ${POSTGRESQL_RETRY_INTERVAL} | ||
resources: {} | ||
imagePullPolicy: Always | ||
capabilities: {} | ||
securityContext: | ||
capabilities: {} | ||
privileged: false | ||
restartPolicy: Always | ||
serviceAccount: '' | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
name: perfapp-${IDENTIFIER} | ||
triggers: | ||
- type: ConfigChange | ||
strategy: | ||
type: RollingUpdate | ||
- kind: Service | ||
apiVersion: v1 | ||
metadata: | ||
name: postgresql-${IDENTIFIER} | ||
spec: | ||
selector: | ||
name: postgres-${IDENTIFIER} | ||
ports: | ||
- protocol: TCP | ||
port: 5432 | ||
targetPort: 5432 | ||
portalIP: '' | ||
type: ClusterIP | ||
sessionAffinity: None | ||
status: | ||
loadBalancer: {} | ||
- kind: Service | ||
apiVersion: v1 | ||
metadata: | ||
name: perfapp-${IDENTIFIER} | ||
spec: | ||
selector: | ||
name: perfapp-${IDENTIFIER} | ||
ports: | ||
- protocol: TCP | ||
port: 8080 | ||
targetPort: 8080 | ||
portalIP: '' | ||
type: ClusterIP | ||
sessionAffinity: None | ||
status: | ||
loadBalancer: {} | ||
parameters: | ||
- name: IDENTIFIER | ||
description: Number to append to the name of resources | ||
value: '1' | ||
- name: POSTGRESQL_USER | ||
description: Postgresql database username | ||
value: 'admin' | ||
- name: POSTGRESQL_PASSWORD | ||
description: Postgresql database password | ||
value: 'secret' | ||
- name: POSTGRESQL_DATABASE | ||
description: Postgresql database name | ||
value: 'mydb' | ||
- name: POSTGRESQL_RETRY_INTERVAL | ||
description: Postgresql connection retry interval | ||
value: '5' | ||
- name: LIVENESS_ENDPOINT | ||
description: Liveness probe endpoint | ||
value: '/ready' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module ocp.performance.io/perfapp | ||
|
||
go 1.20 | ||
|
||
require ( | ||
github.com/lib/pq v1.3.0 | ||
github.com/prometheus/client_golang v1.5.1 | ||
github.com/sirupsen/logrus v1.4.2 | ||
) | ||
|
||
require ( | ||
github.com/beorn7/perks v1.0.1 // indirect | ||
github.com/cespare/xxhash/v2 v2.1.1 // indirect | ||
github.com/golang/protobuf v1.3.2 // indirect | ||
github.com/konsorten/go-windows-terminal-sequences v1.0.1 // indirect | ||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect | ||
github.com/prometheus/client_model v0.2.0 // indirect | ||
github.com/prometheus/common v0.9.1 // indirect | ||
github.com/prometheus/procfs v0.0.8 // indirect | ||
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82 // indirect | ||
) |
Oops, something went wrong.