Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion .github/actions/build-api-images/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ inputs:
description: 'build websocket-server api'
default: false

gateway-kube-proxy:
description: 'build gateway kube proxy'
default: false

runs:
using: 'composite'
steps:
Expand All @@ -103,7 +107,7 @@ runs:
echo "GOCACHE=$GOCACHE" >> $GITHUB_ENV
echo "FILES_HASH=${{ hashFiles('**/*.go', '**/go.mod', '**/go.sum')}}" >> $GITHUB_OUTPUT
echo "PUSH_IMAGE=false" >> $GITHUB_ENV
if [ "${{ inputs.git_directory }}" != "." ]; then
if [ "$(basename ${{ inputs.git_directory }})" != "." ]; then
echo "IMAGE_REPOSITORY_PREFIX=ghcr.io/${{ github.repository }}/$(basename ${{inputs.git_directory}})" >> $GITHUB_ENV
else
echo "IMAGE_REPOSITORY_PREFIX=ghcr.io/${{ github.repository }}" >> $GITHUB_ENV
Expand Down Expand Up @@ -430,3 +434,20 @@ runs:
run: |
task container:build-and-push image=${IMAGE_REPOSITORY_PREFIX}/websocket-server:${IMAGE_TAG:-latest} upx=true override=$OVERRIDE_PUSHED_IMAGE push_image=${PUSH_IMAGE}

- name: gateway kube proxy api build cache
if: ${{ inputs.gateway-kube-proxy == 'true' }}
uses: actions/cache@v4
with:
path: |+
${{ env.GOMODCACHE }}
${{ env.GOCACHE }}
key: go-${{ runner.os }}-gateway-kube-proxy-${{ steps.env-vars.outputs.FILES_HASH }}
save-always: true
restore-keys: go-${{ runner.os }}-gateway-kube-proxy-

- name: gateway logs proxy
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Use more descriptive names for GitHub Actions steps

Consider using more descriptive names for the steps, especially for the new gateway kube proxy steps. For example, 'Build and push gateway kube proxy image' would be clearer than 'gateway logs proxy'.

Suggested change
- name: gateway logs proxy
- name: Build and push gateway kube proxy image

