Docker vs K8s API

41 views
Skip to first unread message

Diego Lapiduz

unread,
Jun 2, 2017, 12:09:11 AM6/2/17
to Kubernetes user discussion and Q&A
Hi y'all, (k8s noob here so forgive me if this is something that I am doing obviously wrong)

I am trying to run a short lived task and I am trying to move from Docker Swarm to Kubernetes. An interesting issue that I am finding is that running the same Docker image on the same minikube cluster is much faster using the docker cli tool (or docker api) than kubectl.

Here is a quick screen cap: I know that I am probably doing something off, any idea what it could be? Thanks!






Tim Hockin

unread,
Jun 2, 2017, 12:27:56 AM6/2/17
to Kubernetes user discussion and Q&A
It runs faster or it starts faster?  The gif clear too quickly for me to see.

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-users+unsubscribe@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.

Diego Lapiduz

unread,
Jun 2, 2017, 10:13:54 AM6/2/17
to kubernet...@googlegroups.com
This is a very short lived task (just runs `echo hello`) so the only thing I really care about is getting that `hello` back.

This is what I did in text format:

```
➜  eval $(minikube docker-env)

➜  time docker run dlapiduz/hello-world

hello
docker run dlapiduz/hello-world  0.07s user 0.02s system 30% cpu 0.318 total
➜  time kubectl run --image=dlapiduz/hello-world test --attach --restart=Never
Waiting for pod default/test to be running, status is Pending, pod ready: false
hello
kubectl run --image=dlapiduz/hello-world test --attach --restart=Never  0.09s user 0.02s system 7% cpu 1.357 total
```

--
You received this message because you are subscribed to a topic in the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kubernetes-users/MArCwIOYWo0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kubernetes-users+unsubscribe@googlegroups.com.

Matthias Rampke

unread,
Jun 2, 2017, 10:38:24 AM6/2/17
to kubernet...@googlegroups.com
Is this difference a problem for your use case? Kubernetes does do more work before a pod starts. If you need low-latency execution you'll have to use long-running worker processes of some form. Once it's started, it should be just as fast.

On Fri, Jun 2, 2017 at 2:13 PM Diego Lapiduz <di...@lapiduz.com> wrote:
This is a very short lived task (just runs `echo hello`) so the only thing I really care about is getting that `hello` back.

This is what I did in text format:

```
➜  eval $(minikube docker-env)

➜  time docker run dlapiduz/hello-world

hello
docker run dlapiduz/hello-world  0.07s user 0.02s system 30% cpu 0.318 total
➜  time kubectl run --image=dlapiduz/hello-world test --attach --restart=Never
Waiting for pod default/test to be running, status is Pending, pod ready: false
hello
kubectl run --image=dlapiduz/hello-world test --attach --restart=Never  0.09s user 0.02s system 7% cpu 1.357 total
```

On Thu, Jun 1, 2017 at 11:27 PM, 'Tim Hockin' via Kubernetes user discussion and Q&A <kubernet...@googlegroups.com> wrote:
It runs faster or it starts faster?  The gif clear too quickly for me to see.
On Thu, Jun 1, 2017 at 9:09 PM, Diego Lapiduz <di...@lapiduz.com> wrote:
Hi y'all, (k8s noob here so forgive me if this is something that I am doing obviously wrong)

I am trying to run a short lived task and I am trying to move from Docker Swarm to Kubernetes. An interesting issue that I am finding is that running the same Docker image on the same minikube cluster is much faster using the docker cli tool (or docker api) than kubectl.

Here is a quick screen cap: I know that I am probably doing something off, any idea what it could be? Thanks!






--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kubernetes-users/MArCwIOYWo0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kubernetes-use...@googlegroups.com.

To post to this group, send email to kubernet...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.

Diego Lapiduz

unread,
Jun 2, 2017, 10:41:23 AM6/2/17
to kubernet...@googlegroups.com
Thanks Matthias, yes this is a bit of a problem for my use case. Ideally I'd like to run a fresh container every time that is why I am trying to do this.
The weird thing is that Kubernetes is the backend in both cases, I am just using the Docker API in one case and the kubernetes one in the other. Not sure what the difference is but there should be a way to replicate what docker run is doing with kubectl (or their API equivalents).

On Fri, Jun 2, 2017 at 9:38 AM, Matthias Rampke <m...@soundcloud.com> wrote:
Is this difference a problem for your use case? Kubernetes does do more work before a pod starts. If you need low-latency execution you'll have to use long-running worker processes of some form. Once it's started, it should be just as fast.
On Fri, Jun 2, 2017 at 2:13 PM Diego Lapiduz <di...@lapiduz.com> wrote:
This is a very short lived task (just runs `echo hello`) so the only thing I really care about is getting that `hello` back.

This is what I did in text format:

```
➜  eval $(minikube docker-env)

➜  time docker run dlapiduz/hello-world

hello
docker run dlapiduz/hello-world  0.07s user 0.02s system 30% cpu 0.318 total
➜  time kubectl run --image=dlapiduz/hello-world test --attach --restart=Never
Waiting for pod default/test to be running, status is Pending, pod ready: false
hello
kubectl run --image=dlapiduz/hello-world test --attach --restart=Never  0.09s user 0.02s system 7% cpu 1.357 total
```

