mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #4025 from ironcladlou/replica-annotations
Backport annotations to PodTemplateSpec
This commit is contained in:
commit
0474c49b07
@ -418,6 +418,9 @@ func init() {
|
|||||||
if err := s.Convert(&in.ObjectMeta.Labels, &out.Labels, 0); err != nil {
|
if err := s.Convert(&in.ObjectMeta.Labels, &out.Labels, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := s.Convert(&in.ObjectMeta.Annotations, &out.Annotations, 0); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
func(in *PodTemplate, out *newer.PodTemplateSpec, s conversion.Scope) error {
|
func(in *PodTemplate, out *newer.PodTemplateSpec, s conversion.Scope) error {
|
||||||
@ -431,6 +434,9 @@ func init() {
|
|||||||
if err := s.Convert(&in.Labels, &out.ObjectMeta.Labels, 0); err != nil {
|
if err := s.Convert(&in.Labels, &out.ObjectMeta.Labels, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := s.Convert(&in.Annotations, &out.ObjectMeta.Annotations, 0); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -493,6 +493,7 @@ type PodTemplate struct {
|
|||||||
DesiredState PodState `json:"desiredState,omitempty" description:"specification of the desired state of pods created from this template"`
|
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"`
|
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"`
|
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
|
// Session Affinity Type string
|
||||||
|
@ -282,6 +282,9 @@ func init() {
|
|||||||
if err := s.Convert(&in.ObjectMeta.Labels, &out.Labels, 0); err != nil {
|
if err := s.Convert(&in.ObjectMeta.Labels, &out.Labels, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := s.Convert(&in.ObjectMeta.Annotations, &out.Annotations, 0); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
func(in *PodTemplate, out *newer.PodTemplateSpec, s conversion.Scope) error {
|
func(in *PodTemplate, out *newer.PodTemplateSpec, s conversion.Scope) error {
|
||||||
@ -295,6 +298,9 @@ func init() {
|
|||||||
if err := s.Convert(&in.Labels, &out.ObjectMeta.Labels, 0); err != nil {
|
if err := s.Convert(&in.Labels, &out.ObjectMeta.Labels, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := s.Convert(&in.Annotations, &out.ObjectMeta.Annotations, 0); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
// Converts internal Container to v1beta1.Container.
|
// Converts internal Container to v1beta1.Container.
|
||||||
|
@ -457,6 +457,7 @@ type PodTemplate struct {
|
|||||||
DesiredState PodState `json:"desiredState,omitempty" description:"specification of the desired state of pods created from this template"`
|
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"`
|
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"`
|
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
|
// Session Affinity Type string
|
||||||
|
@ -61,6 +61,10 @@ func (r RealPodControl) createReplica(namespace string, controller api.Replicati
|
|||||||
for k, v := range controller.Spec.Template.Labels {
|
for k, v := range controller.Spec.Template.Labels {
|
||||||
desiredLabels[k] = v
|
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
|
// use the dash (if the name isn't too long) to make the pod name a bit prettier
|
||||||
prefix := fmt.Sprintf("%s-", controller.Name)
|
prefix := fmt.Sprintf("%s-", controller.Name)
|
||||||
@ -71,6 +75,7 @@ func (r RealPodControl) createReplica(namespace string, controller api.Replicati
|
|||||||
pod := &api.Pod{
|
pod := &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Labels: desiredLabels,
|
Labels: desiredLabels,
|
||||||
|
Annotations: desiredAnnotations,
|
||||||
GenerateName: prefix,
|
GenerateName: prefix,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user