pods using a specific aws instance type

818 views
Skip to first unread message

Norman Khine

unread,
Aug 25, 2016, 3:13:26 PM8/25/16
to Kubernetes user discussion and Q&A
hello,
i have couple of worker instances some are c4.large and others i2.xlarge what is the correct way to run specific pods in one instance type?

any advice much appreciated

David Oppenheimer

unread,
Aug 25, 2016, 3:48:06 PM8/25/16
to kubernet...@googlegroups.com
When you're running on GCE, GKE, or AWS, your nodes will be automatically given a label with key "beta.kubernetes.io/instance-type" and value being the instance type. So you can use node selectors to do what you want; see http://kubernetes.io/docs/user-guide/node-selection/

--
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.

Norman Khine

unread,
Aug 25, 2016, 4:53:48 PM8/25/16
to kubernet...@googlegroups.com
so something like:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: my-app
  labels:
    pod: app
  annotations:
    scheduler.alpha.kubernetes.io/affinity: >
      {
        "nodeAffinity": {
          "requiredDuringSchedulingIgnoredDuringExecution": {
            "nodeSelectorTerms": [
              {
                "matchExpressions": [
                  {
                    "key": "beta.kubernetes.io/instance-type",
                    "operator": "In",
                    "values": ["c4.large"]
                  }
                ]
              }
            ]
          }
        }
      }
spec:
  replicas: 1
  template:
    metadata:
      labels:
        pod: app
    spec:
      containers:
        - image: redis
          name: "redis"
          ports:
            - containerPort: 6379

--
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/_pEAEb9T_ck/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.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.



--
%>>> "".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-83)%26) for c in ",adym,*)&uzq^zqf" ] )

Brandon Philips

unread,
Aug 25, 2016, 5:28:20 PM8/25/16
to kubernet...@googlegroups.com
Yes, this looks roughly right. Did it work? We should probably write a doc on this.

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/_pEAEb9T_ck/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.



--
%>>> "".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-83)%26) for c in ",adym,*)&uzq^zqf" ] )

--
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.

Norman Khine

unread,
Aug 25, 2016, 6:03:07 PM8/25/16
to kubernet...@googlegroups.com
is there a way to find out on which nodes did the pods got deployed from kubectl?

On 25 August 2016 at 20:48, 'David Oppenheimer' via Kubernetes user discussion and Q&A <kubernetes-users@googlegroups.com> wrote:
When you're running on GCE, GKE, or AWS, your nodes will be automatically given a label with key "beta.kubernetes.io/instance-type" and value being the instance type. So you can use node selectors to do what you want; see http://kubernetes.io/docs/user-guide/node-selection/
On Thu, Aug 25, 2016 at 12:13 PM, Norman Khine <nor...@khine.net> wrote:
hello,
i have couple of worker instances some are c4.large and others i2.xlarge what is the correct way to run specific pods in one instance type?

any advice much appreciated

--
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/_pEAEb9T_ck/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.



--
%>>> "".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-83)%26) for c in ",adym,*)&uzq^zqf" ] )

--
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/_pEAEb9T_ck/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.

Norman Khine

unread,
Aug 25, 2016, 6:22:53 PM8/25/16
to kubernet...@googlegroups.com
i can check the IP addresses 

➜  trint-boto git:(master) kubectl get pods -o wide                            
NAME                         READY     STATUS             RESTARTS   AGE       IP          NODE
busybox                      1/1       Running            3          3h        10.2.91.4   ip-10-0-13-102.ec2.internal
dd-agent-2u9d0               1/1       Running            0          59m       10.2.48.3   ip-10-0-10-185.ec2.internal
logspout-xknw9               1/1       Running            0          59m       10.2.39.4   ip-10-0-11-129.ec2.internal
trint-app-3504655228-50x8q   3/3       Running            0          1m        10.2.3.5    ip-10-0-10-210.ec2.internal
trint-app-3504655228-5p109   3/3       Running            0          1m        10.2.88.8   ip-10-0-13-90.ec2.internal
trint-app-3504655228-a4ovh   3/3       Running            0          1m        10.2.53.6   ip-10-0-11-108.ec2.internal
trint-app-3504655228-bjo0l   3/3       Running            0          1h        10.2.53.3   ip-10-0-11-108.ec2.internal
trint-app-3504655228-i6kb8   3/3       Running            0          1m        10.2.3.6    ip-10-0-10-210.ec2.internal
trint-app-3504655228-n7hys   3/3       Running            0          1m        10.2.71.5   ip-10-0-12-107.ec2.internal
trint-app-3504655228-nn43h   3/3       Running            0          1m        10.2.48.5   ip-10-0-10-185.ec2.internal
trint-app-3504655228-t4yd9   3/3       Running            0          1m        10.2.91.9   ip-10-0-13-102.ec2.internal
trint-app-3504655228-xvx6c   3/3       Running            0          1m        10.2.39.5   ip-10-0-11-129.ec2.internal

