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

Backport annotations to PodTemplateSpec #4025

Merged
merged 1 commit into from
Feb 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/api/v1beta1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,9 @@ func init() {
if err := s.Convert(&in.ObjectMeta.Labels, &out.Labels, 0); err != nil {
return err
}
if err := s.Convert(&in.ObjectMeta.Annotations, &out.Annotations, 0); err != nil {
return err
}
return nil
},
func(in *PodTemplate, out *newer.PodTemplateSpec, s conversion.Scope) error {
Expand All @@ -431,6 +434,9 @@ func init() {
if err := s.Convert(&in.Labels, &out.ObjectMeta.Labels, 0); err != nil {
return err
}
if err := s.Convert(&in.Annotations, &out.ObjectMeta.Annotations, 0); err != nil {
return err
}
return nil
},

Expand Down
1 change: 1 addition & 0 deletions pkg/api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ type PodTemplate struct {
DesiredState PodState `json:"desiredState,omitempty" description:"specification of the desired state of pods created from this template"`
NodeSelector map[string]string `json:"nodeSelector,omitempty" description:"a selector which must be true for the pod to fit on a node"`
Labels map[string]string `json:"labels,omitempty" description:"map of string keys and values that can be used to organize and categorize the pods created from the template; must match the selector of the replication controller to which the template belongs; may match selectors of services"`
Annotations map[string]string `json:"annotations,omitempty" description:"map of string keys and values that can be used by external tooling to store and retrieve arbitrary metadata about pods created from the template"`
}

// Session Affinity Type string
Expand Down
6 changes: 6 additions & 0 deletions pkg/api/v1beta2/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ func init() {
if err := s.Convert(&in.ObjectMeta.Labels, &out.Labels, 0); err != nil {
return err
}
if err := s.Convert(&in.ObjectMeta.Annotations, &out.Annotations, 0); err != nil {
return err
}
return nil
},
func(in *PodTemplate, out *newer.PodTemplateSpec, s conversion.Scope) error {
Expand All @@ -295,6 +298,9 @@ func init() {
if err := s.Convert(&in.Labels, &out.ObjectMeta.Labels, 0); err != nil {
return err
}
if err := s.Convert(&in.Annotations, &out.ObjectMeta.Annotations, 0); err != nil {
return err
}
return nil
},
// Converts internal Container to v1beta1.Container.
Expand Down
1 change: 1 addition & 0 deletions pkg/api/v1beta2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ type PodTemplate struct {
DesiredState PodState `json:"desiredState,omitempty" description:"specification of the desired state of pods created from this template"`
NodeSelector map[string]string `json:"nodeSelector,omitempty" description:"a selector which must be true for the pod to fit on a node"`
Labels map[string]string `json:"labels,omitempty" description:"map of string keys and values that can be used to organize and categorize the pods created from the template; must match the selector of the replication controller to which the template belongs; may match selectors of services"`
Annotations map[string]string `json:"annotations,omitempty" description:"map of string keys and values that can be used by external tooling to store and retrieve arbitrary metadata about pods created from the template"`
}

// Session Affinity Type string
Expand Down
5 changes: 5 additions & 0 deletions pkg/controller/replication_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ func (r RealPodControl) createReplica(namespace string, controller api.Replicati
for k, v := range controller.Spec.Template.Labels {
desiredLabels[k] = v
}
desiredAnnotations := make(labels.Set)
for k, v := range controller.Spec.Template.Annotations {
desiredAnnotations[k] = v
}

// use the dash (if the name isn't too long) to make the pod name a bit prettier
prefix := fmt.Sprintf("%s-", controller.Name)
Expand All @@ -71,6 +75,7 @@ func (r RealPodControl) createReplica(namespace string, controller api.Replicati
pod := &api.Pod{
ObjectMeta: api.ObjectMeta{
Labels: desiredLabels,
Annotations: desiredAnnotations,
GenerateName: prefix,
},
}
Expand Down