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

257 refactorcloud component renaming #279

Merged
merged 3 commits into from
Mar 3, 2025
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/container-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ jobs:
--bare --verbose .
cd ../..
# Uncomment after agent works
# cd cmd/cloud
# KO_DOCKER_REPO=${{ env.BASE_REPO }}/serviceradar-cloud CGO_ENABLED=1 GOFLAGS="-tags=containers" ko build ...
# cd cmd/core
# KO_DOCKER_REPO=${{ env.BASE_REPO }}/serviceradar-core CGO_ENABLED=1 GOFLAGS="-tags=containers" ko build ...
# (add other components)
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
run: |
./scripts/setup-deb-agent.sh
./scripts/setup-deb-poller.sh
./scripts/setup-deb-cloud.sh
./scripts/setup-deb-core.sh
./scripts/setup-deb-web.sh
./scripts/setup-deb-dusk-checker.sh
./scripts/setup-deb-snmp-checker.sh
Expand Down Expand Up @@ -76,10 +76,10 @@ jobs:
run: ./scripts/build-web.sh
- name: Move web artifacts
run: |
mkdir -p pkg/cloud/api/web/
cp -r web/dist pkg/cloud/api/web/
mkdir -p cmd/cloud/.kodata
cp -r web/dist cmd/cloud/.kodata/web
mkdir -p pkg/core/api/web/
cp -r web/dist pkg/core/api/web/
mkdir -p cmd/core/.kodata
cp -r web/dist cmd/core/.kodata/web
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
Expand All @@ -100,6 +100,6 @@ jobs:
--image-refs=image-refs.txt \
./cmd/agent \
./cmd/poller \
./cmd/cloud \
./cmd/core \
./cmd/checkers/dusk \
./cmd/checkers/snmp
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ elements/
# binaries
./poller
./agent
./cloud
./core

./web/dist/assets
./dist
Expand All @@ -157,6 +157,8 @@ elements/
serviceradar-dusk_*/
serviceradar-poller_*/
serviceradar-cloud_*/
serviceradar-core*/
serviceradar-web*/
/pkg/cloud/api/web/dist/assets/

# Coverage files
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ issues:
# exclude-use-default: false # By default, golangci-lint does not enforce comments on exported types. We want it.
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: pkg/cloud/api/server\.go
- path: pkg/core/api/server\.go
linters:
- typecheck
- path: _test\.go
Expand Down
42 changes: 21 additions & 21 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ builds:
ldflags:
- -s -w -X main.version={{.Version}}

- id: serviceradar-cloud
main: ./cmd/cloud/main.go
binary: serviceradar-cloud
- id: serviceradar-core
main: ./cmd/core/main.go
binary: serviceradar-core
dir: .
goos:
- linux
Expand All @@ -67,7 +67,7 @@ builds:
- -s -w -X main.version={{.Version}}
hooks:
pre:
- ./scripts/build-cloud.sh {{ .Version }}
- ./scripts/build-core.sh {{ .Version }}

nfpms:
- id: agent
Expand Down Expand Up @@ -118,34 +118,34 @@ nfpms:
postinstall: ./packaging/poller/scripts/postinstall.sh
preremove: ./packaging/poller/scripts/preremove.sh

- id: cloud
package_name: serviceradar-cloud
- id: core
package_name: serviceradar-core
file_name_template: "{{ .PackageName }}_{{ .Version }}"
builds:
- serviceradar-cloud
- serviceradar-core
vendor: ServiceRadar
homepage: https://github.com/carverauto/serviceradar
maintainer: Michael Freeman <[email protected]>
description: ServiceRadar Cloud Component
description: ServiceRadar Core Component
license: MIT
formats:
- deb
dependencies:
- systemd
contents:
- src: dist/cloud_linux_amd64_v1/serviceradar-cloud
dst: /usr/local/bin/serviceradar-cloud
- src: ./packaging/cloud/systemd/serviceradar-cloud.service
dst: /lib/systemd/system/serviceradar-cloud.service
- src: ./packaging/cloud/config/cloud.json
dst: /etc/serviceradar/cloud.json
- src: dist/core_linux_amd64_v1/serviceradar-core
dst: /usr/local/bin/serviceradar-core
- src: ./packaging/core/systemd/serviceradar-core.service
dst: /lib/systemd/system/serviceradar-core.service
- src: ./packaging/core/config/core.json
dst: /etc/serviceradar/core.json
type: config
- src: pkg/cloud/api/web/dist
dst: /usr/local/share/serviceradar-cloud/web/dist
- src: pkg/core/api/web/dist
dst: /usr/local/share/serviceradar-core/web/dist
type: "tree"
scripts:
postinstall: ./packaging/cloud/scripts/postinstall.sh
preremove: ./packaging/cloud/scripts/preremove.sh
postinstall: ./packaging/core/scripts/postinstall.sh
preremove: ./packaging/core/scripts/preremove.sh

