-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
1,243 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Build | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
name: Build | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: google-github-actions/auth@v1 | ||
id: auth | ||
with: | ||
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }} | ||
token_format: access_token | ||
- uses: docker/login-action@v1 | ||
with: | ||
registry: asia-southeast1-docker.pkg.dev | ||
username: oauth2accesstoken | ||
password: ${{ steps.auth.outputs.access_token }} | ||
- uses: docker/setup-buildx-action@v2 | ||
with: | ||
version: latest | ||
- uses: docker/build-push-action@v4 | ||
with: | ||
provenance: false | ||
push: true | ||
tags: asia-southeast1-docker.pkg.dev/deploys-app/public/log:${{ github.sha }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.DS_Store | ||
.idea/ | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
golang 1.21.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM gcr.io/moonrhythm-containers/builder | ||
|
||
ENV CGO_ENABLED=0 | ||
|
||
WORKDIR /workspace | ||
|
||
ADD .tool-versions . | ||
RUN asdf install | ||
|
||
ADD go.mod go.sum ./ | ||
RUN go mod download | ||
ADD . . | ||
RUN go build -o .build/log -ldflags "-w -s" . | ||
|
||
FROM gcr.io/distroless/static | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=0 --link /workspace/.build/* ./ | ||
ENTRYPOINT ["/app/log"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
# log | ||
# log | ||
|
||
Log agent running inside the cluster. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
module github.com/deploys-app/log | ||
|
||
go 1.21.4 | ||
|
||
require ( | ||
github.com/acoshift/configfile v1.9.0 | ||
github.com/golang-jwt/jwt v3.2.2+incompatible | ||
github.com/moonrhythm/parapet v0.13.3 | ||
golang.org/x/sync v0.3.0 | ||
k8s.io/api v0.27.8 | ||
k8s.io/apimachinery v0.27.8 | ||
k8s.io/client-go v0.27.8 | ||
k8s.io/utils v0.0.0-20230505201702-9f6742963106 | ||
) | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/emicklei/go-restful/v3 v3.9.0 // indirect | ||
github.com/go-logr/logr v1.2.4 // indirect | ||
github.com/go-openapi/jsonpointer v0.19.6 // indirect | ||
github.com/go-openapi/jsonreference v0.20.1 // indirect | ||
github.com/go-openapi/swag v0.22.3 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/protobuf v1.5.3 // indirect | ||
github.com/google/gnostic v0.6.9 // indirect | ||
github.com/google/go-cmp v0.5.9 // indirect | ||
github.com/google/gofuzz v1.2.0 // indirect | ||
github.com/google/uuid v1.3.1 // indirect | ||
github.com/joho/godotenv v1.5.1 // indirect | ||
github.com/josharian/intern v1.0.0 // indirect | ||
github.com/json-iterator/go v1.1.12 // indirect | ||
github.com/kavu/go_reuseport v1.5.0 // indirect | ||
github.com/kr/pretty v0.3.1 // indirect | ||
github.com/mailru/easyjson v0.7.7 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.2 // indirect | ||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect | ||
github.com/onsi/ginkgo/v2 v2.9.5 // indirect | ||
github.com/onsi/gomega v1.27.7 // indirect | ||
golang.org/x/net v0.17.0 // indirect | ||
golang.org/x/oauth2 v0.12.0 // indirect | ||
golang.org/x/sys v0.13.0 // indirect | ||
golang.org/x/term v0.13.0 // indirect | ||
golang.org/x/text v0.13.0 // indirect | ||
golang.org/x/time v0.3.0 // indirect | ||
google.golang.org/appengine v1.6.8 // indirect | ||
google.golang.org/protobuf v1.31.0 // indirect | ||
gopkg.in/inf.v0 v0.9.1 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
k8s.io/klog/v2 v2.100.1 // indirect | ||
k8s.io/kube-openapi v0.0.0-20230515203736-54b630e78af5 // indirect | ||
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect | ||
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect | ||
sigs.k8s.io/yaml v1.3.0 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package k8s | ||
|
||
import ( | ||
"k8s.io/client-go/kubernetes" | ||
"k8s.io/client-go/rest" | ||
) | ||
|
||
type Client struct { | ||
client *kubernetes.Clientset | ||
namespace string | ||
} | ||
|
||
func NewClient(namespace string) (*Client, error) { | ||
config, err := rest.InClusterConfig() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
client, err := kubernetes.NewForConfig(config) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &Client{ | ||
client: client, | ||
namespace: namespace, | ||
}, nil | ||
} | ||
|
||
func NewLocalClient(namespace string) (*Client, error) { | ||
config := &rest.Config{ | ||
Host: "localhost:8001", | ||
APIPath: "/", | ||
} | ||
|
||
client, err := kubernetes.NewForConfig(config) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &Client{ | ||
client: client, | ||
namespace: namespace, | ||
}, nil | ||
} |
Oops, something went wrong.