diff --git a/Makefile b/Makefile index 0c62080..fa5c150 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 @@ -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 diff --git a/agent/deploy/clusterrole-binding.yaml b/agent/config/base/clusterrole-binding.yaml similarity index 90% rename from agent/deploy/clusterrole-binding.yaml rename to agent/config/base/clusterrole-binding.yaml index 3954691..f8d48ec 100644 --- a/agent/deploy/clusterrole-binding.yaml +++ b/agent/config/base/clusterrole-binding.yaml @@ -5,7 +5,7 @@ metadata: subjects: - kind: ServiceAccount name: manta-agent - namespace: manta-system + namespace: system roleRef: kind: ClusterRole name: manta-agent-role diff --git a/agent/deploy/clusterrole.yaml b/agent/config/base/clusterrole.yaml similarity index 100% rename from agent/deploy/clusterrole.yaml rename to agent/config/base/clusterrole.yaml diff --git a/agent/deploy/serviceaccount.yaml b/agent/config/base/serviceaccount.yaml similarity index 71% rename from agent/deploy/serviceaccount.yaml rename to agent/config/base/serviceaccount.yaml index 0f4d589..ac263cf 100644 --- a/agent/deploy/serviceaccount.yaml +++ b/agent/config/base/serviceaccount.yaml @@ -2,4 +2,4 @@ apiVersion: v1 kind: ServiceAccount metadata: name: manta-agent - namespace: manta-system + namespace: system diff --git a/agent/config/kustomization.yaml b/agent/config/kustomization.yaml new file mode 100644 index 0000000..3f2107d --- /dev/null +++ b/agent/config/kustomization.yaml @@ -0,0 +1,8 @@ +# Adds namespace to all resources. +namespace: manta-system + +resources: +- ./manager +- ./base/serviceaccount.yaml +- ./base/clusterrole.yaml +- ./base/clusterrole-binding.yaml diff --git a/agent/deploy/daemonset.yaml b/agent/config/manager/daemonset.yaml similarity index 95% rename from agent/deploy/daemonset.yaml rename to agent/config/manager/daemonset.yaml index 99715f3..d1c34ec 100644 --- a/agent/deploy/daemonset.yaml +++ b/agent/config/manager/daemonset.yaml @@ -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: diff --git a/agent/config/manager/kustomization.yaml b/agent/config/manager/kustomization.yaml new file mode 100644 index 0000000..10f93fc --- /dev/null +++ b/agent/config/manager/kustomization.yaml @@ -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 diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index c257655..931ffb9 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -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 diff --git a/hack/e2e-test.sh b/hack/e2e-test.sh index 0edb596..054654c 100755 --- a/hack/e2e-test.sh +++ b/hack/e2e-test.sh @@ -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 diff --git a/hack/merge-yaml.sh b/hack/merge-yaml.sh deleted file mode 100755 index 4c89150..0000000 --- a/hack/merge-yaml.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2024 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -o errexit -set -o nounset -set -o pipefail - -output_file="artifacts/manifests.yaml" - -for file in agent/deploy/*.yaml; do - echo "---" >> "$output_file" - cat "$file" >> "$output_file" -done diff --git a/test/e2e/suit_test.go b/test/e2e/suit_test.go index 1531eb0..00ff7b8 100644 --- a/test/e2e/suit_test.go +++ b/test/e2e/suit_test.go @@ -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 {