Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸš€ feat: implement logs streaming for pods #568

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b18f09c
sse endpoint impl
petar-cvit Aug 30, 2024
735d65b
fetch sse endpoint impl
petar-cvit Aug 30, 2024
40ca3b8
fix failing build
petar-cvit Aug 30, 2024
f5152f7
βš™οΈ update cyclops to v0.11.0-rc-streaming
github-actions[bot] Aug 30, 2024
ec3661c
remove client tracking
petar-cvit Sep 1, 2024
f5ec560
remove unused params
petar-cvit Sep 1, 2024
8ecde2c
Merge branch 'main' into stream-deployment-updates
petar-cvit Sep 1, 2024
a4b8456
destroy on proxy
petar-cvit Sep 2, 2024
1b85cee
extract sse subscribe to a function
petar-cvit Sep 2, 2024
57e14e4
remove logging
petar-cvit Sep 2, 2024
a84e1f8
Merge branch 'main' into stream-deployment-updates
petar-cvit Sep 2, 2024
0b24558
support daemonsets and statefulsets
petar-cvit Sep 2, 2024
95807a6
βš™οΈ update cyclops to v0.11.0-rc-streaming.2
github-actions[bot] Sep 3, 2024
274553c
streaming feature flag
petar-cvit Sep 3, 2024
f6adc39
feat[BE]: impl streamed logs for pods over SSE
naineel1209 Sep 7, 2024
f001175
feat[FE]: impl log streaming for pods
naineel1209 Sep 8, 2024
8401e11
Merge branch 'main' into feat/log-streaming-for-pods
naineel1209 Sep 11, 2024
64e9202
wip: resolved merge conflicts
naineel1209 Sep 11, 2024
a13121f
wip: resolved unclosed goroutine
naineel1209 Sep 12, 2024
17d3b67
feat: fixed View Logs button dimensions
naineel1209 Sep 12, 2024
c5d0445
fix: applies recommended changes
naineel1209 Sep 13, 2024
3ca47dc
fix: applies recommended changes
naineel1209 Sep 13, 2024
0053df9
Merge branch 'feat/log-streaming-for-pods' of https://github.com/nain…
naineel1209 Sep 13, 2024
6074d12
fix: pass consistent `logSignalController` to `logStream`
naineel1209 Sep 16, 2024
8c26c21
fix: pass consistent `logSignalController` to `logStream`
naineel1209 Sep 16, 2024
44d1539
Merge branch 'feat/log-streaming-for-pods' of https://github.com/nain…
naineel1209 Sep 16, 2024
522d969
Merge branch 'feat/log-streaming-for-pods' of https://github.com/nain…
naineel1209 Sep 16, 2024
3239b87
Merge branch 'feat/log-streaming-for-pods' of https://github.com/nain…
naineel1209 Sep 16, 2024
1491ba6
Merge branch 'main' into feat/log-streaming-for-pods
naineel1209 Sep 19, 2024
5c018d5
πŸ”€ fix: resolved the duplicated logs streamed error
naineel1209 Sep 19, 2024
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
Prev Previous commit
Next Next commit
Merge branch 'main' into feat/log-streaming-for-pods
  • Loading branch information
naineel1209 committed Sep 11, 2024
commit 8401e119f8f8096a0a58f23520ea3c2e7ad0dfbf
17 changes: 4 additions & 13 deletions cyclops-ctrl/internal/controller/sse/proxychan.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
)

type ProxyChan struct {
update bool
input <-chan watch.Event
output chan any
}
Expand All @@ -21,28 +20,20 @@ func NewProxyChan(ctx context.Context, input <-chan watch.Event, interval time.D

go func() {
ticker := time.NewTicker(interval)
defer ticker.Stop()

batcher := time.NewTicker(time.Millisecond * 500)
defer batcher.Stop()
defer func() {
ticker.Stop()
}()

for {
select {
case _, ok := <-p.input:
if !ok {
return
}
p.update = true
p.output <- true

case <-ticker.C:
p.output <- true
p.update = false

case <-batcher.C:
if p.update {
p.output <- true
}
p.update = false

case <-ctx.Done():
return
Expand Down
2 changes: 1 addition & 1 deletion cyclops-ctrl/internal/controller/sse/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (s *Server) Resources(ctx *gin.Context) {
return
}

p := NewProxyChan(ctx.Request.Context(), watchResource.ResultChan(), time.Second*15)
p := NewProxyChan(ctx.Request.Context(), watchResource.ResultChan(), time.Second*10)

ctx.Stream(func(w io.Writer) bool {
for {
Expand Down
3 changes: 2 additions & 1 deletion cyclops-ctrl/internal/controller/sse/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package sse
import (
"github.com/gin-gonic/gin"

"github.com/cyclops-ui/cyclops/cyclops-ctrl/internal/cluster/k8sclient"
"github.com/cyclops-ui/cyclops/cyclops-ctrl/pkg/cluster/k8sclient"
)

type Server struct {
Expand All @@ -25,6 +25,7 @@ func HeadersMiddleware() gin.HandlerFunc {
c.Writer.Header().Set("Cache-Control", "no-cache")
c.Writer.Header().Set("Connection", "keep-alive")
c.Writer.Header().Set("Transfer-Encoding", "chunked")
c.Writer.Header().Set("X-Accel-Buffering", "no")
c.Next()
}
}
1 change: 0 additions & 1 deletion cyclops-ctrl/internal/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/gin-gonic/gin"
"net/http"

"github.com/cyclops-ui/cyclops/cyclops-ctrl/internal/cluster/k8sclient"
"github.com/cyclops-ui/cyclops/cyclops-ctrl/internal/controller"
"github.com/cyclops-ui/cyclops/cyclops-ctrl/internal/prometheus"
"github.com/cyclops-ui/cyclops/cyclops-ctrl/internal/telemetry"
Expand Down
3 changes: 3 additions & 0 deletions cyclops-ctrl/pkg/cluster/k8sclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
"errors"
"fmt"
"io"
networkingv1 "k8s.io/api/networking/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/watch"
"os"
"os/exec"
"sort"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,31 @@ const PodTable = ({ pods, namespace, updateResourceData }: Props) => {
<div style={{ width: "400px" }}>
<h3>{pod.name} actions</h3>
<Divider style={{ margin: "8px" }} />
<Row style={{ margin: 4, gap: 8 }}>
<PodLogs pod={{ ...pod, namespace }} />
<PodManifest pod={{ ...pod, namespace }} />
<Button
style={{ color: "red", width: "100%" }}
onClick={function () {
setError({ message: "", description: "" });
setDeletePodRef({
on: true,
podDetails: {
group: ``,
version: `v1`,
kind: `Pod`,
name: pod.name,
namespace: namespace,
},
});
}}
>
<h4>
<DeleteOutlined style={{ paddingRight: "5px" }} />
Delete Pod
</h4>
</Button>
</Row>
<Button
style={{ width: "60%", margin: "4px" }}
onClick={function () {
Expand Down
4 changes: 2 additions & 2 deletions install/cyclops-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ spec:
spec:
containers:
- name: cyclops-ui
image: cyclopsui/cyclops-ui:v0.11.0-rc-streaming.2
image: cyclopsui/cyclops-ui:v0.11.0
ports:
- containerPort: 80
env:
Expand Down Expand Up @@ -406,7 +406,7 @@ spec:
serviceAccountName: cyclops-ctrl
containers:
- name: cyclops-ctrl
image: cyclopsui/cyclops-ctrl:v0.11.0-rc-streaming.2
image: cyclopsui/cyclops-ctrl:v0.11.0
ports:
- containerPort: 8080
env:
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.