Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ARM64 support #942

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 1 addition & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ jobs:
docker login --username ${DOCKERHUB_USER} --password ${DOCKERHUB_PASSWORD} &&
export IMAGE_TAG=$([[ "$CIRCLE_BRANCH" == "staging" ]] && echo "staging-candidate" || echo "discardable") &&
IMAGE_NAME_CANDIDATE=snyk/kubernetes-monitor:${IMAGE_TAG}-${CIRCLE_SHA1} &&
./scripts/docker/build-image.sh ${IMAGE_NAME_CANDIDATE} &&
docker push ${IMAGE_NAME_CANDIDATE}
./scripts/docker/build-image.sh ${IMAGE_NAME_CANDIDATE}
name: Build image
- run:
command: |
Expand Down
3 changes: 1 addition & 2 deletions .circleci/config/jobs/@jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ build_image:
docker login --username ${DOCKERHUB_USER} --password ${DOCKERHUB_PASSWORD} &&
export IMAGE_TAG=$([[ "$CIRCLE_BRANCH" == "staging" ]] && echo "staging-candidate" || echo "discardable") &&
IMAGE_NAME_CANDIDATE=snyk/kubernetes-monitor:${IMAGE_TAG}-${CIRCLE_SHA1} &&
./scripts/docker/build-image.sh ${IMAGE_NAME_CANDIDATE} &&
docker push ${IMAGE_NAME_CANDIDATE}
./scripts/docker/build-image.sh ${IMAGE_NAME_CANDIDATE}
- run:
name: Notify Slack on failure
command: |
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ENV NODE_ENV production
RUN curl -sL https://rpm.nodesource.com/setup_16.x | bash -
RUN yum install -y nodejs

RUN curl -L -o /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64
RUN if [ "$(uname -m)" = "x86_64" ]; then curl -L -o /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64 ; else curl -L -o /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_arm64 ; fi
RUN chmod 755 /usr/bin/dumb-init

RUN groupadd -g 10001 snyk
Expand Down
7 changes: 6 additions & 1 deletion scripts/docker/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ LOCAL_DISCARDABLE_IMAGE=snyk/kubernetes-monitor:local
# should happen on merging to `staging`
NAME_AND_TAG=${1:-$LOCAL_DISCARDABLE_IMAGE}

docker build -t ${NAME_AND_TAG} .
mkdir -vp ~/.docker/cli-plugins/
curl --silent -L --output ~/.docker/cli-plugins/docker-buildx https://github.com/docker/buildx/releases/download/v0.6.3/buildx-v0.6.3.linux-amd64
chmod a+x ~/.docker/cli-plugins/docker-buildx
docker run -it --rm --privileged tonistiigi/binfmt --install all
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @odidev what does this line do?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ivanstanev,
Since Circle-CI runner supports only amd64 platform, these lines add docker buildx which is required to build and release docker images for multiple architectures.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see but what does tonistiigi/binfmt do and why does it need to run privileged?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ivanstanev,
The command enables docker buildx builder to support multiple architecture builds. You can refer official Circle-CI blog to build docker images for multiple architectures here. I have added same steps.

docker buildx create --use --name mybuilder
docker buildx build --platform linux/amd64,linux/arm64 -t ${NAME_AND_TAG} --push .
15 changes: 15 additions & 0 deletions snyk-monitor-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ spec:
labels:
app.kubernetes.io/name: snyk-monitor
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "kubernetes.io/arch"
operator: In
values:
- amd64
- arm64
- key: "beta.kubernetes.io/arch"
operator: In
values:
- amd64
- arm64
containers:
- image: snyk/kubernetes-monitor:IMAGE_TAG_OVERRIDE_WHEN_PUBLISHING
imagePullPolicy: Always
Expand Down
8 changes: 6 additions & 2 deletions snyk-monitor/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ spec:
- matchExpressions:
- key: "kubernetes.io/arch"
operator: In
values: ["amd64"]
values:
- amd64
- arm64
- key: "beta.kubernetes.io/arch"
operator: In
values: ["amd64"]
values:
- amd64
- arm64
serviceAccountName: {{ include "snyk-monitor.name" . }}
restartPolicy: Always
initContainers:
Expand Down