Skip to content

Commit

Permalink
Rename helper to agent (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarick authored Feb 23, 2022
1 parent 6f1bb37 commit 2b49455
Show file tree
Hide file tree
Showing 28 changed files with 150 additions and 150 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,25 @@ jobs:
tags: ${{ steps.meta-kusk-gateway.outputs.tags }}
labels: ${{ steps.meta-kusk-gateway.outputs.labels }}
-
name: Docker metadata for Kusk Gateway Helper
id: meta-kusk-gateway-helper
name: Docker metadata for Kusk Gateway Agent
id: meta-kusk-gateway-agent
uses: docker/metadata-action@v3
with:
images: kubeshop/kusk-gateway-helper
images: kubeshop/kusk-gateway-agent
tags: |
type=match,pattern=v(.*)
type=sha
flavor: |
latest=true
-
name: Build and push Kusk Gateway Helper
name: Build and push Kusk Gateway Agent
uses: docker/build-push-action@v2
with:
context: .
file: build/helper/Dockerfile
file: build/agent/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-kusk-gateway-helper.outputs.tags }}
labels: ${{ steps.meta-kusk-gateway-helper.outputs.labels }}
tags: ${{ steps.meta-kusk-gateway-agent.outputs.tags }}
labels: ${{ steps.meta-kusk-gateway-agent.outputs.labels }}
-
name: Run GoReleaser to publish release notes
uses: goreleaser/goreleaser-action@v2
Expand Down
34 changes: 17 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export PATH := $(shell pwd)/bin:$(PATH)

# Image URL to use all building/pushing image targets
MANAGER_IMG ?= kusk-gateway:dev
HELPER_IMG ?= kusk-gateway-helper:dev
AGENT_IMG ?= kusk-gateway-agent:dev

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.22
Expand Down Expand Up @@ -64,7 +64,7 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
$(CONTROLLER_GEN) rbac:roleName=kusk-gateway-manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases

.PHONY: generate
generate: controller-gen helper-management-compile ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
generate: controller-gen agent-management-compile ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

.PHONY: fmt
Expand All @@ -86,9 +86,9 @@ testing: ## Run the integration tests from development/testing and then delete t
##@ Build

.PHONY: build
build: generate fmt vet ## Build manager and helper binary.
build: generate fmt vet ## Build manager and agent binary.
go build -o bin/manager cmd/manager/main.go
go build -o bin/helper cmd/helper/main.go
go build -o bin/agent cmd/agent/main.go

.PHONY: run
run: install-local generate fmt vet ## Run a controller from your host, proxying it inside the cluster.
Expand All @@ -99,20 +99,20 @@ run: install-local generate fmt vet ## Run a controller from your host, proxying
docker-build-manager: ## Build docker image with the manager.
@eval $$(minikube docker-env --profile kgw); DOCKER_BUILDKIT=1 docker build -t ${MANAGER_IMG} -f ./build/manager/Dockerfile .

.PHONY: docker-build-helper
docker-build-helper: ## Build docker image with the helper.
@eval $$(minikube docker-env --profile kgw); DOCKER_BUILDKIT=1 docker build -t ${HELPER_IMG} -f ./build/helper/Dockerfile .
.PHONY: docker-build-agent
docker-build-agent: ## Build docker image with the agent.
@eval $$(minikube docker-env --profile kgw); DOCKER_BUILDKIT=1 docker build -t ${AGENT_IMG} -f ./build/agent/Dockerfile .

.PHONY: docker-build
docker-build: docker-build-manager docker-build-helper ## Build docker images for all apps
docker-build: docker-build-manager docker-build-agent ## Build docker images for all apps

.PHONY: docker-build-manager-debug
docker-build-manager-debug: ## Build docker image with the manager and debugger.
@eval $$(SHELL=/bin/bash minikube docker-env --profile kgw) ;DOCKER_BUILDKIT=1 docker build -t "${MANAGER_IMG}-debug" -f ./build/manager/Dockerfile-debug .

.PHONY: docker-build-helper-debug
docker-build-helper-debug: ## Build docker image with the helper and debugger.
@eval $$(SHELL=/bin/bash minikube docker-env --profile kgw) ;DOCKER_BUILDKIT=1 docker build -t "${HELPER_IMG}-debug" -f ./build/helper/Dockerfile-debug .
.PHONY: docker-build-agent-debug
docker-build-agent-debug: ## Build docker image with the agent and debugger.
@eval $$(SHELL=/bin/bash minikube docker-env --profile kgw) ;DOCKER_BUILDKIT=1 docker build -t "${AGENT_IMG}-debug" -f ./build/agent/Dockerfile-debug .

##@ Deployment

