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

Alternate kubeconfig #199

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions cmd/generate-docs/main.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package main

import (
"log"
"context"

"github.com/solo-io/go-utils/clidoc"
"github.com/solo-io/go-utils/contextutils"
"github.com/solo-io/squash/pkg/squashctl"
"github.com/solo-io/squash/pkg/version"
)

func main() {
app, err := squashctl.App(version.Version)
if err != nil {
log.Fatal(err)
contextutils.LoggerFrom(context.TODO()).Fatal(err)
}
clidoc.MustGenerateCliDocs(app)
}
6 changes: 6 additions & 0 deletions cmd/log_spool/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# calls the go process only, making it the first PID
FROM alpine
WORKDIR /app
ADD _output/log_spooler /app
EXPOSE 8080
ENTRYPOINT ./log_spooler
23 changes: 23 additions & 0 deletions cmd/log_spool/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
IMAGE_TAG ?= dev
CONTAINER_REPO_ORG ?= docker.io/soloio

## These are the images created by this makefile
APP_SPEC := $(CONTAINER_REPO_ORG)/log_spooler:$(IMAGE_TAG)

ROOTDIR := $(shell pwd)
OUTPUT_DIR := $(ROOTDIR)/_output

.PHONY: all
all: push-app

.PHONY: compile
compile: ${OUTPUT_DIR}
GOOS=linux GOARCH=amd64 go build -gcflags "-N -l" -o $(OUTPUT_DIR)/log_spooler main.go

.PHONY: build-app
build-app: compile
docker build -t $(APP_SPEC) -f Dockerfile .

.PHONY: push-app
push-app: build-app
docker push $(APP_SPEC)
33 changes: 33 additions & 0 deletions cmd/log_spool/log_spooler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: log-spooler
spec:
replicas: 1
selector:
matchLabels:
app: log-spooler
template:
metadata:
labels:
app: log-spooler
spec:
containers:
- name: log-spooler
image: soloio/log_spooler:v0.0.4
ports:
- containerPort: 8080
protocol: TCP
---
kind: Service
apiVersion: v1
metadata:
name: log-spooler
spec:
selector:
app: log-spooler
ports:
- name: http
protocol: TCP
port: 80
targetPort: 8080
13 changes: 13 additions & 0 deletions cmd/log_spool/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package main

import (
"net/http"

"github.com/solo-io/squash/pkg/urllogger"
)

// Helper program to gather logs from pods that crash before you can read their logs
func main() {
http.HandleFunc("/", urllogger.BasicHandlerFunction)
http.ListenAndServe(":8080", nil)
}
15 changes: 8 additions & 7 deletions cmd/plank/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@ import (
"context"
"fmt"

log "github.com/sirupsen/logrus"
"github.com/solo-io/squash/pkg/version"

"github.com/solo-io/squash/pkg/urllogger"

"github.com/solo-io/go-utils/contextutils"
"github.com/solo-io/squash/pkg/plank"
"github.com/solo-io/squash/pkg/version"
"go.uber.org/zap"
)