if: ${{ inputs.gateway-kube-proxy == 'true' }}
working-directory: ${{ inputs.git_directory }}/cmd/gateway-kube-proxy
shell: bash
run: |
task container:build-and-push image=${IMAGE_REPOSITORY_PREFIX}/cmd/gateway-kube-proxy:${IMAGE_TAG:-latest} upx=true override=$OVERRIDE_PUSHED_IMAGE push_image=${PUSH_IMAGE}
2 changes: 1 addition & 1 deletion apps/infra/internal/app/graph/byokcluster.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/infra/internal/app/graph/cluster.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/infra/internal/app/graph/common-types.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/infra/internal/app/graph/domainentry.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,702 changes: 851 additions & 851 deletions apps/infra/internal/app/graph/generated/generated.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/infra/internal/app/graph/globalvpn.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/infra/internal/app/graph/globalvpndevice.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/infra/internal/app/graph/helmrelease.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions apps/infra/internal/app/graph/model/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/infra/internal/app/graph/namespace.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/infra/internal/app/graph/node.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/infra/internal/app/graph/nodepool.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions apps/infra/internal/app/graph/schema.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/infra/internal/domain/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ func (d *domain) syncKloudliteDeviceOnPlatform(ctx InfraContext, gvpnName string

wgParams.PublicPeers = publicPeers
wgParams.DNS = clDevice.IPAddr
wgParams.WithDNS = true
wgParams.ListenPort = 31820

dnsServerArgs := make([]string, 0, len(gvpnConns))
Expand Down
2 changes: 1 addition & 1 deletion apps/infra/internal/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Env struct {

KloudliteDNSSuffix string `env:"KLOUDLITE_DNS_SUFFIX" required:"true"`

NatsURL string `env:"NATS_URL" required:"true"`
NatsURL string `env:"NATS_URL" required:"true"`
NatsReceiveFromAgentStream string `env:"NATS_RECEIVE_FROM_AGENT_STREAM" required:"true"`

AccountCookieName string `env:"ACCOUNT_COOKIE_NAME" required:"true"`
Expand Down
2 changes: 1 addition & 1 deletion apps/observability/internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ var Module = fx.Module(
}

if len(pods) == 0 {
// it sends http.StatusTooEarly, for the client to retry request after some time
// INFO: it sends http.StatusTooEarly, for the client to retry request after some time
logger.Infof("no pods found")
http.Error(w, "no pods found", http.StatusTooEarly)
return
Expand Down
8 changes: 7 additions & 1 deletion apps/observability/internal/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ var Module = fx.Module("framework",
return http.NewServeMux()
}),

fx.Invoke(func(lf fx.Lifecycle, ev *env.Env, mux *http.ServeMux) {
fx.Invoke(func(lf fx.Lifecycle, ev *env.Env, mux *http.ServeMux, logger *slog.Logger) {
mux.HandleFunc("/_healthy", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
})

logger.Info("starting observability api HTTP server on", "port", ev.HttpPort)

server := &http.Server{Addr: fmt.Sprintf(":%d", ev.HttpPort), Handler: mux}
lf.Append(fx.Hook{
OnStart: func(context.Context) error {
Expand Down
5 changes: 4 additions & 1 deletion apps/observability/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import (
func main() {
var isDev bool
flag.BoolVar(&isDev, "dev", false, "--dev")

var debug bool
flag.BoolVar(&debug, "debug", false, "--debug")
flag.Parse()

ev, err := env.LoadEnv()
Expand All @@ -45,7 +48,7 @@ func main() {
fx.Provide(func() *slog.Logger {
return logging.NewSlogLogger(logging.SlogOptions{
ShowCaller: true,
ShowDebugLogs: isDev,
ShowDebugLogs: debug,
SetAsDefaultLogger: true,
})
}),
Expand Down
2 changes: 1 addition & 1 deletion cmd/gateway-kube-proxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#syntax=docker/dockerfile:1
FROM --platform=$TARGETPLATFORM cgr.dev/chainguard/static:latest-glibc
FROM cgr.dev/chainguard/static:latest-glibc
ARG BINARY TARGETARCH
COPY --chown=1001 $BINARY-$TARGETARCH ./gateway-kube-proxy
ENTRYPOINT ["./gateway-kube-proxy"]
18 changes: 12 additions & 6 deletions cmd/gateway-kube-proxy/Taskfile.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
version: 3

includes:
go: ../../.tools/taskfiles/go-build.yml
go: ../../.tools/taskfiles/go-build.Taskfile.yml
docker: ../../.tools/taskfiles/docker.Taskfile.yml

vars:
app: gateway-kube-proxy
binary: ./bin/{{.app}}

tasks:
build:
cmds:
- task: go:build
vars:
Out: ./bin/{{.app}}-{{.GOARCH}}
out: "{{.binary}}-{{.GOARCH}}"
GOARCH: "{{.GOARCH}}"

run:
cmds:
- fwatcher --exec 'go run ./main.go --addr :8090 --proxy-addr 127.0.0.1:8111 --authz sample' --ext .go

container:build-and-push:
preconditions:
- sh: '[[ -n "{{.Image}}" ]]'
msg: "var Image is not set"
requires:
vars:
- image
cmds:
- task: build
vars:
GOARCH: amd64
- task: build
vars:
GOARCH: arm64
- docker buildx build --platform linux/amd64,linux/arm64 --output=type=image,compression=zstd,force-compression=true,compression-level=14,push=true --build-arg BINARY="./bin/{{.app}}" -t {{.Image}} .
- task: docker:build-and-push
vars:
args: "--platform linux/amd64,linux/arm64 --build-arg BINARY={{.binary}} ."
image: "{{.image}}"
26 changes: 14 additions & 12 deletions cmd/gateway-kube-proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package main
import (
"flag"
"fmt"
"log/slog"
"net/http"
"net/http/httputil"
"strings"

"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"github.com/kloudlite/api/common"
"github.com/kloudlite/api/pkg/logging"
)

func main() {
Expand All @@ -28,20 +28,23 @@ func main() {
panic("authz token is required, use --authz <authz-token>")
}

logger := slog.Default()
common.PrintKloudliteBanner()

logger := logging.NewSlogLogger(logging.SlogOptions{
ShowCaller: true,
ShowDebugLogs: debug,
SetAsDefaultLogger: true,
})

reverseProxyMap := make(map[string]*httputil.ReverseProxy)

r := chi.NewRouter()
r.Use(func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/healthy" {
next.ServeHTTP(w, r)
return
}
middleware.Logger(next).ServeHTTP(w, r)
})
httpLogger := logging.NewHttpLogger(logger, logging.HttpLoggerOptions{
ShowQuery: true,
ShowHeaders: true,
SilentPaths: []string{},
})
r.Use(httpLogger.Use)

kloudliteAuthzHeader := "X-Kloudlite-Authz"

Expand All @@ -59,7 +62,6 @@ func main() {
return
}

// clusterName := sp[0]
clusterName := chi.URLParam(req, "cluster_name")

urlh := strings.ReplaceAll(proxyAddr, "{{.CLUSTER_NAME}}", clusterName)
Expand Down
Loading