Expand Down Expand Up @@ -153,11 +153,11 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi
.PHONY: update
update: docker-build-manager deploy cycle ## Runs deploy, docker build and restarts kusk-gateway-manager deployment to pick up the change

.PHONY: update-helper
update-helper: docker-build-helper cycle-envoy
.PHONY: update-agent
update-agent: docker-build-agent cycle-envoy

.PHONY: update-debug
update-debug: docker-build-manager-debug docker-build-helper-debug deploy-debug cycle ## Runs Debug configuration deploy, docker build and restarts kusk-gateway-manager deployment to pick up the change
update-debug: docker-build-manager-debug docker-build-agent-debug deploy-debug cycle ## Runs Debug configuration deploy, docker build and restarts kusk-gateway-manager deployment to pick up the change

.PHONY: cycle
cycle: ## Triggers kusk-gateway-manager deployment rollout restart to pick up the new container image with the same tag
Expand Down Expand Up @@ -196,9 +196,9 @@ $(PROTOC_GEN_GO_GRPC):
@echo "[INFO]: Installing protobuf GRPC go generation plugin."
$(call go-get-tool,$(PROTOC_GEN_GO_GRPC),google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2.0)

.PHONY: helper-management-compile
helper-management-compile: $(PROTOC) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC) # Compile protoc files for helper/management
cd "internal/helper/management"; $(PROTOC) --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative *.proto
.PHONY: agent-management-compile
agent-management-compile: $(PROTOC) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC) # Compile protoc files for agent/management
cd "internal/agent/management"; $(PROTOC) --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative *.proto

# Envtest
ENVTEST = $(shell pwd)/bin/setup-envtest
Expand Down
10 changes: 5 additions & 5 deletions api/v1alpha1/envoyfleet_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,18 @@ type EnvoyFleetSpec struct {
//+optional
TLS TLS `json:"tls,omitempty"`

// Helper sidecar configuration
// Agent sidecar configuration
//+optional
Helper *HelperSpec `json:"helper,omitempty"`
Agent *AgentSpec `json:"agent,omitempty"`
}