also, if i also want to ensure that the pods don't land on an etcd node, so for example not an instance-type: c3.large and not name: etcd-* how is this done?

David Oppenheimer

unread,
Aug 28, 2016, 4:48:59 PM8/28/16
to kubernet...@googlegroups.com
On Thu, Aug 25, 2016 at 2:28 PM, Brandon Philips <brandon...@coreos.com> wrote:
Yes, this looks roughly right. Did it work? We should probably write a doc on this.

When I suggested node selector I had in mind the simple key/value-pair version we've had since version 1.0 (nodeSelector field of PodSpec), which is sufficient for this use case. In any event, both that and the node affinity annotation are documented on the page I mentioned, and I have an update in-flight for that page that adds documentation for pod affinity (though pod affinity is not relevant to this question).


On 25 August 2016 at 20:48, 'David Oppenheimer' via Kubernetes user discussion and Q&A <kubernetes-users@googlegroups.com> wrote:
When you're running on GCE, GKE, or AWS, your nodes will be automatically given a label with key "beta.kubernetes.io/instance-type" and value being the instance type. So you can use node selectors to do what you want; see http://kubernetes.io/docs/user-guide/node-selection/
On Thu, Aug 25, 2016 at 12:13 PM, Norman Khine <nor...@khine.net> wrote:
hello,
i have couple of worker instances some are c4.large and others i2.xlarge what is the correct way to run specific pods in one instance type?

any advice much appreciated

--
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/_pEAEb9T_ck/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.



--
%>>> "".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-83)%26) for c in ",adym,*)&uzq^zqf" ] )

--
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 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.

David Oppenheimer

unread,
Aug 28, 2016, 4:57:01 PM8/28/16
to kubernet...@googlegroups.com
if i also want to ensure that the pods don't land on an etcd node, so for example not an instance-type: c3.large and not name: etcd-* how is this done?

You can't filter nodes based on node name, only on node labels. So you need to label the etcd nodes (you could just put a label with key "etcd" and no value -- see "kubectl label"), and then you can use nodeAffinity like you did earlier, but this time have both "beta.kubernetes.io/instance-type in c3.large" and "etcd exists" as rules in the nodeAffinity specification.

Tim Hockin

unread,
Aug 28, 2016, 8:21:12 PM8/28/16
to kubernet...@googlegroups.com

I feel obligated to ask why?  If it is about resources like CPU and RAM you should use the resources section of your pod, and we'll find an appropriate home for it.


--

Norman Khine

unread,
Aug 29, 2016, 4:15:21 AM8/29/16
to kubernet...@googlegroups.com
Hi,
i have a mongo cluster that uses the i2.xlarge instances and did not want the api worker instances to be deployed there as these don't need such big machines. also as i am using coreos with k8s and did not want any pods landing on the etcd machines.

--
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/_pEAEb9T_ck/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.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.

Tim Hockin

unread,
Aug 29, 2016, 5:15:19 PM8/29/16
to kubernet...@googlegroups.com
You can manage this all by hand, as you are doing, or you can use
resources to manage it. For example, if you have 32 core machines,
and mongo needs lots of beef, set the mongo CPU requirement to 31
cores. Nothing else should land there except best-effort work, which
is lower priority anyway.

This is a major shift in how to think about your workloads, I
understand. Stop thinking about machines and start thinking about how
much CPU and memory you actually need to run your apps.

On Mon, Aug 29, 2016 at 1:15 AM, Norman Khine <nor...@khine.net> wrote:
> Hi,
> i have a mongo cluster that uses the i2.xlarge instances and did not want
> the api worker instances to be deployed there as these don't need such big
> machines. also as i am using coreos with k8s and did not want any pods
> landing on the etcd machines.
>
> On 29 August 2016 at 01:21, 'Tim Hockin' via Kubernetes user discussion and
> Q&A <kubernet...@googlegroups.com> wrote:
>>
>> I feel obligated to ask why? If it is about resources like CPU and RAM
>> you should use the resources section of your pod, and we'll find an
>> appropriate home for it.
>>
>>
>> On Aug 25, 2016 12:13 PM, "Norman Khine" <nor...@khine.net> wrote:
>>>
>>> hello,
>>> i have couple of worker instances some are c4.large and others i2.xlarge
>>> what is the correct way to run specific pods in one instance type?
>>>
>>> any advice much appreciated
>>>
>>> --
>>> 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.
>>> Visit this group at https://groups.google.com/group/kubernetes-users.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> 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/_pEAEb9T_ck/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.
>> Visit this group at https://groups.google.com/group/kubernetes-users.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> %>>> "".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-83)%26) for
> c in ",adym,*)&uzq^zqf" ] )
>
> --
> 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.
Reply all
Reply to author
Forward
0 new messages