- id: dusk-checker
package_name: serviceradar-dusk-checker
Expand Down Expand Up @@ -184,7 +184,7 @@ release:
- serviceradar-dusk-checker: Agent package for monitoring Dusk nodes
- serviceradar-agent: Agent performs checks, collects information from external checkers (dusk)
- serviceradar-poller: Network poller for collecting monitoring data from Agent
- serviceradar-cloud: Cloud service with web interface and alerts
- serviceradar-core: Core service with web interface and alerts

## Installation
See the [README.md](README.md) for detailed installation instructions.
Expand All @@ -197,8 +197,8 @@ release:
sudo dpkg -i serviceradar-dusk-checker_{{ .Version }}.deb
# On monitoring host (can co-locate with agent):
sudo dpkg -i serviceradar-poller_{{ .Version }}.deb
# On cloud host (can co-locate with poller+agent):
sudo dpkg -i serviceradar-cloud_{{ .Version }}.deb
# On core host (can co-locate with poller+agent):
sudo dpkg -i serviceradar-core_{{ .Version }}.deb
```

changelog:
Expand Down
6 changes: 3 additions & 3 deletions .ko.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ builds:
ldflags:
- -s -w -X main.version={{.Env.VERSION}}

- id: cloud
dir: ./cmd/cloud
main: ./cmd/cloud
- id: core
dir: ./cmd/core
main: ./cmd/core
env:
- CGO_ENABLED=0
flags:
Expand Down
16 changes: 8 additions & 8 deletions Dockerfile-rpm.cloud → Dockerfile-rpm.core
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ RUN go mod download
COPY . .

# Copy the built web UI from the previous stage
COPY --from=web-builder /web-build/dist ./pkg/cloud/api/web/dist
COPY --from=web-builder /web-build/dist ./pkg/core/api/web/dist

# Build the cloud service
# Build the core service
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 \
go build -o serviceradar-cloud ./cmd/cloud
go build -o serviceradar-core ./cmd/core

# Stage 3: Create RPM
FROM --platform=linux/amd64 rockylinux:9 AS rpm-builder
Expand All @@ -60,12 +60,12 @@ RUN dnf install -y \
RUN rpmdev-setuptree

# Copy built artifacts and spec files
COPY --from=go-builder /src/serviceradar-cloud /root/rpmbuild/BUILD/
COPY --from=go-builder /src/serviceradar-core /root/rpmbuild/BUILD/
COPY packaging/config/*.json /root/rpmbuild/SOURCES/config/
# TODO: fix this, sweep.json is part of agent NOT cloud.g
# TODO: fix this, sweep.json is part of agent NOT core
COPY packaging/config/checkers/sweep/sweep.json /root/rpmbuild/SOURCES/config/checkers/sweep/
COPY packaging/specs/serviceradar-cloud.spec /root/rpmbuild/SPECS/
COPY packaging/cloud/systemd/serviceradar-cloud.service /root/rpmbuild/SOURCES/systemd/
COPY packaging/specs/serviceradar-core.spec /root/rpmbuild/SPECS/
COPY packaging/core/systemd/serviceradar-core.service /root/rpmbuild/SOURCES/systemd/
COPY scripts/setup-rpm-*.sh /build/

# Set default version (can be overridden at build time)
Expand All @@ -76,7 +76,7 @@ ARG RELEASE=1
RUN rpmbuild -bb \
--define "version ${VERSION}" \
--define "release ${RELEASE}" \
/root/rpmbuild/SPECS/serviceradar-cloud.spec
/root/rpmbuild/SPECS/serviceradar-core.spec

# Stage 4: Create a minimal image with just the RPM
FROM --platform=linux/amd64 rockylinux:9
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ RUN go mod download
COPY . .

# Default command - but we'll override this in build.sh
CMD ["./setup-deb-cloud.sh"]
CMD ["./setup-deb-core.sh"]
6 changes: 3 additions & 3 deletions Dockerfile.cloud → Dockerfile.core
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ RUN go mod download
COPY . .

# Copy the built web UI from the previous stage
COPY --from=web-builder /web-build/dist ./pkg/cloud/api/web/dist
COPY --from=web-builder /web-build/dist ./pkg/core/api/web/dist

# Build the cloud service
# Build the core service
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 \
go build -o serviceradar-cloud ./cmd/cloud
go build -o serviceradar-core ./cmd/core
8 changes: 4 additions & 4 deletions Dockerfile.goreleaser.cloud → Dockerfile.goreleaser.core
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ COPY . .

# Build web interface
RUN cd web && npm install && npm run build \
&& mkdir -p /src/pkg/cloud/api/web \
&& cp -r dist /src/pkg/cloud/api/web/
&& mkdir -p /src/pkg/core/api/web \
&& cp -r dist /src/pkg/core/api/web/

# Build the cloud service
# Build the core service
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 \
go build -o serviceradar-cloud ./cmd/cloud
go build -o serviceradar-core ./cmd/core
45 changes: 19 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,30 +103,23 @@ build: ## Build all binaries
@$(GO) build -ldflags "-X main.version=$(VERSION)" -o bin/serviceradar-agent cmd/agent/main.go
@$(GO) build -ldflags "-X main.version=$(VERSION)" -o bin/serviceradar-poller cmd/poller/main.go
@$(GO) build -ldflags "-X main.version=$(VERSION)" -o bin/serviceradar-dusk-checker cmd/checkers/dusk/main.go
@$(GO) build -ldflags "-X main.version=$(VERSION)" -o bin/serviceradar-cloud cmd/cloud/main.go
@$(GO) build -ldflags "-X main.version=$(VERSION)" -o bin/serviceradar-core cmd/core/main.go
@$(GO) build -ldflags "-X main.version=$(VERSION)" -o bin/serviceradar-snmp-checker cmd/checkers/snmp/main.go

.PHONY: build-web
build-web: ## Build web UI
@echo "$(COLOR_BOLD)Building web UI$(COLOR_RESET)"
@./scripts/build-web.sh
@mkdir -p pkg/cloud/api/web/
@cp -r web/dist pkg/cloud/api/web/

.PHONY: kodata-prep
kodata-prep: build-web ## Prepare kodata directories
@echo "$(COLOR_BOLD)Preparing kodata directories$(COLOR_RESET)"
@mkdir -p cmd/cloud/.kodata
@cp -r pkg/cloud/api/web/dist cmd/cloud/.kodata/web
@mkdir -p cmd/core/.kodata
@cp -r pkg/core/api/web/dist cmd/core/.kodata/web

.PHONY: container-build
container-build: kodata-prep ## Build container images with ko
@echo "$(COLOR_BOLD)Building container images with ko$(COLOR_RESET)"
@cd cmd/agent && KO_DOCKER_REPO=$(KO_DOCKER_REPO)/serviceradar-agent GOFLAGS="-tags=containers" ko build --platform=$(PLATFORMS) --tags=$(VERSION) --bare .
@cd cmd/poller && KO_DOCKER_REPO=$(KO_DOCKER_REPO)/serviceradar-poller GOFLAGS="-tags=containers" ko build --platform=$(PLATFORMS) --tags=$(VERSION) --bare .
@echo "$(COLOR_BOLD)Building cloud container with CGO using Docker (amd64 only)$(COLOR_RESET)"
@echo "$(COLOR_BOLD)Building core container with CGO using Docker (amd64 only)$(COLOR_RESET)"
@docker buildx build --platform=linux/amd64 -f Dockerfile.build \
-t $(KO_DOCKER_REPO)/serviceradar-cloud:$(VERSION) \
-t $(KO_DOCKER_REPO)/serviceradar-core:$(VERSION) \
--build-arg VERSION=$(VERSION) \
--build-arg BUILD_TAGS=containers \
--push .
Expand All @@ -138,10 +131,10 @@ container-push: kodata-prep ## Build and push container images with ko
@echo "$(COLOR_BOLD)Building and pushing container images with ko$(COLOR_RESET)"
@cd cmd/agent && KO_DOCKER_REPO=$(KO_DOCKER_REPO)/serviceradar-agent GOFLAGS="-tags=containers" ko build --platform=$(PLATFORMS) --tags=$(VERSION),latest --bare .
@cd cmd/poller && KO_DOCKER_REPO=$(KO_DOCKER_REPO)/serviceradar-poller GOFLAGS="-tags=containers" ko build --platform=$(PLATFORMS) --tags=$(VERSION),latest --bare .
@echo "$(COLOR_BOLD)Building and pushing cloud container with CGO using Docker (amd64 only)$(COLOR_RESET)"
@echo "$(COLOR_BOLD)Building and pushing core container with CGO using Docker (amd64 only)$(COLOR_RESET)"
@docker buildx build --platform=linux/amd64 -f Dockerfile.build \
-t $(KO_DOCKER_REPO)/serviceradar-cloud:$(VERSION) \
-t $(KO_DOCKER_REPO)/serviceradar-cloud:latest \
-t $(KO_DOCKER_REPO)/serviceradar-core:$(VERSION) \
-t $(KO_DOCKER_REPO)/serviceradar-core:latest \
--build-arg VERSION=$(VERSION) \
--build-arg BUILD_TAGS=containers \
--push .
Expand All @@ -159,15 +152,15 @@ deb-poller: build-web ## Build the poller Debian package
@echo "$(COLOR_BOLD)Building poller Debian package$(COLOR_RESET)"
@./scripts/setup-deb-poller.sh

.PHONY: deb-cloud
deb-cloud: build-web ## Build the cloud Debian package (standard)
@echo "$(COLOR_BOLD)Building cloud Debian package$(COLOR_RESET)"
@VERSION=$(VERSION) ./scripts/setup-deb-cloud.sh
.PHONY: deb-core
deb-core: build-web ## Build the core Debian package (standard)
@echo "$(COLOR_BOLD)Building core Debian package$(COLOR_RESET)"
@VERSION=$(VERSION) ./scripts/setup-deb-core.sh

.PHONY: deb-cloud-container
deb-cloud-container: build-web ## Build the cloud Debian package with container support
@echo "$(COLOR_BOLD)Building cloud Debian package with container support$(COLOR_RESET)"
@VERSION=$(VERSION) BUILD_TAGS=containers ./scripts/setup-deb-cloud.sh
.PHONY: deb-core-container
deb-core-container: build-web ## Build the core Debian package with container support
@echo "$(COLOR_BOLD)Building core Debian package with container support$(COLOR_RESET)"
@VERSION=$(VERSION) BUILD_TAGS=containers ./scripts/setup-deb-core.sh

.PHONY: deb-dusk
deb-dusk: ## Build the Dusk checker Debian package
Expand All @@ -180,12 +173,12 @@ deb-snmp: ## Build the SNMP checker Debian package
@./scripts/setup-deb-snmp-checker.sh

.PHONY: deb-all
deb-all: deb-agent deb-poller deb-cloud deb-dusk deb-snmp ## Build all Debian packages
deb-all: deb-agent deb-poller deb-core deb-dusk deb-snmp ## Build all Debian packages
@echo "$(COLOR_BOLD)All Debian packages built$(COLOR_RESET)"

.PHONY: deb-all-container
deb-all-container: deb-agent deb-poller deb-cloud-container deb-dusk deb-snmp ## Build all Debian packages with container support for cloud
@echo "$(COLOR_BOLD)All Debian packages built (with container support for cloud)$(COLOR_RESET)"
deb-all-container: deb-agent deb-poller deb-core-container deb-dusk deb-snmp ## Build all Debian packages with container support for core
@echo "$(COLOR_BOLD)All Debian packages built (with container support for core)$(COLOR_RESET)"

# Docusaurus commands
.PHONY: docs-start
Expand Down
Loading
Loading