1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

Adding multi arch support in all kyverno components (AMD6 and ARM64) (#1542)

* Adding multi arch support

Signed-off-by: Raj Das <mail.rajdas@gmail.com>

* Adding multi arch support

Signed-off-by: Raj Das <mail.rajdas@gmail.com>

* minor refactors

Signed-off-by: Raj Das <mail.rajdas@gmail.com>

* adding buildx action in e2e.yaml

Signed-off-by: Raj Das <mail.rajdas@gmail.com>

* Adding kyvernopre

Signed-off-by: Raj Das <mail.rajdas@gmail.com>

* Adding kyvernopre

Signed-off-by: Raj Das <mail.rajdas@gmail.com>

* Adding amd build

Signed-off-by: Raj Das <mail.rajdas@gmail.com>

* Adding go env

Signed-off-by: Raj Das <mail.rajdas@gmail.com>

* minor fix

Signed-off-by: Raj Das <mail.rajdas@gmail.com>

* removing docker tag

Signed-off-by: Raj Das <mail.rajdas@gmail.com>

* Adding local dockerfile build command

Signed-off-by: rajdas98 <mail.rajdas@gmail.com>
This commit is contained in:
Raj Babu Das 2021-02-19 07:39:01 +05:30 committed by GitHub
parent 48f0d90dd1
commit 0b832a038d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 63 additions and 29 deletions

View file

@ -43,6 +43,12 @@ jobs:
- name: golangci-lint - name: golangci-lint
uses: reviewdog/action-golangci-lint@v1 uses: reviewdog/action-golangci-lint@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
id: buildx
with:
install: true
- name: docker images build - name: docker images build
run: | run: |
make docker-build-all make docker-build-all

View file

@ -53,9 +53,9 @@ jobs:
- name: golangci-lint - name: golangci-lint
uses: reviewdog/action-golangci-lint@v1 uses: reviewdog/action-golangci-lint@v1
- name: docker images build - name: docker images build (AMD64)
run: | run: |
make docker-build-all make docker-build-all-amd64
- name : Create Kind Cluster and setup kustomize - name : Create Kind Cluster and setup kustomize
run: | run: |

View file

@ -21,6 +21,12 @@ jobs:
- name: login to GitHub Container Registry - name: login to GitHub Container Registry
run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
id: buildx
with:
install: true
- name: docker images publish - name: docker images publish
run: | run: |
make docker-publish-all make docker-publish-all

View file

@ -35,6 +35,12 @@ jobs:
- name: login to GitHub Container Registry - name: login to GitHub Container Registry
run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
id: buildx
with:
install: true
- name : docker images publish - name : docker images publish
run: | run: |
make docker-publish-all make docker-publish-all

View file

@ -31,24 +31,24 @@ INITC_IMAGE := kyvernopre
initContainer: fmt vet initContainer: fmt vet
GOOS=$(GOOS) go build -o $(PWD)/$(INITC_PATH)/kyvernopre -ldflags=$(LD_FLAGS) $(PWD)/$(INITC_PATH)/main.go GOOS=$(GOOS) go build -o $(PWD)/$(INITC_PATH)/kyvernopre -ldflags=$(LD_FLAGS) $(PWD)/$(INITC_PATH)/main.go
.PHONY: docker-build-initContainer docker-tag-repo-initContainer docker-push-initContainer .PHONY: docker-build-initContainer docker-push-initContainer
docker-publish-initContainer: docker-build-initContainer docker-tag-repo-initContainer docker-push-initContainer docker-publish-initContainer: docker-build-initContainer docker-push-initContainer
docker-build-initContainer: docker-build-initContainer:
@docker build -f $(PWD)/$(INITC_PATH)/Dockerfile -t $(REPO)/$(INITC_IMAGE):$(IMAGE_TAG) . --build-arg LD_FLAGS=$(LD_FLAGS) @docker buildx build --file $(PWD)/$(INITC_PATH)/Dockerfile --progress plane --platform linux/arm64,linux/amd64 --tag $(REPO)/$(INITC_IMAGE):$(IMAGE_TAG) . --build-arg LD_FLAGS=$(LD_FLAGS)
docker-tag-repo-initContainer: docker-build-initContainer-amd64:
@docker tag $(REPO)/$(INITC_IMAGE):$(IMAGE_TAG) $(REPO)/$(INITC_IMAGE):latest @docker build -f $(PWD)/$(INITC_PATH)/Dockerfile -t $(REPO)/$(INITC_IMAGE):$(IMAGE_TAG) . --build-arg LD_FLAGS=$(LD_FLAGS) --build-arg TARGETPLATFORM="linux/amd64"
docker-push-initContainer: docker-push-initContainer:
@docker push $(REPO)/$(INITC_IMAGE):$(IMAGE_TAG) @docker buildx build --file $(PWD)/$(INITC_PATH)/Dockerfile --progress plane --push --platform linux/arm64,linux/amd64 --tag $(REPO)/$(INITC_IMAGE):$(IMAGE_TAG) .
@docker push $(REPO)/$(INITC_IMAGE):latest @docker buildx build --file $(PWD)/$(INITC_PATH)/Dockerfile --progress plane --push --platform linux/arm64,linux/amd64 --tag $(REPO)/$(INITC_IMAGE):latest .
################################## ##################################
# KYVERNO CONTAINER # KYVERNO CONTAINER
################################## ##################################
.PHONY: docker-build-kyverno docker-tag-repo-kyverno docker-push-kyverno .PHONY: docker-build-kyverno docker-push-kyverno
KYVERNO_PATH := cmd/kyverno KYVERNO_PATH := cmd/kyverno
KYVERNO_IMAGE := kyverno KYVERNO_IMAGE := kyverno
@ -59,22 +59,21 @@ local:
kyverno: fmt vet kyverno: fmt vet
GOOS=$(GOOS) go build -o $(PWD)/$(KYVERNO_PATH)/kyverno -ldflags=$(LD_FLAGS) $(PWD)/$(KYVERNO_PATH)/main.go GOOS=$(GOOS) go build -o $(PWD)/$(KYVERNO_PATH)/kyverno -ldflags=$(LD_FLAGS) $(PWD)/$(KYVERNO_PATH)/main.go
docker-publish-kyverno: docker-build-kyverno docker-tag-repo-kyverno docker-push-kyverno docker-publish-kyverno: docker-build-kyverno docker-push-kyverno
docker-build-kyverno: docker-build-kyverno:
@docker build -f $(PWD)/$(KYVERNO_PATH)/Dockerfile -t $(REPO)/$(KYVERNO_IMAGE):$(IMAGE_TAG) . --build-arg LD_FLAGS=$(LD_FLAGS) @docker buildx build --file $(PWD)/$(KYVERNO_PATH)/Dockerfile --progress plane --platform linux/arm64,linux/amd64 --tag $(REPO)/$(KYVERNO_IMAGE):$(IMAGE_TAG) . --build-arg LD_FLAGS=$(LD_FLAGS)
docker-build-local-kyverno: docker-build-local-kyverno:
CGO_ENABLED=0 GOOS=linux go build -o $(PWD)/$(KYVERNO_PATH)/kyverno -ldflags=$(LD_FLAGS) $(PWD)/$(KYVERNO_PATH)/main.go CGO_ENABLED=0 GOOS=linux go build -o $(PWD)/$(KYVERNO_PATH)/kyverno -ldflags=$(LD_FLAGS) $(PWD)/$(KYVERNO_PATH)/main.go
@docker build -f $(PWD)/$(KYVERNO_PATH)/localDockerfile -t $(REPO)/$(KYVERNO_IMAGE):$(IMAGE_TAG) $(PWD)/$(KYVERNO_PATH) @docker build -f $(PWD)/$(KYVERNO_PATH)/localDockerfile -t $(REPO)/$(KYVERNO_IMAGE):$(IMAGE_TAG) $(PWD)/$(KYVERNO_PATH)
docker-tag-repo-kyverno: docker-build-kyverno-amd64:
@echo "docker tag $(REPO)/$(KYVERNO_IMAGE):$(IMAGE_TAG) $(REPO)/$(KYVERNO_IMAGE):latest" @docker build -f $(PWD)/$(KYVERNO_PATH)/Dockerfile -t $(REPO)/$(KYVERNO_IMAGE):$(IMAGE_TAG) . --build-arg LD_FLAGS=$(LD_FLAGS) --build-arg TARGETPLATFORM="linux/amd64"
@docker tag $(REPO)/$(KYVERNO_IMAGE):$(IMAGE_TAG) $(REPO)/$(KYVERNO_IMAGE):latest
docker-push-kyverno: docker-push-kyverno:
@docker push $(REPO)/$(KYVERNO_IMAGE):$(IMAGE_TAG) @docker buildx build --file $(PWD)/$(KYVERNO_PATH)/Dockerfile --progress plane --push --platform linux/arm64,linux/amd64 --tag $(REPO)/$(KYVERNO_IMAGE):$(IMAGE_TAG) .
@docker push $(REPO)/$(KYVERNO_IMAGE):latest @docker buildx build --file $(PWD)/$(KYVERNO_PATH)/Dockerfile --progress plane --push --platform linux/arm64,linux/amd64 --tag $(REPO)/$(KYVERNO_IMAGE):latest .
################################## ##################################
@ -88,32 +87,31 @@ generate-api-docs:
################################## ##################################
# CLI # CLI
################################## ##################################
.PHONY: docker-build-cli docker-tag-repo-cli docker-push-cli .PHONY: docker-build-cli docker-push-cli
CLI_PATH := cmd/cli/kubectl-kyverno CLI_PATH := cmd/cli/kubectl-kyverno
KYVERNO_CLI_IMAGE := kyverno-cli KYVERNO_CLI_IMAGE := kyverno-cli
cli: cli:
GOOS=$(GOOS) go build -o $(PWD)/$(CLI_PATH)/kyverno -ldflags=$(LD_FLAGS) $(PWD)/$(CLI_PATH)/main.go GOOS=$(GOOS) go build -o $(PWD)/$(CLI_PATH)/kyverno -ldflags=$(LD_FLAGS) $(PWD)/$(CLI_PATH)/main.go
docker-publish-cli: docker-build-cli docker-tag-repo-cli docker-push-cli docker-publish-cli: docker-build-cli docker-push-cli
docker-build-cli: docker-build-cli:
@docker build -f $(PWD)/$(CLI_PATH)/Dockerfile -t $(REPO)/$(KYVERNO_CLI_IMAGE):$(IMAGE_TAG) . --build-arg LD_FLAGS=$(LD_FLAGS) @docker buildx build --file $(PWD)/$(CLI_PATH)/Dockerfile --progress plane --platform linux/arm64,linux/amd64 --tag $(REPO)/$(KYVERNO_CLI_IMAGE):$(IMAGE_TAG) . --build-arg LD_FLAGS=$(LD_FLAGS)
docker-tag-repo-cli: docker-build-cli-amd64:
@echo "docker tag $(REPO)/$(KYVERNO_CLI_IMAGE):$(IMAGE_TAG) $(REPO)/$(KYVERNO_CLI_IMAGE):latest" @docker build -f $(PWD)/$(CLI_PATH)/Dockerfile -t $(REPO)/$(KYVERNO_CLI_IMAGE):$(IMAGE_TAG) . --build-arg LD_FLAGS=$(LD_FLAGS) --build-arg TARGETPLATFORM="linux/amd64"
@docker tag $(REPO)/$(KYVERNO_CLI_IMAGE):$(IMAGE_TAG) $(REPO)/$(KYVERNO_CLI_IMAGE):latest
docker-push-cli: docker-push-cli:
@docker push $(REPO)/$(KYVERNO_CLI_IMAGE):$(IMAGE_TAG) @docker buildx build --file $(PWD)/$(CLI_PATH)/Dockerfile --progress plane --push --platform linux/arm64,linux/amd64 --tag $(REPO)/$(KYVERNO_CLI_IMAGE):$(IMAGE_TAG) .
@docker push $(REPO)/$(KYVERNO_CLI_IMAGE):latest @docker buildx build --file $(PWD)/$(CLI_PATH)/Dockerfile --progress plane --push --platform linux/arm64,linux/amd64 --tag $(REPO)/$(KYVERNO_CLI_IMAGE):latest .
################################## ##################################
docker-publish-all: docker-publish-initContainer docker-publish-kyverno docker-publish-cli docker-publish-all: docker-publish-initContainer docker-publish-kyverno docker-publish-cli
docker-build-all: docker-build-initContainer docker-build-kyverno docker-build-cli docker-build-all: docker-build-initContainer docker-build-kyverno docker-build-cli
docker-tag-all: docker-tag-repo-initContainer docker-tag-repo-kyverno docker-tag-repo-cli docker-build-all-amd64: docker-build-initContainer-amd64 docker-build-kyverno-amd64 docker-build-cli-amd64
################################## ##################################
# Create e2e Infrastruture # Create e2e Infrastruture

View file

@ -6,11 +6,17 @@ LABEL maintainer="Kyverno"
# LD_FLAGS is passed as argument from Makefile. It will be empty, if no argument passed # LD_FLAGS is passed as argument from Makefile. It will be empty, if no argument passed
ARG LD_FLAGS ARG LD_FLAGS
ARG TARGETPLATFORM
ADD . /kyverno ADD . /kyverno
WORKDIR /kyverno WORKDIR /kyverno
RUN CGO_ENABLED=0 GOOS=linux go build -o /output/kyverno -ldflags="${LD_FLAGS}" -v ./cmd/cli/kubectl-kyverno/ RUN export GOOS=$(echo ${TARGETPLATFORM} | cut -d / -f1) && \
export GOARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2)
RUN go env
RUN CGO_ENABLED=0 go build -o /output/kyverno -ldflags="${LD_FLAGS}" -v ./cmd/cli/kubectl-kyverno/
RUN useradd -u 10001 kyverno RUN useradd -u 10001 kyverno

