Skip to content

Commit

Permalink
Merge pull request #6 from wongnai/whs/bump-deps
Browse files Browse the repository at this point in the history
Bump dependencies, upgrade to stable otel, remove node_id metric
  • Loading branch information
whs authored Aug 9, 2023
2 parents 5a924a0 + e5e2ab7 commit 1ba7485
Show file tree
Hide file tree
Showing 15 changed files with 179 additions and 364 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.17 AS builder
FROM golang:1.20 AS builder
RUN go install -v -trimpath github.com/grpc-ecosystem/[email protected]
COPY . /build
WORKDIR /build
Expand Down
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A simple xDS server, distributing Kubernetes service endpoints to clients.

It is designed for [gRPC](https://grpc.github.io/grpc/cpp/md_doc_grpc_xds_features.html).

This software is in **alpha** stage.
This software has been powering Wongnai and LINE MAN production since Q1 2022

## Why xDS?

Expand Down Expand Up @@ -90,16 +90,13 @@ Make sure gRPC Python is at least v1.36. No code change is needed.

### JavaScript

Install `@grpc/grpc-js-xds` then run
Install [@grpc/grpc-js-xds](https://www.npmjs.com/package/@grpc/grpc-js-xds) 1.5.0 or later then run

```javascript
require('@grpc/grpc-js-xds').register();
```

At this time of writing, grpc-js-xds v1.4.0 is broken and earlier versions do not support xDSv3. You'll need to install
the package from the main branch for this to work.

Note that gRPC C (the `grpc` package) is deprecated and does not contains xDS support.
Note that gRPC C (the [grpc](https://www.npmjs.com/package/grpc) package) is deprecated and does not contains xDS support.

### Java
You need to add grpc-xds dependency along with the common grpc dependencies.
Expand Down
22 changes: 15 additions & 7 deletions debug/marshaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,27 @@ func (c cacheMarshaler) MarshalJSON() ([]byte, error) {
out[node] = nodeMap

for i := types.ResponseType(0); i < types.UnknownType; i++ {
if len(snapshot.Resources[i].Items) == 0 {
typeURL, _ := cache.GetResponseTypeURL(i)
version := snapshot.GetVersion(typeURL)
resources := snapshot.GetResources(typeURL)

if len(resources) == 0 {
continue
}
typeName, _ := cache.GetResponseTypeURL(i)
nodeMap[typeName] = resourcesMarshaler{snapshot.Resources[i]}

nodeMap[typeURL] = resourcesMarshaler{
version: version,
resources: resources,
}
}
}

return json.Marshal(out)
}

type resourcesMarshaler struct {
cache.Resources
version string
resources map[string]types.Resource
}

func (r resourcesMarshaler) MarshalJSON() ([]byte, error) {
Expand All @@ -53,12 +61,12 @@ func (r resourcesMarshaler) MarshalJSON() ([]byte, error) {
}

out := outMap{
Version: r.Version,
Version: r.version,
Items: map[string]resourceMarshaler{},
}

for k, v := range r.Resources.Items {
out.Items[k] = resourceMarshaler{Resource: v.Resource}
for k, v := range r.resources {
out.Items[k] = resourceMarshaler{Resource: v}
}

return json.Marshal(out)
Expand Down
8 changes: 2 additions & 6 deletions debug/server.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package debug

import (
"github.com/prometheus/client_golang/prometheus/promhttp"
"net/http"
"net/http/pprof"

"github.com/envoyproxy/go-control-plane/pkg/cache/v3"
"github.com/wongnai/xds/meter"
"k8s.io/apimachinery/pkg/util/json"
)

Expand Down Expand Up @@ -33,11 +33,7 @@ func (s *Server) register() {
s.mux.HandleFunc("/_hc", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("ok"))
})
exporter, err := meter.CreateExporter()
if err != nil {
panic(err)
}
s.mux.HandleFunc("/metrics", exporter.ServeHTTP)
s.mux.Handle("/metrics", promhttp.Handler())

s.mux.HandleFunc("/debug/pprof/", pprof.Index)
s.mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
Expand Down
65 changes: 33 additions & 32 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
module github.com/wongnai/xds

go 1.17
go 1.20

require (
github.com/cespare/xxhash v1.1.0
github.com/envoyproxy/go-control-plane v0.10.1
github.com/golang/protobuf v1.5.2
go.opentelemetry.io/otel v1.3.0
go.opentelemetry.io/otel/exporters/prometheus v0.26.0
go.opentelemetry.io/otel/metric v0.26.0
go.opentelemetry.io/otel/sdk/export/metric v0.26.0
go.opentelemetry.io/otel/sdk/metric v0.26.0
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
google.golang.org/grpc v1.43.0
google.golang.org/protobuf v1.27.1
github.com/envoyproxy/go-control-plane v0.11.1
github.com/golang/protobuf v1.5.3
github.com/prometheus/client_golang v1.15.1
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.42.0
go.opentelemetry.io/otel v1.16.0
go.opentelemetry.io/otel/exporters/prometheus v0.39.0
go.opentelemetry.io/otel/metric v1.16.0
go.opentelemetry.io/otel/sdk/metric v0.39.0
golang.org/x/sync v0.1.0
google.golang.org/grpc v1.55.0
google.golang.org/protobuf v1.30.0
k8s.io/api v0.23.2
k8s.io/apimachinery v0.23.2
k8s.io/client-go v0.23.2
Expand All @@ -22,41 +23,41 @@ require (

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/census-instrumentation/opencensus-proto v0.3.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cncf/xds/go v0.0.0-20220112060520-0fa49ea1db0c // indirect
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cncf/xds/go v0.0.0-20230428030218-4003588d1b74 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/envoyproxy/protoc-gen-validate v0.6.3 // indirect
github.com/go-logr/logr v1.2.2 // indirect
github.com/envoyproxy/protoc-gen-validate v1.0.1 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/go-cmp v0.5.7 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/prometheus/client_golang v1.12.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.opentelemetry.io/otel/internal/metric v0.26.0 // indirect
go.opentelemetry.io/otel/sdk v1.3.0 // indirect
go.opentelemetry.io/otel/trace v1.3.0 // indirect
golang.org/x/net v0.0.0-20220114011407-0dd24b26b47d // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
go.opentelemetry.io/otel/sdk v1.16.0 // indirect
go.opentelemetry.io/otel/trace v1.16.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.6.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220118154757-00ab72f36ad5 // indirect
google.golang.org/genproto v0.0.0-20230526203410-71b5a4ffd15e // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230526203410-71b5a4ffd15e // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230526203410-71b5a4ffd15e // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/kube-openapi v0.0.0-20220114203427-a0453230fd26 // indirect
k8s.io/utils v0.0.0-20211208161948-7d6a63dca704 // indirect
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
Expand Down
Loading

0 comments on commit 1ba7485

Please sign in to comment.