kubernetesskaffold

How do I set the build output platform x86_64 in a Skaffold configuration?


Since I'm developing on an M1 mac, my Docker builds will build ARM. I want to build x86_64 images which I know I can build with the --platform flag but I want to do that with my Skaffold configuration.


Solution

  • Thanks to @p10l putting me on the right track, I was able to figure it out. Skaffold can't set the platform using the Docker Engine API, so we need to pass --platform=linux/x86_64 to the command line by setting useDockerCLI to true and adding cliFlags to our Docker configuration.

    apiVersion: skaffold/v2beta26
    kind: Config
    build:
      # ... other unrelated config ...
      artifacts:
        - image: my-image
          context: ./
          docker:
            cliFlags:
              - --platform=linux/x86_64 
      local:
        useDockerCLI: true # the only way to set platform is with cliFlags so we need to enable the Docker CLI