View file

@ -6,11 +6,17 @@ LABEL maintainer="Kyverno"
# LD_FLAGS is passed as argument from Makefile. It will be empty, if no argument passed # LD_FLAGS is passed as argument from Makefile. It will be empty, if no argument passed
ARG LD_FLAGS ARG LD_FLAGS
ARG TARGETPLATFORM
ADD . /kyverno ADD . /kyverno
WORKDIR /kyverno WORKDIR /kyverno
RUN CGO_ENABLED=0 GOOS=linux go build -o /output/kyvernopre -ldflags="${LD_FLAGS}" -v ./cmd/initContainer/ RUN export GOOS=$(echo ${TARGETPLATFORM} | cut -d / -f1) && \
export GOARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2)
RUN go env
RUN CGO_ENABLED=0 go build -o /output/kyvernopre -ldflags="${LD_FLAGS}" -v ./cmd/initContainer/
RUN useradd -u 10001 kyverno RUN useradd -u 10001 kyverno

View file

@ -6,11 +6,17 @@ LABEL maintainer="Kyverno"
# LD_FLAGS is passed as argument from Makefile. It will be empty, if no argument passed # LD_FLAGS is passed as argument from Makefile. It will be empty, if no argument passed
ARG LD_FLAGS ARG LD_FLAGS
ARG TARGETPLATFORM
ADD . /kyverno ADD . /kyverno
WORKDIR /kyverno WORKDIR /kyverno
RUN CGO_ENABLED=0 GOOS=linux go build -o /output/kyverno -ldflags="${LD_FLAGS}" -v ./cmd/kyverno/ RUN export GOOS=$(echo ${TARGETPLATFORM} | cut -d / -f1) && \
export GOARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2)
RUN go env
RUN CGO_ENABLED=0 go build -o /output/kyverno -ldflags="${LD_FLAGS}" -v ./cmd/kyverno/
RUN useradd -u 10001 kyverno RUN useradd -u 10001 kyverno