mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Merge pull request #18618 from mesosphere/sur-697-annotations
Auto commit by PR queue bot
This commit is contained in:
commit
6f2351b981
@ -34,4 +34,5 @@ const (
|
|||||||
PortNameMappingKeyFormat = PortNameMappingKeyPrefix + "%s_%s"
|
PortNameMappingKeyFormat = PortNameMappingKeyPrefix + "%s_%s"
|
||||||
ContainerPortKeyFormat = "k8s.mesosphere.io/containerPort_%s_%s_%d"
|
ContainerPortKeyFormat = "k8s.mesosphere.io/containerPort_%s_%s_%d"
|
||||||
StaticPodFilenameKey = "k8s.mesosphere.io/staticPodFilename"
|
StaticPodFilenameKey = "k8s.mesosphere.io/staticPodFilename"
|
||||||
|
RolesKey = "k8s.mesosphere.io/roles"
|
||||||
)
|
)
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2015 The Kubernetes Authors All rights reserved.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package meta
|
|
||||||
|
|
||||||
// kubernetes api object labels
|
|
||||||
const (
|
|
||||||
RolesKey = "k8s.mesosphere.io/roles"
|
|
||||||
)
|
|
@ -170,10 +170,10 @@ func (t *T) Has(f FlagType) (exists bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Roles returns the valid roles under which this pod task can be scheduled.
|
// Roles returns the valid roles under which this pod task can be scheduled.
|
||||||
// If the pod has roles labels defined they are being used
|
// If the pod has roles annotations defined they are being used
|
||||||
// else default pod roles are being returned.
|
// else default pod roles are being returned.
|
||||||
func (t *T) Roles() []string {
|
func (t *T) Roles() (result []string) {
|
||||||
if r, ok := t.Pod.ObjectMeta.Labels[annotation.RolesKey]; ok {
|
if r, ok := t.Pod.ObjectMeta.Annotations[annotation.RolesKey]; ok {
|
||||||
roles := strings.Split(r, ",")
|
roles := strings.Split(r, ",")
|
||||||
|
|
||||||
for i, r := range roles {
|
for i, r := range roles {
|
||||||
|
@ -56,7 +56,7 @@ func TestRoles(t *testing.T) {
|
|||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
for i, tt := range []struct {
|
for i, tt := range []struct {
|
||||||
labels map[string]string
|
annotations map[string]string
|
||||||
frameworkRoles []string
|
frameworkRoles []string
|
||||||
want []string
|
want []string
|
||||||
}{
|
}{
|
||||||
@ -105,7 +105,7 @@ func TestRoles(t *testing.T) {
|
|||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
task := fakePodTask("test", tt.frameworkRoles, starRole)
|
task := fakePodTask("test", tt.frameworkRoles, starRole)
|
||||||
task.Pod.ObjectMeta.Labels = tt.labels
|
task.Pod.ObjectMeta.Annotations = tt.annotations
|
||||||
assert.True(reflect.DeepEqual(task.Roles(), tt.want), "test #%d got %#v want %#v", i, task.Roles(), tt.want)
|
assert.True(reflect.DeepEqual(task.Roles(), tt.want), "test #%d got %#v want %#v", i, task.Roles(), tt.want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ var _ = Describe("Mesos", func() {
|
|||||||
fmt.Sprintf("number of static pods in namespace %s is %d", ns, numpods))
|
fmt.Sprintf("number of static pods in namespace %s is %d", ns, numpods))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("schedules pods labelled with roles on correct slaves", func() {
|
It("schedules pods annotated with roles on correct slaves", func() {
|
||||||
// launch a pod to find a node which can launch a pod. We intentionally do
|
// launch a pod to find a node which can launch a pod. We intentionally do
|
||||||
// not just take the node list and choose the first of them. Depending on the
|
// not just take the node list and choose the first of them. Depending on the
|
||||||
// cluster and the scheduler it might be that a "normal" pod cannot be
|
// cluster and the scheduler it might be that a "normal" pod cannot be
|
||||||
@ -86,7 +86,7 @@ var _ = Describe("Mesos", func() {
|
|||||||
},
|
},
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: podName,
|
Name: podName,
|
||||||
Labels: map[string]string{
|
Annotations: map[string]string{
|
||||||
"k8s.mesosphere.io/roles": "public",
|
"k8s.mesosphere.io/roles": "public",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user