Skip to content
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
39 changes: 32 additions & 7 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
# Ignore everything by default and re-include only needed files
**
# Compatible with both Docker and Podman
# Use explicit exclusions (not negation patterns) for better compatibility

# Re-include Go source files (but not *_test.go)
!**/*.go
# Build artifacts and unnecessary files
bin/
dist/
.git/
.github/
docs/
examples/
hack/
test/
*.md
*.tape
*.gif
*.mp4
*.svg
*.png

# Test files
**/*_test.go

# Re-include Go module files
!go.mod
!go.sum
# Cache directories
.cache/

# IDE and editor files
.vscode/
.idea/
*.swp
*.swo
*~

# OS files
.DS_Store
Thumbs.db
3 changes: 2 additions & 1 deletion CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ generated: config/rbac/*.yaml (multiple files via kubebuilder)
### Build and Deploy

* `make build` - builds controller binary
* `make docker-build` - builds container image
* `make docker-build` - builds container image with Docker
* `make podman-build` - builds container image with Podman
* `make deploy` - deploys to current kubectl context
* `make undeploy` - removes deployment

Expand Down
41 changes: 35 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ CONTROLLER_GEN_PKG := sigs.k8s.io/controller-tools/cmd/controller-gen
IMG_PREFIX ?= controller
IMG_TAG ?= latest

# ENABLE_METRICS: If set to true, includes Prometheus Service resources.
# Kind cluster name for loading images
KIND_CLUSTER ?= nrr-test

# ENABLE_METRICS: If set to true, includes Prometheus Service and ServiceMonitor resources.
ENABLE_METRICS ?= false
# ENABLE_TLS: If set to true (and ENABLE_METRICS is true), configures metrics to use HTTPS with CertManager.
ENABLE_TLS ?= false
# ENABLE_WEBHOOK: If set to true, includes validating webhook. Requires ENABLE_TLS=true.
ENABLE_WEBHOOK ?= false
Expand Down Expand Up @@ -173,11 +177,16 @@ run: manifests generate fmt vet ## Run a controller from your host.
go run ./cmd/main.go

# If you wish to build the manager image targeting other platforms you can use the --platform flag.
# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it.
# (i.e. docker build --platform linux/arm64 or podman build --platform linux/arm64).
# However, you must enable docker buildKit for it.
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
.PHONY: docker-build
docker-build: ## Build docker image with the manager.
DOCKER_BUILDKIT=1 $(CONTAINER_TOOL) build -t ${IMG_PREFIX}:${IMG_TAG} .
docker-build: ## Build container image with Docker.
DOCKER_BUILDKIT=1 docker build -t ${IMG_PREFIX}:${IMG_TAG} .

.PHONY: podman-build
podman-build: ## Build container image with Podman.
podman build -t localhost/${IMG_PREFIX}:${IMG_TAG} .

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
Expand All @@ -197,9 +206,29 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG_PREFIX}:${IMG_TAG} .
- $(CONTAINER_TOOL) buildx rm nrrcontroller-builder

.PHONY: kind-load
kind-load: ## Load the built image into kind cluster
ifeq ($(CONTAINER_TOOL),podman)
@echo "Loading Podman image into kind cluster: $(KIND_CLUSTER)"
@echo "Saving image to temporary tar archive..."
@$(CONTAINER_TOOL) save -o /tmp/controller-image.tar localhost/$(IMG_PREFIX):$(IMG_TAG)
@echo "Loading tar archive into kind cluster..."
@kind load image-archive /tmp/controller-image.tar --name $(KIND_CLUSTER)
@echo "Cleaning up temporary tar archive..."
@rm /tmp/controller-image.tar
@echo "Image loaded successfully!"
else
@echo "Loading Docker image into kind cluster: $(KIND_CLUSTER)"
@kind load docker-image $(IMG_PREFIX):$(IMG_TAG) --name $(KIND_CLUSTER)
endif

.PHONY: docker-build-reporter
docker-build-reporter: ## Build docker image with the reporter.
DOCKER_BUILDKIT=1 $(CONTAINER_TOOL) build -f Dockerfile.reporter -t ${IMG_PREFIX}:${IMG_TAG} .
docker-build-reporter: ## Build reporter container image with Docker.
DOCKER_BUILDKIT=1 docker build -f Dockerfile.reporter -t ${IMG_PREFIX}:${IMG_TAG} .

.PHONY: podman-build-reporter
podman-build-reporter: ## Build reporter container image with Podman.
podman build -f Dockerfile.reporter -t ${IMG_PREFIX}:${IMG_TAG} .

.PHONY: docker-push-reporter
docker-push-reporter: ## Push docker image with the reporter.
Expand Down
35 changes: 29 additions & 6 deletions docs/TEST_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The test uses a 3-node Kind cluster:

### Prerequisites

- [Docker](https://docs.docker.com/get-docker/)
- [Docker](https://docs.docker.com/get-docker/) or [Podman](https://podman.io/getting-started/installation)
- [Kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation)
- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
- [Go](https://golang.org/doc/install)
Expand All @@ -38,21 +38,44 @@ make install

Build the controller image and load it into the Kind cluster nodes.

**Using Docker:**
```bash
# Build the image
make docker-build IMG_PREFIX=controller IMG_TAG=latest
# Build the image (uses defaults: IMG_PREFIX=controller IMG_TAG=latest)
make docker-build

# Load the image into the kind cluster
kind load docker-image controller:latest --name nrr-test
# Load the image into the kind cluster (uses default: KIND_CLUSTER=nrr-test)
make kind-load

# Verify the image is loaded
docker exec -it nrr-test-control-plane crictl images | grep controller
```

**Using Podman:**
```bash
# Build the image (uses defaults: IMG_PREFIX=controller IMG_TAG=latest)
make podman-build

# Load the image into the kind cluster (uses default: KIND_CLUSTER=nrr-test)
make kind-load CONTAINER_TOOL=podman

# Verify the image is loaded
podman exec -it nrr-test-control-plane crictl images | grep controller
```

### Step 3: Controller Deployment

Deploy the controller image to nrr-test-worker
Deploy the controller to the cluster.

**Using Docker:**
```bash
make deploy IMG_PREFIX=controller IMG_TAG=latest
```

**Using Podman:**
```bash
make deploy IMG_PREFIX=localhost/controller IMG_TAG=latest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL, that podman forces the localhost prefix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Thats correct.

```

Verify the controller is running on the control plane node (`nrr-test-control-plane`):
```bash
kubectl get pods -n nrr-system -o wide
Expand Down
Loading