Skip to content

Commit 99540a5

Browse files
authored
docs: update instructions for building kubectl-retina (#143)
I previously removed the kubectl-retina container and kubectl-retina-image Make targets in #112, which transitioned to building kubectl-retina artifacts with GoReleaser and attaching tarballs to the GitHub releases instead of publishing images. That change was made for Krew #108. This change updates the docs for building kubectl-retina to show how to simply build it with `go build`. Explanation was also added describing how to build for all supported platforms with GoReleaser. Signed-off-by: Evan Baker <[email protected]>
1 parent b48ca3c commit 99540a5

File tree

7 files changed

+972
-241
lines changed

7 files changed

+972
-241
lines changed

.github/workflows/integration.yaml

-74
This file was deleted.

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ hack/tools/bin
3131
.vscode/
3232

3333
dist/
34+
bin/

Makefile

+18-39
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
RMDIR := rm -rf
55

66
## Globals
7+
GIT_CURRENT_BRANCH_NAME := $(shell git rev-parse --abbrev-ref HEAD)
78

89
REPO_ROOT = $(shell git rev-parse --show-toplevel)
910
ifndef TAG
@@ -13,7 +14,6 @@ OUTPUT_DIR = $(REPO_ROOT)/output
1314
BUILD_DIR = $(OUTPUT_DIR)/$(GOOS)_$(GOARCH)
1415
RETINA_BUILD_DIR = $(BUILD_DIR)/retina
1516
RETINA_DIR = $(REPO_ROOT)/controller
16-
KUBECTL_RETINA_BUILD_DIR = $(OUTPUT_DIR)/kubectl-retina
1717
OPERATOR_DIR=$(REPO_ROOT)/operator
1818
CAPTURE_WORKLOAD_DIR = $(REPO_ROOT)/captureworkload
1919

@@ -63,15 +63,16 @@ help: ## Display this help
6363

6464
##@ Tools
6565

66-
TOOLS_DIR = $(REPO_ROOT)/hack/tools
67-
TOOLS_BIN_DIR = $(TOOLS_DIR)/bin
68-
GOFUMPT := $(TOOLS_BIN_DIR)/gofumpt
69-
GOLANGCI_LINT := $(TOOLS_BIN_DIR)/golangci-lint
70-
CONTROLLER_GEN := $(TOOLS_BIN_DIR)/controller-gen
71-
GINKGO := $(TOOLS_BIN_DIR)/ginkgo
72-
MOCKGEN := $(TOOLS_BIN_DIR)/mockgen
73-
ENVTEST := $(TOOLS_BIN_DIR)/setup-envtest
74-
GIT_CURRENT_BRANCH_NAME := $(shell git rev-parse --abbrev-ref HEAD)
66+
TOOLS_DIR = $(REPO_ROOT)/hack/tools
67+
TOOLS_BIN_DIR = $(TOOLS_DIR)/bin
68+
69+
GOFUMPT = $(TOOLS_BIN_DIR)/gofumpt
70+
GOLANGCI_LINT = $(TOOLS_BIN_DIR)/golangci-lint
71+
GORELEASER = $(TOOLS_BIN_DIR)/goreleaser
72+
CONTROLLER_GEN = $(TOOLS_BIN_DIR)/controller-gen
73+
GINKGO = $(TOOLS_BIN_DIR)/ginkgo
74+
MOCKGEN = $(TOOLS_BIN_DIR)/mockgen
75+
ENVTEST = $(TOOLS_BIN_DIR)/setup-envtest
7576

7677
$(TOOLS_DIR)/go.mod:
7778
cd $(TOOLS_DIR); go mod init && go mod tidy
@@ -89,6 +90,11 @@ golangci-lint: $(GOLANGCI_LINT) ## Build golangci-lint
8990
$(CONTROLLER_GEN): $(TOOLS_DIR)/go.mod
9091
cd $(TOOLS_DIR); go mod download; go build -tags=tools -o bin/controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen
9192

93+
goreleaser: $(GORELEASER) ## Build goreleaser
94+
95+
$(GORELEASER): $(TOOLS_DIR)/go.mod
96+
cd $(TOOLS_DIR); go mod download; go build -tags=tools -o bin/goreleaser github.com/goreleaser/goreleaser
97+
9298
controller-gen: $(CONTROLLER_GEN) ## Build controller-gen
9399

94100
$(GINKGO): $(TOOLS_DIR)/go.mod
@@ -140,23 +146,14 @@ clean: ## clean build artifacts
140146

141147
##@ Build Binaries
142148

143-
retina: ## builds both retina and kapctl binaries
144-
$(MAKE) retina-binary kubectl-retina
149+
retina: ## builds retina binary
150+
$(MAKE) retina-binary
145151

146152
retina-binary: ## build the Retina binary
147153
go generate ./...
148154
export CGO_ENABLED=0
149155
go build -v -o $(RETINA_BUILD_DIR)/retina$(EXE_EXT) -gcflags="-dwarflocationlists=true" -ldflags "-X main.version=$(TAG) -X main.applicationInsightsID=$(APP_INSIGHTS_ID)" $(RETINA_DIR)/main.go
150156

151-
kubectl-retina-binary-%: ## build kubectl plugin locally.
152-
export CGO_ENABLED=0 && \
153-
export GOOS=$(shell echo $* |cut -f1 -d-) GOARCH=$(shell echo $* |cut -f2 -d-) && \
154-
go build -v \
155-
-o $(KUBECTL_RETINA_BUILD_DIR)/kubectl-retina-$${GOOS}-$${GOARCH} \
156-
-gcflags="-dwarflocationlists=true" \
157-
-ldflags "-X github.com/microsoft/retina/cli/cmd.Version=$(TAG)" \
158-
github.com/microsoft/retina/cli
159-
160157
retina-capture-workload: ## build the Retina capture workload
161158
cd $(CAPTURE_WORKLOAD_DIR) && CGO_ENABLED=0 go build -v -o $(RETINA_BUILD_DIR)/captureworkload$(EXE_EXT) -gcflags="-dwarflocationlists=true" -ldflags "-X main.version=$(TAG)"
162159

@@ -268,18 +265,6 @@ retina-operator-image: ## build the retina linux operator image.
268265
APP_INSIGHTS_ID=$(APP_INSIGHTS_ID) \
269266
CONTEXT_DIR=$(REPO_ROOT)
270267

271-
kubectl-retina-image: ## build the kubectl-retina image.
272-
echo "Building for $(PLATFORM)"
273-
$(MAKE) container-$(CONTAINER_BUILDER) \
274-
PLATFORM=$(PLATFORM) \
275-
DOCKERFILE=cli/Dockerfile.kubectl-retina \
276-
REGISTRY=$(IMAGE_REGISTRY) \
277-
IMAGE=$(KUBECTL_RETINA_IMAGE) \
278-
VERSION=$(TAG) \
279-
TAG=$(RETINA_PLATFORM_TAG) \
280-
APP_INSIGHTS_ID=$(APP_INSIGHTS_ID) \
281-
CONTEXT_DIR=$(REPO_ROOT)
282-
283268
proto-gen: ## generate protobuf code
284269
docker build --platform=linux/amd64 \
285270
-t $(IMAGE_REGISTRY)/$(RETINA_PROTO_IMAGE):$(RETINA_PLATFORM_TAG) \
@@ -311,18 +296,12 @@ manifest-operator-image: ## create a multiplatform manifest for the operator ima
311296
$(eval FULL_IMAGE_NAME=$(IMAGE_REGISTRY)/$(RETINA_OPERATOR_IMAGE):$(TAG))
312297
docker buildx imagetools create -t $(FULL_IMAGE_NAME) $(foreach platform,linux/amd64, $(FULL_IMAGE_NAME)-$(subst /,-,$(platform)))
313298

314-
manifest-kubectl-retina-image: ## create a multiplatform manifest for the kubectl-retina image
315-
$(eval FULL_IMAGE_NAME=$(IMAGE_REGISTRY)/$(KUBECTL_RETINA_IMAGE):$(TAG))
316-
docker buildx imagetools create -t $(FULL_IMAGE_NAME) $(foreach platform,linux/amd64 linux/arm64, $(FULL_IMAGE_NAME)-$(subst /,-,$(platform)))
317-
318299
manifest:
319300
echo "Building for $(COMPONENT)"
320301
if [ "$(COMPONENT)" = "retina" ]; then \
321302
$(MAKE) manifest-retina-image; \
322303
elif [ "$(COMPONENT)" = "operator" ]; then \
323304
$(MAKE) manifest-operator-image; \
324-
elif [ "$(COMPONENT)" = "kubectl-retina" ]; then \
325-
$(MAKE) manifest-kubectl-retina-image; \
326305
fi
327306

328307
##@ Tests

README.md

+12-11
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ Prerequisites: Go, Helm
4141

4242
1. Clone the repo, then install Retina on your Kubernetes cluster
4343

44-
```bash
45-
make helm-install
46-
```
44+
```bash
45+
make helm-install
46+
```
4747

4848
2. Follow steps in [Using Prometheus and Grafana](https://retina.sh/docs/installation/prometheus-unmanaged) to set up metrics collection and visualization.
4949

@@ -55,22 +55,23 @@ Currently, Retina CLI only supports Linux.
5555

5656
- Option 1: Download from Release
5757

58-
Download `kubectl-retina` from the latest [Retina release](https://github.com/microsoft/retina/releases).
58+
Download the correct `kubectl-retina` package for your platform from the latest [Retina release](https://github.com/microsoft/retina/releases).
5959
Feel free to move the binary to `/usr/local/bin/`, or add it to your `PATH` otherwise.
6060

6161
- Option 2: Build from source
6262

6363
Requirements:
6464

6565
- go 1.21 or newer
66-
- GNU make
6766

6867
Clone the Retina repo and execute:
6968

7069
```shell
71-
make install-kubectl-retina
70+
go build -o bin/kubectl-retina cli/main.go
7271
```
7372

73+
and move bin/kubectl-retina in to your $PATH.
74+
7475
Execute Retina:
7576

7677
```shell
@@ -85,15 +86,15 @@ Prerequisites: Go, Helm
8586

8687
1. Clone the repo, then install Retina with Capture operator support on your Kubernetes cluster
8788

88-
```bash
89-
make helm-install-with-operator
90-
```
89+
```bash
90+
make helm-install-with-operator
91+
```
9192

9293
2. Follow steps in [Capture CRD](https://retina.sh/docs/captures/#option-2-capture-crd-custom-resource-definition) for documentation of the CRD and examples for setting up Captures.
9394

9495
## Contributing
9596

96-
This project welcomes contributions and suggestions. Most contributions require you to agree to a
97+
This project welcomes contributions and suggestions. Most contributions require you to agree to a
9798
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
9899
the rights to use your contribution. For details, visit <https://cla.opensource.microsoft.com>.
99100

@@ -130,7 +131,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope
130131

131132
For bugs or feature requests, open an [issue](https://github.com/microsoft/retina/issues).
132133
For security or vulnerability concerns, see [SECURITY.md](SECURITY.md).
133-
For other communication, contact the maintainers at <[email protected]>
134+
For other communication, contact the maintainers at <[email protected]>
134135

135136
[goreport-img]: https://goreportcard.com/badge/github.com/microsoft/retina
136137
[goreport]: https://goreportcard.com/report/github.com/microsoft/retina

docs/installation/cli.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# CLI Setup
22

3-
Currently, Retina CLI only supports Linux.
3+
Currently, Retina CLI supports Linux, Windows, and MacOS on x86_64 and ARM64 platforms.
44

55
For CLI usage, see [Capture with Retina CLI](../captures/cli.md).
66

@@ -11,13 +11,16 @@ Feel free to move the binary to `/usr/local/bin/`, or add it to your `PATH` othe
1111

1212
## Option 2: Build from source
1313

14-
Clone the Retina repo and execute:
14+
Building the CLI requires go1.21 or greater.
1515

16-
```shell
17-
make install-kubectl-retina
16+
To build the CLI simply with Go:
17+
18+
```bash
19+
go build -o bin/kubectl-retina cli/main.go
1820
```
1921

20-
Requirements:
22+
To cross-compile for all supported platforms, use [GoReleaser](https://goreleaser.com/):
2123

22-
- go 1.21 or newer
23-
- GNU make
24+
```bash
25+
goreleaser build --snapshot --clean
26+
```

0 commit comments

Comments
 (0)