Skip to content
Draft
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
37 changes: 34 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

# Image URL to use all building/pushing image targets
IMG ?= localhost/ofcir:latest
IMG ?= localhost/ofcir-test:latest
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.23
# KUSTOMIZE_BUILD_DIR defines the root folder to be used for manifests generation
KUSTOMIZE_BUILD_DIR ?= config/default
CONTAINER_NAME=e2e-test
LOG_FILE=e2e-test.log


# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
Expand Down Expand Up @@ -81,13 +83,36 @@ unit-tests: fmt vet
e2e-tests:
go test ./tests/e2e/...

e2e-tests-container: delete-cluster cleantmp create-cluster ofcir-image export-ofcir-image load-ofcir-image

docker run --name e2e-test --rm \
--network host \
-v $(PWD):/app \
-v $(HOME)/.kube:/root/.kube \
-e KUBECONFIG=/root/.kube/config \
-e KUBERNETES_SERVICE_HOST=127.0.0.1 \
-e KUBERNETES_SERVICE_PORT=6443 \
-w /app golang:1.23 bash -c "apt-get update && apt-get install -y make git docker.io libvirt-dev pkg-config curl && curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.23.0/bin/linux/amd64/kubectl && chmod +x kubectl && mv kubectl /usr/local/bin/ && go install sigs.k8s.io/controller-tools/cmd/controller-ge@$(CONTROLLER_TOOLS_VERSION) && go mod tidy && make e2e-tests"

cleantmp:
rm -rf /tmp/ofcir-latest.tar

export-ofcir-image:
podman save -o /tmp/ofcir-latest.tar localhost/ofcir-test:latest

copy-e2e-logs:
podman cp $(CONTAINER_NAME):/app/$(LOG_FILE) ./$(LOG_FILE)

load-ofcir-image:
/usr/local/bin/kind load image-archive --name ofcir-test /tmp/ofcir-latest.tar

.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
go run ./main.go

.PHONY: ofcir-image
ofcir-image:
podman build -t ${IMG} -f Dockerfile .
docker build -t ${IMG} -f Dockerfile .

##@ Deployment

Expand Down Expand Up @@ -162,4 +187,10 @@ $(ENVTEST): $(LOCALBIN)
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

.PHONY: runapi
runapi: manifests generate fmt vet ## Run a controller from your host.
runapi: manifests generate fmt vet ## Run a controller from your host.

create-cluster:
/usr/local/bin/kind create cluster --name ofcir-test --image kindest/node:v1.30.0 --config tests/e2e/kind-config.yaml

delete-cluster:
/usr/local/bin/kind delete cluster --name ofcir-test
19 changes: 12 additions & 7 deletions config/crd/bases/ofcir.openshift_cipools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.12.0
controller-gen.kubebuilder.io/version: v0.17.0
name: cipools.ofcir.openshift
spec:
group: ofcir.openshift
Expand Down Expand Up @@ -47,14 +47,19 @@ spec:
description: CIPool is the Schema for the cipools API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
Expand Down
29 changes: 18 additions & 11 deletions config/crd/bases/ofcir.openshift_ciresources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.12.0
controller-gen.kubebuilder.io/version: v0.17.0
name: ciresources.ofcir.openshift
spec:
group: ofcir.openshift
Expand Down Expand Up @@ -48,14 +48,19 @@ spec:
instances) from a specific pool
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
Expand All @@ -70,8 +75,9 @@ spec:
CIResource
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
type: object
x-kubernetes-map-type: atomic
Expand All @@ -94,8 +100,9 @@ spec:
description: Public IPv4 address
type: string
extra:
description: This field may contain extra data that may vary depending
on the specific resource type used
description: |-
This field may contain extra data that may vary depending on the
specific resource type used
type: string
lastUpdated:
description: LastUpdated identifies when this status was last observed.
Expand Down
28 changes: 2 additions & 26 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,6 @@ rules:
- ofcir.openshift
resources:
- cipools
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
- update
- watch
- apiGroups:
- ofcir.openshift
resources:
- cipools/finalizers
verbs:
- update
- apiGroups:
- ofcir.openshift
resources:
- cipools/status
verbs:
- get
- patch
- update
- apiGroups:
- ofcir.openshift
resources:
- ciresources
verbs:
- create
Expand All @@ -60,12 +34,14 @@ rules:
- apiGroups:
- ofcir.openshift
resources:
- cipools/finalizers
- ciresources/finalizers
verbs:
- update
- apiGroups:
- ofcir.openshift
resources:
- cipools/status
- ciresources/status
verbs:
- get
Expand Down
1 change: 0 additions & 1 deletion pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func (o *OfcirAPI) Init(kubeconfig string) error {
var err error
var config *rest.Config

// Use this option when running outside the cluster
if kubeconfig != "" {
config, err = clientcmd.BuildConfigFromFlags("", kubeconfig)
} else {
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ func TestMain(m *testing.M) {
testenv = env.New()

testenv.Setup(
createKindCluster(kindClusterName),
buildAndLoadOfcirImage,
// createKindCluster(kindClusterName),
// buildAndLoadOfcirImage,
deployOfcirOperator,
)

Expand Down