[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Trick to update in go a DeploymentConfig



Hi,

When I use the following code, then the data of the original deploymentConfig are nto merged with the new PodTemplateSpec created

Do we have to do a deepcopy of the dc before to update it ?

for _, d := range deploymentList.Items {
fmt.Printf("%s\n", d.Name)
dc, err := deploymentConfigV1client.DeploymentConfigs(namespace).Get(d.Name,metav1.GetOptions{})
if err != nil {
glog.Error("Error to get the Deployment Config %s. Error is : %s\n", dc.Name, err)
}
dc.Spec.Template = supervisordInitContainer() // ORIGINAL DATA ARE GONE !!!! 
updateddc, err := deploymentConfigV1client.DeploymentConfigs(namespace).Update(dc)
if err != nil {
glog.Error("Error to update the Deployment Config %s. Error is : %s\n", updateddc.Name, err)
}
//fmt.Printf("Raw printout of the dc %+v\n", d)
}
}

func supervisordInitContainer() *corev1.PodTemplateSpec {
return &corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"app":              "spring-boot-supervisord",
"deploymentconfig": "spring-boot-supervisord",
},
},
Spec: corev1.PodSpec{
Volumes: []corev1.Volume{
{
Name: "shared-data",
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{},
},
},
},
InitContainers: []corev1.Container{
{
Name:    "copy-supervisord",
Image:   "docker/dd/dd",
Command: []string{"/usr/bin/cp"},
Args:    []string{"-r", "/opt/supervisord", " /var/lib/"},
VolumeMounts: []corev1.VolumeMount{
{
Name:      "shared-data",
MountPath: "/var/lib/supervisord",
},
},
},
},
},
}

Regards

Charles

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]