Skip to content

Commit c206921

Browse files
authored
✨ Add Podman support (#157)
1 parent 33216e3 commit c206921

File tree

4 files changed

+98
-20
lines changed

4 files changed

+98
-20
lines changed

.dockerignore

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,36 @@
11
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
2-
# Ignore everything by default and re-include only needed files
3-
**
2+
# Compatible with both Docker and Podman
3+
# Use explicit exclusions (not negation patterns) for better compatibility
44

5-
# Re-include Go source files (but not *_test.go)
6-
!**/*.go
5+
# Build artifacts and unnecessary files
6+
bin/
7+
dist/
8+
.git/
9+
.github/
10+
docs/
11+
examples/
12+
hack/
13+
test/
14+
*.md
15+
*.tape
16+
*.gif
17+
*.mp4
18+
*.svg
19+
*.png
20+
21+
# Test files
722
**/*_test.go
823

9-
# Re-include Go module files
10-
!go.mod
11-
!go.sum
24+
# Cache directories
25+
.cache/
26+
27+
# IDE and editor files
28+
.vscode/
29+
.idea/
30+
*.swp
31+
*.swo
32+
*~
33+
34+
# OS files
35+
.DS_Store
36+
Thumbs.db

CONTEXT.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ generated: config/rbac/*.yaml (multiple files via kubebuilder)
9696
### Build and Deploy
9797

9898
* `make build` - builds controller binary
99-
* `make docker-build` - builds container image
99+
* `make docker-build` - builds container image with Docker
100+
* `make podman-build` - builds container image with Podman
100101
* `make deploy` - deploys to current kubectl context
101102
* `make undeploy` - removes deployment
102103

Makefile

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,12 @@ CONTROLLER_GEN_PKG := sigs.k8s.io/controller-tools/cmd/controller-gen
6262
IMG_PREFIX ?= controller
6363
IMG_TAG ?= latest
6464

65-
# ENABLE_METRICS: If set to true, includes Prometheus Service resources.
65+
# Kind cluster name for loading images
66+
KIND_CLUSTER ?= nrr-test
67+
68+
# ENABLE_METRICS: If set to true, includes Prometheus Service and ServiceMonitor resources.
6669
ENABLE_METRICS ?= false
70+
# ENABLE_TLS: If set to true (and ENABLE_METRICS is true), configures metrics to use HTTPS with CertManager.
6771
ENABLE_TLS ?= false
6872
# ENABLE_WEBHOOK: If set to true, includes validating webhook. Requires ENABLE_TLS=true.
6973
ENABLE_WEBHOOK ?= false
@@ -173,11 +177,16 @@ run: manifests generate fmt vet ## Run a controller from your host.
173177
go run ./cmd/main.go
174178

175179
# If you wish to build the manager image targeting other platforms you can use the --platform flag.
176-
# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it.
180+
# (i.e. docker build --platform linux/arm64 or podman build --platform linux/arm64).
181+
# However, you must enable docker buildKit for it.
177182
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
178183
.PHONY: docker-build
179-
docker-build: ## Build docker image with the manager.
180-
DOCKER_BUILDKIT=1 $(CONTAINER_TOOL) build -t ${IMG_PREFIX}:${IMG_TAG} .
184+
docker-build: ## Build container image with Docker.
185+
DOCKER_BUILDKIT=1 docker build -t ${IMG_PREFIX}:${IMG_TAG} .
186+
187+
.PHONY: podman-build
188+
podman-build: ## Build container image with Podman.
189+
podman build -t localhost/${IMG_PREFIX}:${IMG_TAG} .
181190

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

209+
.PHONY: kind-load
210+
kind-load: ## Load the built image into kind cluster
211+
ifeq ($(CONTAINER_TOOL),podman)
212+
@echo "Loading Podman image into kind cluster: $(KIND_CLUSTER)"
213+
@echo "Saving image to temporary tar archive..."
214+
@$(CONTAINER_TOOL) save -o /tmp/controller-image.tar localhost/$(IMG_PREFIX):$(IMG_TAG)
215+
@echo "Loading tar archive into kind cluster..."
216+
@kind load image-archive /tmp/controller-image.tar --name $(KIND_CLUSTER)
217+
@echo "Cleaning up temporary tar archive..."
218+
@rm /tmp/controller-image.tar
219+
@echo "Image loaded successfully!"
220+
else
221+
@echo "Loading Docker image into kind cluster: $(KIND_CLUSTER)"
222+
@kind load docker-image $(IMG_PREFIX):$(IMG_TAG) --name $(KIND_CLUSTER)
223+
endif
224+
200225
.PHONY: docker-build-reporter
201-
docker-build-reporter: ## Build docker image with the reporter.
202-
DOCKER_BUILDKIT=1 $(CONTAINER_TOOL) build -f Dockerfile.reporter -t ${IMG_PREFIX}:${IMG_TAG} .
226+
docker-build-reporter: ## Build reporter container image with Docker.
227+
DOCKER_BUILDKIT=1 docker build -f Dockerfile.reporter -t ${IMG_PREFIX}:${IMG_TAG} .
228+
229+
.PHONY: podman-build-reporter
230+
podman-build-reporter: ## Build reporter container image with Podman.
231+
podman build -f Dockerfile.reporter -t ${IMG_PREFIX}:${IMG_TAG} .
203232

204233
.PHONY: docker-push-reporter
205234
docker-push-reporter: ## Push docker image with the reporter.

docs/TEST_README.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The test uses a 3-node Kind cluster:
1515

1616
### Prerequisites
1717

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

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

41+
**Using Docker:**
4142
```bash
42-
# Build the image
43-
make docker-build IMG_PREFIX=controller IMG_TAG=latest
43+
# Build the image (uses defaults: IMG_PREFIX=controller IMG_TAG=latest)
44+
make docker-build
4445

45-
# Load the image into the kind cluster
46-
kind load docker-image controller:latest --name nrr-test
46+
# Load the image into the kind cluster (uses default: KIND_CLUSTER=nrr-test)
47+
make kind-load
48+
49+
# Verify the image is loaded
50+
docker exec -it nrr-test-control-plane crictl images | grep controller
51+
```
52+
53+
**Using Podman:**
54+
```bash
55+
# Build the image (uses defaults: IMG_PREFIX=controller IMG_TAG=latest)
56+
make podman-build
57+
58+
# Load the image into the kind cluster (uses default: KIND_CLUSTER=nrr-test)
59+
make kind-load CONTAINER_TOOL=podman
60+
61+
# Verify the image is loaded
62+
podman exec -it nrr-test-control-plane crictl images | grep controller
4763
```
4864

4965
### Step 3: Controller Deployment
5066

51-
Deploy the controller image to nrr-test-worker
67+
Deploy the controller to the cluster.
68+
69+
**Using Docker:**
5270
```bash
5371
make deploy IMG_PREFIX=controller IMG_TAG=latest
5472
```
5573

74+
**Using Podman:**
75+
```bash
76+
make deploy IMG_PREFIX=localhost/controller IMG_TAG=latest
77+
```
78+
5679
Verify the controller is running on the control plane node (`nrr-test-control-plane`):
5780
```bash
5881
kubectl get pods -n nrr-system -o wide

0 commit comments

Comments
 (0)