Skip to content

Commit

Permalink
Merge pull request #27 from kerthcet/cleanup/test-framework
Browse files Browse the repository at this point in the history
Use kustomize to build agent image
  • Loading branch information
InftyAI-Agent authored Nov 15, 2024
2 parents 7f05ed5 + c8581d5 commit d924085
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 38 deletions.
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ test-integration: manifests fmt vet envtest ginkgo ## Run integration tests.
$(GINKGO) --junit-report=junit.xml --output-dir=$(ARTIFACTS) -v $(INTEGRATION_TARGET)

.PHONY: test-e2e
test-e2e: kustomize manifests fmt vet envtest ginkgo kind-image-build
E2E_KIND_VERSION=$(E2E_KIND_VERSION) KIND_CLUSTER_NAME=$(KIND_CLUSTER_NAME) KIND=$(KIND) KUBECTL=$(KUBECTL) KUSTOMIZE=$(KUSTOMIZE) GINKGO=$(GINKGO) USE_EXISTING_CLUSTER=$(USE_EXISTING_CLUSTER) IMAGE_TAG=$(IMG) ./hack/e2e-test.sh
test-e2e: kustomize manifests fmt vet envtest ginkgo kind-image-build kind-agent-image-build
E2E_KIND_VERSION=$(E2E_KIND_VERSION) KIND_CLUSTER_NAME=$(KIND_CLUSTER_NAME) KIND=$(KIND) KUBECTL=$(KUBECTL) KUSTOMIZE=$(KUSTOMIZE) GINKGO=$(GINKGO) USE_EXISTING_CLUSTER=$(USE_EXISTING_CLUSTER) IMAGE_TAG=$(IMG) AGENT_IMAGE_TAG=$(AGENT_IMG) ./hack/e2e-test.sh

GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint
GOLANGCI_LINT_VERSION ?= v1.58.2
Expand Down Expand Up @@ -200,6 +200,11 @@ kind-image-build: PLATFORMS=linux/amd64
kind-image-build: IMAGE_BUILD_EXTRA_OPTS=--load
kind-image-build: kind image-build

.PHONY: kind-agent-image-build
kind-agent-image-build: PLATFORMS=linux/amd64
kind-agent-image-build: IMAGE_BUILD_EXTRA_OPTS=--load
kind-agent-image-build: kind agent-image-build

##@ Deployment

ifndef ignore-not-found
Expand Down Expand Up @@ -275,10 +280,12 @@ artifacts: kustomize
if [ -d artifacts ]; then rm -rf artifacts; fi
mkdir -p artifacts
$(KUSTOMIZE) build config/default -o artifacts/manifests.yaml
@$(call clean-manifests)

# Merge all the yamls, inclduing the agent.
./hack/merge-yaml.sh
echo "---" >> artifacts/manifests.yaml

cd agent/config/manager && $(KUSTOMIZE) edit set image controller=${AGENT_IMG}
$(KUSTOMIZE) build agent/config >> artifacts/manifests.yaml
@$(call clean-manifests)

HELMIFY ?= $(LOCALBIN)/helmify

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
subjects:
- kind: ServiceAccount
name: manta-agent
namespace: manta-system
namespace: system
roleRef:
kind: ClusterRole
name: manta-agent-role
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: manta-agent
namespace: manta-system
namespace: system
8 changes: 8 additions & 0 deletions agent/config/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Adds namespace to all resources.
namespace: manta-system

resources:
- ./manager
- ./base/serviceaccount.yaml
- ./base/clusterrole.yaml
- ./base/clusterrole-binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ spec:
mountPath: /workspace/models
containers:
- name: agent
image: inftyai/manta-agent:v0.0.2
image: controller:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 9090
resources:
Expand Down
8 changes: 8 additions & 0 deletions agent/config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resources:
- daemonset.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: inftyai/manta-agent
newTag: v0.0.2
4 changes: 2 additions & 2 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: inftyai/test
newTag: manta-111113
newName: inftyai/manta
newTag: v0.0.2
7 changes: 7 additions & 0 deletions hack/e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,17 @@ function startup {
}
function kind_load {
$KIND load docker-image $IMAGE_TAG --name $KIND_CLUSTER_NAME
$KIND load docker-image $AGENT_IMAGE_TAG --name $KIND_CLUSTER_NAME
}
function deploy {
# controller
cd $CWD/config/manager && $KUSTOMIZE edit set image controller=$IMAGE_TAG
$KUSTOMIZE build $CWD/test/e2e/config | $KUBECTL apply --server-side -f -

# agent
cd $CWD/agent/config/manager && $KUSTOMIZE edit set image controller=$AGENT_IMAGE_TAG
$KUSTOMIZE build $CWD/agent/config | $KUBECTL apply --server-side -f -

}
trap cleanup EXIT
startup
Expand Down
26 changes: 0 additions & 26 deletions hack/merge-yaml.sh

This file was deleted.

2 changes: 0 additions & 2 deletions test/e2e/suit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ func readyForTesting(client client.Client) {
}).ShouldNot(Succeed())

By("waiting for nodeTrackers to ready")
// Hardcoded the namespace here because we just can't change the namespace dynamically.
Expect(util.Apply(ctx, k8sClient, "../../agent/deploy", "manta-system", "create")).To(Succeed())
Eventually(func() error {
nodeTrackers := &api.NodeTrackerList{}
if err := client.List(ctx, nodeTrackers); err != nil {
Expand Down

0 comments on commit d924085

Please sign in to comment.