parent
8e33be359a
commit
30d2938bd6
@ -1,2 +1,3 @@
|
||||
resources:
|
||||
- ./runner-deployment.yaml
|
||||
- ./proxy-admin-deployment.yaml
|
||||
|
@ -0,0 +1,54 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: proxy-admin
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
service: proxy-admin
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
service: proxy-admin
|
||||
spec:
|
||||
containers:
|
||||
- name: proxy-admin
|
||||
image: barretthousen/service-proxy-admin:latest
|
||||
ports:
|
||||
- containerPort: 80
|
||||
name: http
|
||||
command:
|
||||
- /opt/proxy-admin
|
||||
resources:
|
||||
limits:
|
||||
memory: "64Mi"
|
||||
cpu: "250m"
|
||||
volumeMounts:
|
||||
- name: proxy-admin-config
|
||||
mountPath: /config/
|
||||
volumes:
|
||||
- name: proxy-admin-config
|
||||
configMap:
|
||||
name: proxy-admin-config
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: proxy-admin
|
||||
spec:
|
||||
selector:
|
||||
service: proxy-admin
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 80
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: proxy-admin-config
|
||||
data:
|
||||
config.yaml: |
|
||||
log_level: 2
|
||||
port: 80
|
||||
endpoints:
|
||||
runner: local-runner:5001
|
@ -0,0 +1,23 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: runner
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: runner
|
||||
command:
|
||||
- /go/bin/dlv
|
||||
args:
|
||||
- --headless
|
||||
- --listen=0.0.0.0:2345
|
||||
- --api-version=2
|
||||
- --log
|
||||
- --accept-multiclient
|
||||
#- --log-output=rpc,dap
|
||||
- exec
|
||||
- /opt/runner-debug
|
||||
- --continue
|
||||
ports:
|
||||
- containerPort: 2345
|
@ -0,0 +1,6 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="bh-db@localhost" uuid="05aba6c0-168c-47e3-b807-951316a3a483">
|
||||
<driver-ref>postgresql</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:postgresql://localhost:5432/postgres</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/src.iml" filepath="$PROJECT_DIR$/.idea/src.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="DBE_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -1,20 +1,31 @@
|
||||
FROM golang:1.19-alpine as builder
|
||||
FROM golang:1.19-alpine as development
|
||||
|
||||
ARG SERVICE
|
||||
|
||||
ENV SERVICE=${SERVICE}
|
||||
|
||||
RUN go install github.com/go-delve/delve/cmd/dlv@latest
|
||||
|
||||
COPY . /go/src
|
||||
|
||||
WORKDIR /go/src/${SERVICE}
|
||||
|
||||
RUN go mod tidy && go build -v -o /opt/${SERVICE} /go/src/${SERVICE}
|
||||
RUN go mod tidy \
|
||||
&& CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o /opt/${SERVICE} /go/src/${SERVICE} \
|
||||
&& CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -gcflags="-N -l" -v -o /opt/${SERVICE}-debug /go/src/${SERVICE}
|
||||
# && go build -v -gcflags="all=-N -l" -o /opt/${SERVICE}-debug /go/src/${SERVICE}
|
||||
|
||||
ENTRYPOINT ['/go/bin/dlv']
|
||||
|
||||
CMD ['debug', '/go/src/${SERVICE}']
|
||||
|
||||
|
||||
FROM alpine
|
||||
FROM alpine as production
|
||||
|
||||
ARG SERVICE
|
||||
|
||||
ENV SERVICE=${SERVICE}
|
||||
|
||||
COPY --from=builder /opt/${SERVICE} /opt/${SERVICE}
|
||||
COPY --from=development /opt/${SERVICE} /opt/${SERVICE}
|
||||
|
||||
ENTRYPOINT ['/opt/${SERVICE}']
|
||||
|
@ -0,0 +1,9 @@
|
||||
FROM golang:1.19-alpine as builder
|
||||
|
||||
ARG SERVICE
|
||||
|
||||
COPY . /go/src
|
||||
|
||||
WORKDIR /go/src/${SERVICE}
|
||||
|
||||
RUN go mod tidy && go build -v -o /opt/${SERVICE} /go/src/${SERVICE}
|
@ -0,0 +1,11 @@
|
||||
module git.vdhsn.com/barretthousen/barretthousen/src/proxy-admin
|
||||
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
git.vdhsn.com/barretthousen/barretthousen/src/lib v1.0.0
|
||||
git.vdhsn.com/barretthousen/barretthousen/src/runner v1.0.0
|
||||
)
|
||||
|
||||
replace git.vdhsn.com/barretthousen/barretthousen/src/lib v1.0.0 => ../lib
|
||||
replace git.vdhsn.com/barretthousen/barretthousen/src/runner v1.0.0 => ../runner
|
@ -0,0 +1,59 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"git.vdhsn.com/barretthousen/barretthousen/src/lib/kernel"
|
||||
"git.vdhsn.com/barretthousen/barretthousen/src/runner/api"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
type ProxyAdminApp struct {
|
||||
LogLevel kernel.LogLevel `yaml:"log_level" env:"BH_LOG_LEVEL" env-default:"0" yaml-default:"0"`
|
||||
Port int `yaml:"port" env:"PROXY_ADMIN_PORT"`
|
||||
Endpoints struct {
|
||||
Runner string `yaml:"runner" env:"RUNNER_ENDPOINT"`
|
||||
} `yaml:"endpoints" env:"PROXY_ADMIN_SERVICES"`
|
||||
}
|
||||
|
||||
func (app *ProxyAdminApp) Start(ctx context.Context) error {
|
||||
grpcMux := runtime.NewServeMux()
|
||||
err := api.RegisterRunnerHandlerFromEndpoint(ctx, grpcMux, app.Endpoints.Runner, []grpc.DialOption{
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
kernel.TraceLog.Printf("%+v", app)
|
||||
|
||||
httpServer := &http.Server{
|
||||
Addr: fmt.Sprintf("0.0.0.0:%d", app.Port),
|
||||
ReadHeaderTimeout: time.Second,
|
||||
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
kernel.TraceLog.Printf("{ \"Client\": \"%s\", \"Path\":\"%s\"} ", r.RemoteAddr, r.URL.Path)
|
||||
grpcMux.ServeHTTP(w, r)
|
||||
}),
|
||||
}
|
||||
|
||||
kernel.InfoLog.Printf("Starting HTTP proxy @ %q", httpServer.Addr)
|
||||
|
||||
return httpServer.ListenAndServe()
|
||||
}
|
||||
|
||||
func (app *ProxyAdminApp) OnStop(ctx context.Context) {
|
||||
}
|
||||
|
||||
func (app *ProxyAdminApp) GetLogLevel() kernel.LogLevel { return app.LogLevel }
|
||||
|
||||
func main() {
|
||||
kernel.Run(context.Background(), &ProxyAdminApp{
|
||||
LogLevel: kernel.LevelTrace,
|
||||
Port: 80,
|
||||
})
|
||||
}
|
Loading…
Reference in new issue