type HelperSpec struct {
// Helper sidecar image tag.
type AgentSpec struct {
// Agent sidecar image tag.
// If empty (most of the cases) - will be detected from the Kusk Gateway Manager version and default Kubeshop container repository
//+optional
Image string `json:"image,omitempty"`

// Helper sidecar CPU and Memory resources requests and limits
// Agent sidecar CPU and Memory resources requests and limits
//+optional
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
}
Expand Down
46 changes: 23 additions & 23 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions build/helper/Dockerfile → build/agent/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ RUN go mod download
COPY . .

# Build
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/root/go/pkg CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o helper cmd/helper/main.go
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/root/go/pkg CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o agent cmd/agent/main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/helper .
COPY --from=builder /workspace/agent .
USER 65532:65532

ENTRYPOINT ["/helper"]
ENTRYPOINT ["/agent"]
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ RUN CGO_ENABLED=0 go get github.com/go-delve/delve/cmd/dlv@v1.8.0
COPY . .

# Build
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/root/go/pkg CGO_ENABLED=0 GOOS=linux go build -gcflags "all=-N -l" -v -o helper cmd/helper/main.go
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/root/go/pkg CGO_ENABLED=0 GOOS=linux go build -gcflags "all=-N -l" -v -o agent cmd/agent/main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/helper .
COPY --from=builder /workspace/agent .
COPY --from=builder /go/bin/dlv .
USER 65532:65532

ENTRYPOINT ["/dlv", "--listen=:40001", "--api-version=2", "--headless", "exec", "--accept-multiclient", "--continue", "/helper", "--"]
ENTRYPOINT ["/dlv", "--listen=:40001", "--api-version=2", "--headless", "exec", "--accept-multiclient", "--continue", "/agent", "--"]
18 changes: 9 additions & 9 deletions cmd/helper/main.go → cmd/agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"os"
"time"

"github.com/kubeshop/kusk-gateway/internal/helper/httpserver"
"github.com/kubeshop/kusk-gateway/internal/helper/management"
"github.com/kubeshop/kusk-gateway/internal/agent/httpserver"
"github.com/kubeshop/kusk-gateway/internal/agent/management"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"google.golang.org/grpc"
Expand All @@ -20,12 +20,12 @@ import (
func main() {

var (
helperConfigurationManagerServiceAddress string
log *zap.SugaredLogger
fleetID string
agentConfigurationManagerServiceAddress string
log *zap.SugaredLogger
fleetID string
)
flag.StringVar(&helperConfigurationManagerServiceAddress, "helper-config-manager-service-address", "", "The address (hostname:port) of Kusk Gateway Helper Configuration Manager Service")
flag.StringVar(&fleetID, "fleetID", "", "The Envoy Fleet ID this Helper server is deployed for.")
flag.StringVar(&agentConfigurationManagerServiceAddress, "agent-config-manager-service-address", "", "The address (hostname:port) of Kusk Gateway Agent Configuration Manager Service")
flag.StringVar(&fleetID, "fleetID", "", "The Envoy Fleet ID this Agent server is deployed for.")
flag.Parse()
log = initLogger().Sugar()
defer log.Sync()
Expand All @@ -52,8 +52,8 @@ func main() {
// Creates the connection, wait for the commands and respond
// Using closure since this respawns if failed and we defer a lot of closing operations.
connection := func() {
log.Info("Dialing to the management service at: ", helperConfigurationManagerServiceAddress)
conn, err := grpc.Dial(helperConfigurationManagerServiceAddress, grpcOpts...)
log.Info("Dialing to the management service at: ", agentConfigurationManagerServiceAddress)
conn, err := grpc.Dial(agentConfigurationManagerServiceAddress, grpcOpts...)
defer conn.Close()
if err != nil {
log.Errorf("failed to dial: %v", err)
Expand Down
14 changes: 7 additions & 7 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook"

gateway "github.com/kubeshop/kusk-gateway/api/v1alpha1"
agentManagement "github.com/kubeshop/kusk-gateway/internal/agent/management"
"github.com/kubeshop/kusk-gateway/internal/controllers"
"github.com/kubeshop/kusk-gateway/internal/envoy/manager"
helperManagement "github.com/kubeshop/kusk-gateway/internal/helper/management"
"github.com/kubeshop/kusk-gateway/internal/validation"
)

Expand Down Expand Up @@ -157,15 +157,15 @@ func main() {
enableLeaderElection bool
probeAddr string
envoyControlPlaneAddr string
helperManagerAddr string
agentManagerAddr string
logLevel string
development bool
)

flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.StringVar(&envoyControlPlaneAddr, "envoy-control-plane-bind-address", ":18000", "The address Envoy control plane XDS server binds to.")
flag.StringVar(&helperManagerAddr, "helper-manager-bind-address", ":18010", "The address Helper Manager service binds to.")
flag.StringVar(&agentManagerAddr, "agent-manager-bind-address", ":18010", "The address Agent Manager service binds to.")
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
Expand Down Expand Up @@ -218,11 +218,11 @@ func main() {
}
}()

helperManager := helperManagement.New(context.Background(), helperManagerAddr, logger)
agentManager := agentManagement.New(context.Background(), agentManagerAddr, logger)

go func() {
if err := helperManager.Start(); err != nil {
setupLog.Error(err, "unable to start Helper Manager Server")
if err := agentManager.Start(); err != nil {
setupLog.Error(err, "unable to start Agent Manager Server")
os.Exit(1)
}
}()
Expand All @@ -233,7 +233,7 @@ func main() {
Scheme: mgr.GetScheme(),
EnvoyManager: envoyManager,
Validator: proxy,
HelperManager: helperManager,
AgentManager: agentManager,
SecretToEnvoyFleet: map[string]gateway.EnvoyFleetID{},
WatchedSecretsChan: secretsChan,
}
Expand Down
20 changes: 10 additions & 10 deletions config/crd/bases/gateway.kusk.io_envoyfleet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -891,22 +891,17 @@ spec:
type: array
type: object
type: object
annotations:
additionalProperties:
type: string
description: Additional Envoy Deployment annotations, optional
type: object
helper:
description: Helper sidecar configuration
agent:
description: Agent sidecar configuration
properties:
image:
description: Helper sidecar image tag. If empty (most of the cases)
description: Agent sidecar image tag. If empty (most of the cases)
- will be detected from the Kusk Gateway Manager version and
default Kubeshop container repository
type: string
resources:
description: Helper sidecar CPU and Memory resources requests
and limits
description: Agent sidecar CPU and Memory resources requests and
limits
properties:
limits:
additionalProperties:
Expand All @@ -932,6 +927,11 @@ spec:
type: object
type: object
type: object
annotations:
additionalProperties:
type: string
description: Additional Envoy Deployment annotations, optional
type: object
image:
description: Envoy image tag
type: string
Expand Down
2 changes: 1 addition & 1 deletion config/default/manager_webhook_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
name: validator
protocol: TCP
- containerPort: 18010
name: helper-config
name: agent-config
protocol: TCP
volumeMounts:
- mountPath: /tmp/k8s-webhook-server/serving-certs
Expand Down
Loading

0 comments on commit 2b49455

Please sign in to comment.