diff --git a/.github/workflows/build-container.yml b/.github/workflows/build-container.yml new file mode 100644 index 0000000..8aa8832 --- /dev/null +++ b/.github/workflows/build-container.yml @@ -0,0 +1,52 @@ +name: Release ingress-netperf container image + +on: + push: + paths: + - "containers/**" # Trigger only when Dockerfile changes in a pull request + +env: + CONTAINER_REGISTRY: ${{ 'quay.io' }} + GO_VER: 1.19 + +jobs: + build-and-publish-container-images: + name: Build and Publish Multi Architecture Container Images + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - name: Setup QEMU & Install Dependecies + run: | + sudo apt-get update -y + sudo apt-get install qemu-user-static fuse-overlayfs -y + sudo apt-get install podman -y + if: runner.os == 'Linux' + + - name: Clone Repository + uses: actions/checkout@v3 + + - name: Setup Golang + uses: actions/setup-go@v3 + with: + go-version: ${{ env.GO_VER }} + + - name: Verify Go Version + run: go version + + - name: Login to the ${{ env.CONTAINER_REGISTRY }} Container Registry + run: podman login quay.io -u ${QUAY_USER} -p ${QUAY_TOKEN} + env: + QUAY_USER: ${{ secrets.QUAY_USER }} + QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }} + + - name: Build and Push Multi archiecture Image + id: push + run: | + make gha-build + make gha-push + env: + GO_VER: ${{ env.GO_VER }} diff --git a/Makefile b/Makefile index 7fcd19a..3e07b26 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +CONTAINER_BUILD ?= podman build --force-rm +CONTAINER_NS ?= quay.io/cloud-bulldozer GIT_COMMIT = $(shell git rev-parse HEAD) BRANCH := $(shell git rev-parse --abbrev-ref HEAD) @@ -18,16 +20,30 @@ CGO = 0 .PHONY: build lint clean -all: lint build +all: lint build container-build build: $(BIN_PATH) $(BIN_PATH): $(SOURCES) GOARCH=$(shell go env GOARCH) CGO_ENABLED=$(CGO) go build -v -ldflags "-X $(INGRESS_PERF_VERSION).GitCommit=$(GIT_COMMIT) -X $(INGRESS_PERF_VERSION).Version=$(VERSION) -X $(INGRESS_PERF_VERSION).BuildDate=$(BUILD_DATE)" -o $(BIN_PATH) cmd/ingress-perf.go +container-build: build + @echo "Building the container image" + $(CONTAINER_BUILD) -f containers/Containerfile \ + -t $(CONTAINER_NS)/$(BIN_NAME) ./containers + +gha-build: build + @echo "Building Multi-architecture container Images" + $(CONTAINER_BUILD) -f containers/Containerfile \ + --platform=linux/amd64,linux/arm64,linux/ppc64le,linux/s390x \ + -t $(CONTAINER_NS)/$(BIN_NAME) ./containers --manifest=$(CONTAINER_NS)/$(BIN_NAME):latest + +gha-push: gha-build + @echo "Pushing Container Images" + $(CONTAINER_BUILD) manifest push + clean: rm -Rf $(BIN_DIR) lint: golangci-lint run - diff --git a/cmd/ingress-perf.go b/cmd/ingress-perf.go index 6633d1d..e05967a 100644 --- a/cmd/ingress-perf.go +++ b/cmd/ingress-perf.go @@ -64,7 +64,7 @@ func run() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { var indexer *indexers.Indexer var err error - log.Infof("Running ingress performance %s", uuid) + log.Infof("Running ingress-perf (%s@%s) with uuid %s", version.Version, version.GitCommit, uuid) if err := config.Load(cfg); err != nil { return err } diff --git a/assets/Containerfile b/containers/Containerfile similarity index 100% rename from assets/Containerfile rename to containers/Containerfile diff --git a/assets/json.lua b/containers/json.lua similarity index 100% rename from assets/json.lua rename to containers/json.lua diff --git a/pkg/runner/runner.go b/pkg/runner/runner.go index 347ba27..62cc699 100644 --- a/pkg/runner/runner.go +++ b/pkg/runner/runner.go @@ -55,7 +55,6 @@ func Start(uuid, baseUUID, baseIndex string, tolerancy int, indexer *indexers.In var comparator comparison.Comparator var clusterMetadata tools.ClusterMetadata passed := true - log.Info("Starting ingress-perf") if os.Getenv("KUBECONFIG") != "" { kubeconfig = os.Getenv("KUBECONFIG") } else if _, err := os.Stat(filepath.Join(os.Getenv("HOME"), ".kube", "config")); kubeconfig == "" && !os.IsNotExist(err) { diff --git a/pkg/runner/types.go b/pkg/runner/types.go index 1fa5068..aaa408e 100644 --- a/pkg/runner/types.go +++ b/pkg/runner/types.go @@ -21,7 +21,6 @@ import ( appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" rbac "k8s.io/api/rbac/v1" - "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/utils/pointer" @@ -58,13 +57,6 @@ var workerAffinity = &corev1.Affinity{ }, } -var clientServerRequests = corev1.ResourceRequirements{ - Requests: corev1.ResourceList{ - "cpu": resource.MustParse("100m"), - "memory": resource.MustParse("250Mi"), - }, -} - var server = appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ Name: serverName, @@ -82,6 +74,14 @@ var server = appsv1.Deployment{ Labels: map[string]string{"app": serverName}, }, Spec: corev1.PodSpec{ + TopologySpreadConstraints: []corev1.TopologySpreadConstraint{{ + MaxSkew: 1, + TopologyKey: "kubernetes.io/hostname", + WhenUnsatisfiable: corev1.DoNotSchedule, + LabelSelector: &metav1.LabelSelector{ + MatchLabels: map[string]string{"app": serverName}, + }, + }}, Affinity: workerAffinity, TerminationGracePeriodSeconds: pointer.Int64(0), // It helps to kill the pod inmediatly on GC Containers: []corev1.Container{ @@ -95,8 +95,7 @@ var server = appsv1.Deployment{ RunAsNonRoot: pointer.Bool(true), SeccompProfile: &corev1.SeccompProfile{Type: corev1.SeccompProfileTypeRuntimeDefault}, }, - Resources: clientServerRequests, - Ports: []corev1.ContainerPort{{Name: "http", Protocol: corev1.ProtocolTCP, ContainerPort: 8080}}, + Ports: []corev1.ContainerPort{{Name: "http", Protocol: corev1.ProtocolTCP, ContainerPort: 8080}}, }, }, }, @@ -135,6 +134,14 @@ var client = appsv1.Deployment{ Labels: map[string]string{"app": clientName}, }, Spec: corev1.PodSpec{ + TopologySpreadConstraints: []corev1.TopologySpreadConstraint{{ + MaxSkew: 1, + TopologyKey: "kubernetes.io/hostname", + WhenUnsatisfiable: corev1.DoNotSchedule, + LabelSelector: &metav1.LabelSelector{ + MatchLabels: map[string]string{"app": clientName}, + }, + }}, Affinity: workerAffinity, TerminationGracePeriodSeconds: pointer.Int64(0), HostNetwork: true, // Enable hostNetwork in client pods @@ -150,7 +157,6 @@ var client = appsv1.Deployment{ RunAsNonRoot: pointer.Bool(true), SeccompProfile: &corev1.SeccompProfile{Type: corev1.SeccompProfileTypeRuntimeDefault}, }, - Resources: clientServerRequests, }, }, },