GoogleContainerTools / skaffold

Easy and Repeatable Kubernetes Development
https://skaffold.dev/
Apache License 2.0
15.05k stars 1.62k forks source link

No child with platform linux/amd64 in index openjdk:8u312-nanoserver-1809 #6902

Open mikedld opened 2 years ago

mikedld commented 2 years ago

Expected behavior

Building Windows container image on Linux (using DOCKER_HOST) succeeds.

Actual behavior

# DOCKER_HOST=tcp://windows.host:2375 skaffold build -p build-only --default-repo=foo.bar
Generating tags...
 - cli-tools/openjdk -> foo.bar/cli-tools_openjdk:ef75757-ltsc2019
Checking cache...
 - cli-tools/openjdk: Error checking cache.
getting hash for artifact "cli-tools/openjdk": getting dependencies for "cli-tools/openjdk": parsing ONBUILD instructions: retrieving image "openjdk:8u312-nanoserver-1809": no child with platform linux/amd64 in index openjdk:8u312-nanoserver-1809

Information

apiVersion: skaffold/v2beta20
kind: Config
build:
  artifacts:
    - image: cli-tools/openjdk
      context: cli-tools/openjdk
  tagPolicy:
    customTemplate:
      template: "{{.COMMIT}}-ltsc2019"
      components:
        - name: COMMIT
          gitCommit: {}
profiles:
  - name: build-only
    build:
      local:
        push: false
FROM openjdk:8u312-nanoserver-1809

Steps to reproduce the behavior

See above.

Current workaround:

apiVersion: skaffold/v2beta20
kind: Config
build:
  artifacts:
    - image: bases/openjdk
      custom:
        buildCommand: docker pull openjdk:8u312-nanoserver-1809 && docker tag openjdk:8u312-nanoserver-1809 $IMAGE
    - image: cli-tools/openjdk
      context: cli-tools/openjdk
      requires:
        - image: bases/openjdk
          alias: BASE
  tagPolicy:
    customTemplate:
      template: "{{.COMMIT}}-ltsc2019"
      components:
        - name: COMMIT
          gitCommit: {}
profiles:
  - name: build-only
    build:
      local:
        push: false
ARG BASE
FROM ${BASE}
tejal29 commented 2 years ago

Skaffold does not support cross platforms builds yet. We will be working on this feature soon in Q2 2022.

ethanhallb commented 2 years ago

+1 on this issue, though the use case is slightly different.

Expected behavior

Requests to with a remote builder like googleCloudBuild allow the remote building to perform platform/architecture checks and implementations, avoiding the local skaffold environment limitations.

ie a local Dockerfile that pulls FROM a different platform/architecture image, does not prevent skaffold build from running, since the build task is delegated to a remote builder with a different environment (Google Cloud Build.)

Actual behavior

Skaffold is performing local Dockerfile validation and enforcing platform rules, before sending context to the remote googleCloudBuilder. As the local environment does not match the Dockerfile build chain, the parsing ONBUILD instructions step errors out and halts the process.

Possible solution

Skaffold parameters/config allow to suppress the Dockerfile onbuild inspection for FROM chain, at least for platform architecture, when explicitly set and/or when a known remote building environment is used for building

Contents of Dockerfile

ARG WINDOWS_VERSION=ltsc2019
FROM mcr.microsoft.com/windows/servercore:${WINDOWS_VERSION}
[...]

Output from skaffold

skaffold build -vtrace

..
INFO[0000] Skaffold &{Version:v1.38.0 ConfigVersion:skaffold/v2beta28 GitVersion: 
..
DEBU[0000] Using builder: google cloud                   subtask=-1 task=DevLoop
..
Checking cache...
TRAC[0000] Checking base image golang:1.16-alpine for ONBUILD triggers.  subtask=-1 task=DevLoop
TRAC[0000] Checking base image mcr.microsoft.com/windows/servercore:ltsc2019 for ONBUILD triggers.  subtask=-1 ..                                       
TRAC[0000] --> GET https://mcr.microsoft.com/v2/windows/servercore/manifests/ltsc2019 
..                                        
TRAC[0000] {"schemaVersion":2,"mediaType":"application/vnd.docker.distribution.manifest.list.v2+json","manifests":[{"mediaType":"application/vnd.docker.distribution.manifest.v2+json","size":886,"digest":"sha256:704343b4035e7b249499354375eca8abb9c62746af06586013e91a7d4c0b033e","platform":{"architecture":"amd64","os":"windows","os.version":"10.0.17763.3046","os.features":["win32k"]}}]} 
 - us-central1-docker.pkg.dev/ticketingdevops-332715/devops-iac/test-go-http-basic: Error checking cache.
..
getting hash for artifact "us-central1-docker.pkg.dev/ticketingdevops-332715/devops-iac/test-go-http-basic": getting dependencies for "us-central1-docker.pkg.dev/ticketingdevops-332715/devops-iac/test-go-http-basic": parsing ONBUILD instructions: retrieving image "mcr.microsoft.com/windows/servercore:ltsc2019": no child with platform linux/amd64 in index mcr.microsoft.com/windows/servercore:ltsc2019

Information

Skaffold version: 1.38.0 Operating system: Linux (Debian 12 rodete/amd64) Installed via: skaffold.dev Contents of skaffold.yaml:

apiVersion: skaffold/v2beta28
kind: Config
metadata:
  name: test-win-go-http
build:
  #artifacts:
  #  - image: win1
  googleCloudBuild:
    projectId: ticketingdevops-332715
    timeout: 3600s
    logging: GCS_ONLY
    dockerImage: 'us-docker.pkg.dev/gke-windows-tools/docker-repo/gke-windows-builder:latest'
    concurrency: 1
  artifacts:
  - image: windows-hello-sk
deploy:
  kubectl:
    manifests:
    - kubernetes/manifest.yaml