Tags down


Expose kubernetes logs to browser through websocket

By : Giri
Date : October 16 2020, 08:10 AM
I wish this help you I am trying to use sidecar mode in kubernetes to create a logs sidecar to expose specific container logs. And I am using kubernetes client to fetch logs from kubernetes api and send it out by websocket. The code shows below: , Put my final code here, thanks for the tips from @Peter:
code :
func serveWs(w http.ResponseWriter, r *http.Request) {
    w.Header().Set("Access-Control-Allow-Origin", "*")
    conn, err := upgrader.Upgrade(w, r, nil)
    if err != nil {
        if _, ok := err.(websocket.HandshakeError); !ok {

    log.Println("create new connection")

    defer func() {
        log.Println("connection close")

    logsClient, err := InitKubeLogsClient(config.InCluster)
    if err != nil {

    stream, err := logsClient.GetLogs(config.Namespace, config.PodName, config.ContainerName)
    if err != nil {
    defer stream.Close()
    reader := bufio.NewReaderSize(stream, 16)
    lastLine := ""
    for {
        data, isPrefix, err := reader.ReadLine()
        if err != nil {

        lines := strings.Split(string(data), "\r")

        length := len(lines)

        if len(lastLine) > 0 {
            lines[0] = lastLine + lines[0]
            lastLine = ""

        if isPrefix {
            lastLine = lines[length-1]
            lines = lines[:(length - 1)]

        for _, line := range lines {
            if err := conn.WriteMessage(websocket.TextMessage, []byte(line)); err != nil {

Share : facebook icon twitter icon

browser.manage().logs().get('browser') logs are not retrieving browser debug logs

By : user294881
Date : March 29 2020, 07:55 AM
will be helpful for those in need Chrome browser logs is been set to Info, when we change the log structure to debug, then im able to capture debug logs as well. this works only in chrome

on single node kubernetes cluster i can expose a service with 'expose' cmd, but doing it via create -f <svc.json-file

By : Wajahat Ahmed Zia
Date : March 29 2020, 07:55 AM
wish helps you The service json file used label selector name: wordpress, which is different from replication controller's label selector app: wordpress. This means the service created with that json file was targeting pods with name: wordpress label, but the replication controller was targeting pod with app: wordpress label. This is why your service created with json file didn't work as expected.
You may use kubectl get svc wordpress -o yaml to compare both created services.

Logs sent to console using logback configuration in java app, not visible in Kubernetes using kubectl logs

By : SGC Shaw
Date : March 29 2020, 07:55 AM
this one helps. ok so this finally got resolved. The issue was with the logs not being flushed.
In the PatternLayout the %n was missing. Hence everything was going into some buffer I guess and not reaching the console.

how to set up websocket in nodejs to send console.logs to the browser

By : Radek Dlask
Date : March 29 2020, 07:55 AM
will help you To make it send to all currently connected sockets, you need to keep track of which sockets are currently connected and them moving your overwrite of the console functions outside of the connect event like this:
code :
let activeSockets = new Set();

// override console functions
(function() {
    const _privateLog = console.log;
    const _privateError = console.error;
    const _privateInfo = console.info;
    const _privateWarn = console.warn;
    const _privateDebug = console.debug;

    function send(style, data) {
        // send to all currently connected webSockets
        if (typeof data === "object") {
            data = JSON.stringify(data);
        for (let ws of activeSockets) {
            ws.send(`<span style="${style}">${data}</span>`);

    console.log = function (message) {
        send('color:lightgreen', message);
        _privateLog.apply(console, arguments);
    console.error = function (message) {
        send('color:red', message);
        _privateError.apply(console, arguments);
    console.info = function (message) {
        send('color:cyan', message);
        _privateInfo.apply(console, arguments);
    console.warn = function (message) {
        send('color:yellow', message);
        _privateWarn.apply(console, arguments);
    console.debug = function (message) {
        send('color:white', message);
        _privateDebug.apply(console, arguments);

wss.on('connection', function (ws) {
    // maintain list of activeSockets
    ws.on('close', function() {

Traefik Kubernetes: Expose non Kubernetes service

By : Chandra Shekhar
Date : March 29 2020, 07:55 AM
This might help you For starters, I bet that when you kubectl describe svc my-service you have empty endpoints, even though endpoints do exist, right ?
To fix that, you need to adapt your endpoints ports key to have the same ports definition as your service has (name, protocol etc.). You should then see these endpoints in describe service results and be able to use it normally.
Related Posts Related Posts :
  • File not found in Gitlab-CI
  • Using collision to pick up items
  • Polygon on Bing Map using Local GeoJSON Object results in wrong location
  • Searching for a Blame
  • Outlook Add In Recipient Not Being Returned
  • Verify the signing of manifest and application files
  • Gulp 4 watch gulp.series only run one time
  • How to label markers similar to Google Maps in Leaflet
  • How to efficiently manage YAML documents in Java with jacksoon-dataformat-yaml?
  • Camel REST DSL - Premature end of Content-Length delimited message body
  • Moodle database dump not working on restore
  • Return an expression containing ArrayWrapper
  • Does Barcode/Magswipe Track data contains photo/image information on Driving License?
  • Here API Indoor discovery
  • What is the best way to detect a button push - Arduino
  • Does RadListView still exist (Nativescript pro-ui)
  • Implementing traits without repeating methods already defined on the struct
  • Twilio Studio create variable
  • Test sbt plugin
  • Dot Net Nuke 9 Create Site Template
  • TypeError: Cannot read property 'id' of null
  • I don't understand how 'exists' works in mysql
  • Does Flatten have any effects other than flattening collections element-wise?
  • Workaround for pinnable Office add-in on OS X?
  • Opened VS 2013 Solution in VS 2017. Now Razor intellisense doesn't work
  • The application has not been granted consent and is unable to be used for local accounts
  • How to express two columns with org-mode format to be exported by Pandoc to Powerpoint
  • Displaying time relative to a given using luxon library
  • How Do I Use a PanGestureRecognizer to Reposition a Sublayer?
  • Working out the maximum drop-down width for a CComboBoxEx with icons
  • How to send asynchronous call to application insights (AZURE)
  • How can a add a custom license to my dotnet nuget package?
  • What does Metis: Unused theorems mean in this context?
  • dig returns wrong record type
  • Haproxy multi-line config
  • How to programatically retrieve information from organisation directory?
  • How to make the application window maximized by default
  • Mongoose Document.toObject produces GraphQL error
  • Nativescript transparent row gridlayout
  • Apache Airflow - Maintain table for dag_ids with last run date?
  • .NET standard 2.0 project not able to load Dapper 1.50.5
  • CGAL: How do I rotate one 3D vector onto another?
  • Google receipt validation - 401 - permissionDenied
  • Create 2D Circle from Existing Grid
  • Setting up Rethinkdb with bash command in docker-compose
  • Microsoft Cognitive Services Sentiment Analysis: Retention period
  • How to install Cocoapods behind a firewall
  • rxjs - stop observable with a subject subscription
  • Verilog : A task with continuous assign output for local variables
  • Delphi flow with indy
  • How to hide drop-downs when clicking Tableau buttons using Tableau Reader
  • What is the best way to restrict access to an Application Load Balancer?
  • google d8 (v8 shell) navigation on Mac (arrow keys) do not navigate
  • is Bluetooth BR/EDR same as bluetooth Classic
  • How to pass onClick handler from parent to child components through optional labeled arguments
  • Timer Routine to Auto close database doesn't always kick off
  • Why can I not access a variable declared in a macro unless I pass in the name of the variable?
  • How to get the address of a constant in MIPS?
  • What does this Zurb Foundation 6 mixin @include xy-grid() mean?
  • C++ Builder > TControl.Parent property > does the parent free the children?
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org