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

Allow images to be loaded into kind using 'kind.local'. #180

Merged
merged 4 commits into from
Sep 4, 2020

Conversation

markusthoemmes
Copy link
Contributor

@markusthoemmes markusthoemmes commented Aug 10, 2020

Fixes #123
Fixes #149

This allows ko to load images into kind nodes when the user is setting the KO_DOCKER_REPO to kind.local.

This replicates some of kind's CLI in that it talks to the container hosting the respective K8s node and loads an image into it by execing into the containerd instance of the respective container and loading the image in via stdin.

@markusthoemmes markusthoemmes force-pushed the kind-publisher branch 2 times, most recently from 69c0040 to b82ee35 Compare September 1, 2020 14:45

// Cause the pod to "hang" to allow us to check for a readiness state.
sigs := make(chan os.Signal)
signal.Notify(sigs, syscall.SIGTERM)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This might have problems with Windows. Paging @evankanderson

Copy link
Collaborator

Choose a reason for hiding this comment

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

looking here, it looks like TERM is wrong on windows and we want Interrupt (for both): https://github.com/knative/pkg/blob/master/signals/signal_windows.go

Copy link
Contributor

Choose a reason for hiding this comment

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

What setup do I need to run this test? I have Windows and I think I have Kind on there (I've been using the Docker k8s cluster recently, but have tried several).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@evankanderson kind should be fine. Just running integration-tests.sh should do it.

Copy link
Contributor

Choose a reason for hiding this comment

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

It turns out that .\integration-tests.sh doesn't work at all unless you install WSL. 😁

I'm interpreting that into windows-ese now, as running in WSL2 isn't really what I think you meant.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not looking good:

where.exe ko | Get-Item


    Directory: C:\Users\evank\go\bin

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---            9/4/2020  3:55 PM       45475328 ko.exe
apiVersion: v1
kind: Pod
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{},"name":"kodata","namespace":"default"},"spec":{"containers":[{"image":"kind.local/test-0e3a563dcfe31cd0109fe43c1bf7c91e:07723e67f22e6166c482243cd364ce809e692ebfceeb5ac1fe6c1a6d8b533bac","name":"obiwan"}],"restartPolicy":"Never"}}
  creationTimestamp: "2020-09-04T23:00:45Z"
  name: kodata
  namespace: default
  resourceVersion: "460"
  selfLink: /api/v1/namespaces/default/pods/kodata
  uid: 5042f04f-ec41-4977-8277-1c2d3105a326
spec:
  containers:
  - image: kind.local/test-0e3a563dcfe31cd0109fe43c1bf7c91e:07723e67f22e6166c482243cd364ce809e692ebfceeb5ac1fe6c1a6d8b533bac
    imagePullPolicy: IfNotPresent
    name: obiwan
    resources: {}
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: default-token-gmfbj
      readOnly: true
  dnsPolicy: ClusterFirst
  enableServiceLinks: true
  nodeName: kind-control-plane
  priority: 0
  restartPolicy: Never
  schedulerName: default-scheduler
  securityContext: {}
  serviceAccount: default
  serviceAccountName: default
  terminationGracePeriodSeconds: 30
  tolerations:
  - effect: NoExecute
    key: node.kubernetes.io/not-ready
    operator: Exists
    tolerationSeconds: 300
  - effect: NoExecute
    key: node.kubernetes.io/unreachable
    operator: Exists
    tolerationSeconds: 300
  volumes:
  - name: default-token-gmfbj
    secret:
      defaultMode: 420
      secretName: default-token-gmfbj
status:
  conditions:
  - lastProbeTime: null
    lastTransitionTime: "2020-09-04T23:00:48Z"
    status: "True"
    type: Initialized
  - lastProbeTime: null
    lastTransitionTime: "2020-09-04T23:00:48Z"
    message: 'containers with unready status: [obiwan]'
    reason: ContainersNotReady
    status: "False"
    type: Ready
  - lastProbeTime: null
    lastTransitionTime: "2020-09-04T23:00:48Z"
    message: 'containers with unready status: [obiwan]'
    reason: ContainersNotReady
    status: "False"
    type: ContainersReady
  - lastProbeTime: null
    lastTransitionTime: "2020-09-04T23:00:48Z"
    status: "True"
    type: PodScheduled
  containerStatuses:
  - containerID: containerd://093eaf8b2bb2b10597fc384baacdac2047144e59380ca403b1267952b53dd55d
    image: kind.local/test-0e3a563dcfe31cd0109fe43c1bf7c91e:latest
    imageID: sha256:86b4c2af5f8f1b04278bd8c20b04c4953826b146f7af0b86734f725117e36b82
    lastState: {}
    name: obiwan
    ready: false
    restartCount: 0
    started: false
    state:
      terminated:
        containerID: containerd://093eaf8b2bb2b10597fc384baacdac2047144e59380ca403b1267952b53dd55d
        exitCode: 1
        finishedAt: "2020-09-04T23:00:49Z"
        reason: Error
        startedAt: "2020-09-04T23:00:49Z"
  hostIP: 172.17.0.2
  phase: Failed
  podIP: 10.244.0.2
  podIPs:
  - ip: 10.244.0.2
  qosClass: BestEffort
  startTime: "2020-09-04T23:00:48Z"

Copy link
Contributor

Choose a reason for hiding this comment

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

Kubectl logs output:

kubectl logs kodata
2020/09/04 23:00:49 ../kenobi
2020/09/04 23:00:49 Error reading "/var/run/ko/refs/heads/master": open /var/run/ko/refs/heads/master: not a directory

return pw.CloseWithError(tarball.Write(tag, img, pw))
})

cmd := n.Command("ctr", "--namespace=k8s.io", "images", "import", "-").SetStdin(pr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

these are going to run serially. I wonder about running onEachNode in an errgroup?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like complexity for a follow-up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack, I thought about that too but then wanted to get the general mechanism blessed first.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep, this seems great. We should add kind.local to the list of built-in domains that Serving ignores for digest resolution too 😎

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll do that as soon as this lands 😂

@mattmoor
Copy link
Collaborator

mattmoor commented Sep 4, 2020

@markusthoemmes Can you update the README to call this out? Generally this seems great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add pkg/v1/kind for writing images to KinD Document how to use ko with kind
5 participants