On Thu, Jun 1, 2017 at 11:27 PM, 'Tim Hockin' via Kubernetes user discussion and Q&A <kubernetes-users@googlegroups.com> wrote:
It runs faster or it starts faster?  The gif clear too quickly for me to see.
On Thu, Jun 1, 2017 at 9:09 PM, Diego Lapiduz <di...@lapiduz.com> wrote:
Hi y'all, (k8s noob here so forgive me if this is something that I am doing obviously wrong)

I am trying to run a short lived task and I am trying to move from Docker Swarm to Kubernetes. An interesting issue that I am finding is that running the same Docker image on the same minikube cluster is much faster using the docker cli tool (or docker api) than kubectl.

Here is a quick screen cap: I know that I am probably doing something off, any idea what it could be? Thanks!






--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-users+unsubscribe@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kubernetes-users/MArCwIOYWo0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kubernetes-users+unsubscribe@googlegroups.com.

To post to this group, send email to kubernetes-users@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-users+unsubscribe@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kubernetes-users/MArCwIOYWo0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kubernetes-users+unsubscribe@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.

Warren Strange

unread,
Jun 2, 2017, 12:40:26 PM6/2/17
to Kubernetes user discussion and Q&A

To echo what Matthias has said, Kubernetes is doing a lot more housekeeping work behind the scenes than just docker run. 

You can see Kube is adding about one second of overhead. If your containers typically run for a just a second or two, that is probably not a good fit for Kube (or even docker, for that matter).   Some kind of worker model would be a better approach.



On Friday, June 2, 2017 at 8:41:23 AM UTC-6, Diego Lapiduz wrote:
Thanks Matthias, yes this is a bit of a problem for my use case. Ideally I'd like to run a fresh container every time that is why I am trying to do this.
The weird thing is that Kubernetes is the backend in both cases, I am just using the Docker API in one case and the kubernetes one in the other. Not sure what the difference is but there should be a way to replicate what docker run is doing with kubectl (or their API equivalents).
On Fri, Jun 2, 2017 at 9:38 AM, Matthias Rampke <m...@soundcloud.com> wrote:
Is this difference a problem for your use case? Kubernetes does do more work before a pod starts. If you need low-latency execution you'll have to use long-running worker processes of some form. Once it's started, it should be just as fast.
On Fri, Jun 2, 2017 at 2:13 PM Diego Lapiduz <di...@lapiduz.com> wrote:
This is a very short lived task (just runs `echo hello`) so the only thing I really care about is getting that `hello` back.

This is what I did in text format:

```
➜  eval $(minikube docker-env)

➜  time docker run dlapiduz/hello-world

hello
docker run dlapiduz/hello-world  0.07s user 0.02s system 30% cpu 0.318 total
➜  time kubectl run --image=dlapiduz/hello-world test --attach --restart=Never
Waiting for pod default/test to be running, status is Pending, pod ready: false
hello
kubectl run --image=dlapiduz/hello-world test --attach --restart=Never  0.09s user 0.02s system 7% cpu 1.357 total
```

On Thu, Jun 1, 2017 at 11:27 PM, 'Tim Hockin' via Kubernetes user discussion and Q&A <kubernet...@googlegroups.com> wrote:
It runs faster or it starts faster?  The gif clear too quickly for me to see.
On Thu, Jun 1, 2017 at 9:09 PM, Diego Lapiduz <di...@lapiduz.com> wrote:
Hi y'all, (k8s noob here so forgive me if this is something that I am doing obviously wrong)

I am trying to run a short lived task and I am trying to move from Docker Swarm to Kubernetes. An interesting issue that I am finding is that running the same Docker image on the same minikube cluster is much faster using the docker cli tool (or docker api) than kubectl.

Here is a quick screen cap: I know that I am probably doing something off, any idea what it could be? Thanks!






--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kubernetes-users/MArCwIOYWo0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kubernetes-use...@googlegroups.com.

To post to this group, send email to kubernet...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kubernetes-users/MArCwIOYWo0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.

Tim Hockin

unread,
Jun 2, 2017, 1:11:07 PM6/2/17
to Kubernetes user discussion and Q&A
To refine this.  Kubectl does an API call.  That API call does an etcd write and sync. Then the API has to notify the watching kubelet, which has to ultimately do that docker run.  

So, by definition, it can't be as fast because kunernetes is an async decoupling ON TOP of the thing you're benchmarking.

Additionally, I think kubectl polls for status, so even if it didn't actually take longer, you wouldn't see that in this test.


To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-users+unsubscribe@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.

Ahmet Alp Balkan

unread,
Jun 2, 2017, 7:27:01 PM6/2/17
to kubernet...@googlegroups.com
On Fri, Jun 2, 2017 at 7:40 AM, Diego Lapiduz <di...@lapiduz.com> wrote:
The weird thing is that Kubernetes is the backend in both cases, I am just using the Docker API in one case and the kubernetes one in the other.

To be clear, the statement that you're using Kubernetes backend in both cases is incorrect. When you eval "$(minikube docker-env)" and run "docker" commands, you are not using Kubernetes at all. You're directly talking to the docker engine provided on the Minikube instance for Kubernetes to be able to launch containers.

Diego Lapiduz

unread,
Jun 2, 2017, 9:40:58 PM6/2/17
to kubernet...@googlegroups.com
Thanks Tim and Ahmet, that is exactly what I was looking for. I am basically circumventing kubernetes and going straight to the minimize backend. 

Now everything makes sense. 

To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kubernetes-users/MArCwIOYWo0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kubernetes-use...@googlegroups.com.

To post to this group, send email to kubernet...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kubernetes-users/MArCwIOYWo0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kubernetes-users/MArCwIOYWo0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages