Skip to content

Commit

Permalink
feat: add config flag for grpc endpoint (#178)
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian authored Jan 29, 2024
1 parent fa15f8a commit 675254f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ jobs:
working-directory: ${{ env.GOPATH }}/src/github.com/akash-network/provider
run: |
__pod=$(kubectl -n akash-services get pods -l app.kubernetes.io/part-of=provider -l app.kubernetes.io/component=operator -l app.kubernetes.io/instance=inventory-node --no-headers -o custom-columns=":metadata.name")
kubectl -n akash-services port-forward --address 0.0.0.0 pod/$__pod 8444:grpc &
kubectl -n akash-services port-forward --address 0.0.0.0 service/operator-inventory 8445:grpc &
kubectl -n akash-services port-forward --address 0.0.0.0 pod/$__pod 8454:grpc &
kubectl -n akash-services port-forward --address 0.0.0.0 service/operator-inventory 8455:grpc &
timeout 10 bash -c -- 'while ! nc -vz localhost 8445 > /dev/null 2>&1 ; do sleep 0.1; done'
timeout 10 bash -c -- 'while ! nc -vz localhost 8444 > /dev/null 2>&1 ; do sleep 0.1; done'
timeout 10 bash -c -- 'while ! nc -vz localhost 8454 > /dev/null 2>&1 ; do sleep 0.1; done'
timeout 10 bash -c -- 'while ! nc -vz localhost 8455 > /dev/null 2>&1 ; do sleep 0.1; done'
${{ env.GOPATH }}/src/github.com/akash-network/akash-api/script/grpc-probe.sh --host=localhost:8444 --mode=plaintext akash.inventory.v1.NodeRPC/QueryNode
${{ env.GOPATH }}/src/github.com/akash-network/akash-api/script/grpc-probe.sh --host=localhost:8445 --mode=plaintext akash.inventory.v1.ClusterRPC/QueryCluster
${{ env.GOPATH }}/src/github.com/akash-network/akash-api/script/grpc-probe.sh --host=localhost:8454 --mode=plaintext akash.inventory.v1.NodeRPC/QueryNode
${{ env.GOPATH }}/src/github.com/akash-network/akash-api/script/grpc-probe.sh --host=localhost:8455 --mode=plaintext akash.inventory.v1.ClusterRPC/QueryCluster
kubectl -n akash-services logs service/operator-inventory
- name: Run E2E Tests
working-directory: ${{ env.GOPATH }}/src/github.com/akash-network/provider
Expand Down
2 changes: 2 additions & 0 deletions _docs/kustomize/akash-provider/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ spec:
ports:
- name: gateway
containerPort: 8443
- name: grpc
containerPort: 8444
volumeMounts:
- name: home
mountPath: /home
Expand Down
2 changes: 2 additions & 0 deletions _docs/kustomize/akash-provider/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ spec:
ports:
- name: gateway
port: 8443
- name: gateway
port: 8444
13 changes: 8 additions & 5 deletions cmd/provider-services/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const (

// FlagGatewayListenAddress determines listening address for Manifests
FlagGatewayListenAddress = "gateway-listen-address"
FlagGatewayGRPCListenAddress = "gateway-grpc-listen-address"
FlagBidPricingStrategy = "bid-price-strategy"
FlagBidPriceCPUScale = "bid-price-cpu-scale"
FlagBidPriceMemoryScale = "bid-price-memory-scale"
Expand Down Expand Up @@ -180,6 +181,11 @@ func RunCmd() *cobra.Command {
panic(err)
}

cmd.Flags().String(FlagGatewayGRPCListenAddress, "0.0.0.0:8444", "Gateway listen address")
if err := viper.BindPFlag(FlagGatewayGRPCListenAddress, cmd.Flags().Lookup(FlagGatewayGRPCListenAddress)); err != nil {
panic(err)
}

cmd.Flags().String(FlagBidPricingStrategy, "scale", "Pricing strategy to use")
if err := viper.BindPFlag(FlagBidPricingStrategy, cmd.Flags().Lookup(FlagBidPricingStrategy)); err != nil {
panic(err)
Expand Down Expand Up @@ -523,6 +529,7 @@ func doRunCmd(ctx context.Context, cmd *cobra.Command, _ []string) error {
}

gwaddr := viper.GetString(FlagGatewayListenAddress)
grpcaddr := viper.GetString(FlagGatewayGRPCListenAddress)

var certFromFlag io.Reader
if val := cmd.Flag(FlagAuthPem).Value.String(); val != "" {
Expand Down Expand Up @@ -704,15 +711,11 @@ func doRunCmd(ctx context.Context, cmd *cobra.Command, _ []string) error {
return err
}

err = gwgrpc.NewServer(ctx, ":8081", []tls.Certificate{tlsCert}, service)
err = gwgrpc.NewServer(ctx, grpcaddr, []tls.Certificate{tlsCert}, service)
if err != nil {
return err
}

// clGroup.Go(func() error {
// return group.Wait()
// })

group.Go(func() error {
return events.Publish(ctx, cctx.Client, "provider-cli", bus)
})
Expand Down

0 comments on commit 675254f

Please sign in to comment.