func main() {
// TODO - switch to zap throughout
log.SetLevel(log.DebugLevel)
log.Infof("plank %v, %v", version.Version, version.TimeStamp)
logger, _ := zap.NewProduction()
//logger, _ := zap.NewProduction()
logger := zap.New(urllogger.GetSpoolerLoggerCoreDefault())
defer logger.Sync()
contextutils.SetFallbackLogger(logger.Sugar())
ctx := context.Background()
ctx = contextutils.WithLogger(ctx, "squash")
ctx = contextutils.WithLogger(ctx, "squash-plank")
logger.Sugar().Infof("plank %v, %v", version.Version, version.TimeStamp)

err := plank.Debug(ctx)
if err != nil {
Expand Down
31 changes: 21 additions & 10 deletions cmd/squash/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package main

import (
log "github.com/sirupsen/logrus"
"context"
"fmt"

"github.com/solo-io/go-utils/contextutils"
"github.com/solo-io/squash/pkg/urllogger"
"go.uber.org/zap"

"github.com/solo-io/squash/pkg/squash"

"github.com/solo-io/squash/pkg/debuggers/remote"
Expand All @@ -10,28 +16,33 @@ import (
)

func main() {
log.SetLevel(log.DebugLevel)
//logger, _ := zap.NewProduction()
logger := zap.New(urllogger.GetSpoolerLoggerCoreDefault())
defer logger.Sync()

customFormatter := new(log.TextFormatter)
log.SetFormatter(customFormatter)
logger.Sugar().Infof("squash started %v, %v", version.Version, version.TimeStamp)

log.Infof("squash started %v, %v", version.Version, version.TimeStamp)
ctx := context.Background()
ctx = contextutils.WithLogger(ctx, "squash")
mustGetContainerProcessLocator(ctx)
err := squash.RunSquash(ctx, remote.GetParticularDebugger)
if err != nil {
fmt.Println(err)
logger.With(zap.Error(err)).Fatal("Error running debug bridge")

mustGetContainerProcessLocator()
err := squash.RunSquash(remote.GetParticularDebugger)
log.WithError(err).Fatal("Error running debug bridge")
}

}

// The debugging pod needs to be able to get a container process
// This function is a way to fail early (from the squash pod) if the running
// version of Kubernetes does not support the needed API.
func mustGetContainerProcessLocator() {
func mustGetContainerProcessLocator(ctx context.Context) {
_, err := kubernetes.NewContainerProcess()
if err != nil {
_, err := kubernetes.NewCRIContainerProcessAlphaV1()
if err != nil {
log.WithError(err).Fatal("Cannot get container process locator")
contextutils.LoggerFrom(ctx).With(zap.Error(err)).Fatal("Cannot get container process locator")
}
}
}
72 changes: 0 additions & 72 deletions cmd/testdebuggerinterface/main.go

This file was deleted.

6 changes: 6 additions & 0 deletions cmd/zapout/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# calls the go process only, making it the first PID
FROM alpine
WORKDIR /app
ADD _output/log_spooler_ping /app
EXPOSE 8080
ENTRYPOINT ./log_spooler_ping
26 changes: 26 additions & 0 deletions cmd/zapout/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
IMAGE_TAG ?= dev
CONTAINER_REPO_ORG ?= docker.io/soloio

## These are the images created by this makefile
APP_SPEC := $(CONTAINER_REPO_ORG)/log_spooler_ping:$(IMAGE_TAG)

ROOTDIR := $(shell pwd)
OUTPUT_DIR := $(ROOTDIR)/_output

.PHONY: all
all: push-app

${OUTPUT_DIR}:
mkdir $@

.PHONY: compile
compile: ${OUTPUT_DIR}
GOOS=linux GOARCH=amd64 go build -gcflags "-N -l" -o $(OUTPUT_DIR)/log_spooler_ping main.go

.PHONY: build-app
build-app: compile
docker build -t $(APP_SPEC) -f Dockerfile .

.PHONY: push-app
push-app: build-app
docker push $(APP_SPEC)
33 changes: 33 additions & 0 deletions cmd/zapout/log_spooler_ping.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: log-spooler-ping
spec:
replicas: 1
selector:
matchLabels:
app: log-spooler-ping
template:
metadata:
labels:
app: log-spooler-ping
spec:
containers:
- name: log-spooler-ping
image: soloio/log_spooler_ping:v0.0.4
ports:
- containerPort: 8080
protocol: TCP
---
kind: Service
apiVersion: v1
metadata:
name: log-spooler-ping
spec:
selector:
app: log-spooler-ping
ports:
- name: http
protocol: TCP
port: 80
targetPort: 8080
19 changes: 19 additions & 0 deletions cmd/zapout/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package main

import (
"fmt"
"time"

"github.com/solo-io/squash/pkg/urllogger"

"go.uber.org/zap"
)

func main() {
core := urllogger.GetSpoolerLoggerCore()
logger := zap.New(core)
for i := 0; i < 100; i++ {
logger.Info(fmt.Sprintf("HEY %v", i))
time.Sleep(1 * time.Second)
}
}
6 changes: 4 additions & 2 deletions contrib/condition/multi_process/main.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package main

import (
"context"
"fmt"
"log"
"net/http"
"os"

"github.com/solo-io/go-utils/contextutils"
)

var ServiceToCall = "example-service2"
Expand All @@ -20,7 +22,7 @@ func main() {
http.HandleFunc("/calc", handler)
http.HandleFunc("/", view)

log.Fatal(http.ListenAndServe(":8080", nil))
contextutils.LoggerFrom(context.TODO()).Fatal(http.ListenAndServe(":8080", nil))
}

func view(w http.ResponseWriter, r *http.Request) {
Expand Down
Loading