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

Specify the arch passed as build arg in the distroless image (#848) #882

Merged

Conversation

Serializator
Copy link
Contributor

What this PR does / why we need it:
I moved ARG ARCH to the start so that it can be used in the last stage (gcr.io/distroless/static:latest-$ARCH). It is declared again below FROM golang:1.17.1 as build so that it is available when make metrics-server is run.

I tested with the architectures defined in the Makefile, each of which worked as expected.
https://github.com/kubernetes-sigs/metrics-server/blob/master/Makefile#L14

$ docker buildx build -t kubernetes-sigs/metrics-server:<arch> \
    --build-arg ARCH=<arch> \
    --build-arg GIT_COMMIT=foo \
    --build-arg GIT_TAG=bar .

"foo" and "bar" came back in the logs for make metrics-server as well, indicating that these are available as environment variables. I wanted to test this as well because I only noticed later that ARCH was not available anymore when I moved ARG ARCH to the start.

I don't know exactly where these images are built but it would be better to compare the architecture of the image that was built with the expected architecture, to prevent a regression in the future.

Which issue(s) this PR fixes:
Fixes #848

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 3, 2021
@k8s-ci-robot
Copy link
Contributor

Welcome @Serializator!

It looks like this is your first PR to kubernetes-sigs/metrics-server 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/metrics-server has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 3, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @Serializator. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 3, 2021
Dockerfile Outdated Show resolved Hide resolved
@serathius
Copy link
Contributor

serathius commented Nov 3, 2021

I have verified locally that this fix works, great job!
Aside one nit, this looks good to be merged.

As for testing we should be able to confirm by checking image pushed after merge gcr.io/k8s-staging-metrics-server/metrics-server:master

@Serializator
Copy link
Contributor Author

Thank you! I made the necessary changes according to your feedback.

@serathius
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 3, 2021
@serathius
Copy link
Contributor

serathius commented Nov 3, 2021

Ups, looks like you need to specify default for

buildArgs:

@Serializator
Copy link
Contributor Author

Ups, looks like you need to specify default for

buildArgs:

I added "amd64" as the default 👍🏼

@serathius
Copy link
Contributor

/retest

@Serializator
Copy link
Contributor Author

As for testing we should be able to confirm by checking image pushed after merge gcr.io/k8s-staging-metrics-server/metrics-server:master

@serathius What about adding it as a structure test in the Skaffold configuration? I looked through the kind of structure tests there are but none of them seem related to the metadata of the image, most of them seem to be ran from within the container.

@serathius
Copy link
Contributor

As for testing we should be able to confirm by checking image pushed after merge gcr.io/k8s-staging-metrics-server/metrics-server:master

@serathius What about adding it as a structure test in the Skaffold configuration? I looked through the kind of structure tests there are but none of them seem related to the metadata of the image, most of them seem to be ran from within the container.

Sure, maybe instead of adding it to Skaffold tests that run k8s cluster, we might want to expand cli tests https://github.com/kubernetes-sigs/metrics-server/blob/master/Makefile#L128-L133 as they just use docker to check image.

@serathius
Copy link
Contributor

This should be good to merge. We can add tests as separate PR.

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: serathius, Serializator

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 3, 2021
@k8s-ci-robot k8s-ci-robot merged commit 1cc7b18 into kubernetes-sigs:master Nov 3, 2021
@serathius
Copy link
Contributor

Confirmed that problem was fixed

~ $ docker pull --platform linux/ppc64le gcr.io/k8s-staging-metrics-server/metrics-server:master
master: Pulling from k8s-staging-metrics-server/metrics-server
e5decac5defe: Pull complete 
1f48636f6f92: Pull complete 
Digest: sha256:b3b6ca00d7bd8211f2e74115ad121be6d2ae8eda9a187ef4e0c60e83ed6be0d8
Status: Downloaded newer image for gcr.io/k8s-staging-metrics-server/metrics-server:master
gcr.io/k8s-staging-metrics-server/metrics-server:master
~ $ docker inspect gcr.io/k8s-staging-metrics-server/metrics-server:master | grep Arch
        "Architecture": "ppc64le",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bad architecture metadata in k8s.gcr.io images
3 participants