mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-20 09:33:52 +00:00
createPod should copy the labels, not edit them in place
This commit is contained in:
@@ -53,18 +53,20 @@ type RealPodControl struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r RealPodControl) createReplica(ctx api.Context, controllerSpec api.ReplicationController) {
|
func (r RealPodControl) createReplica(ctx api.Context, controllerSpec api.ReplicationController) {
|
||||||
labels := controllerSpec.DesiredState.PodTemplate.Labels
|
desiredLabels := make(labels.Set)
|
||||||
// TODO: don't fail to set this label just because the map isn't created.
|
for k, v := range controllerSpec.DesiredState.PodTemplate.Labels {
|
||||||
if labels != nil {
|
desiredLabels[k] = v
|
||||||
labels["replicationController"] = controllerSpec.Name
|
|
||||||
}
|
}
|
||||||
|
desiredLabels["replicationController"] = controllerSpec.Name
|
||||||
|
|
||||||
pod := &api.Pod{
|
pod := &api.Pod{
|
||||||
|
ObjectMeta: api.ObjectMeta{
|
||||||
|
Labels: desiredLabels,
|
||||||
|
},
|
||||||
DesiredState: controllerSpec.DesiredState.PodTemplate.DesiredState,
|
DesiredState: controllerSpec.DesiredState.PodTemplate.DesiredState,
|
||||||
Labels: controllerSpec.DesiredState.PodTemplate.Labels,
|
|
||||||
}
|
}
|
||||||
_, err := r.kubeClient.CreatePod(ctx, pod)
|
if _, err := r.kubeClient.CreatePod(ctx, pod); err != nil {
|
||||||
if err != nil {
|
glog.Errorf("Unable to create pod replica: %v", err)
|
||||||
glog.Errorf("%#v\n", err)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user