mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
kubectl: fix 'create deployment' to set container name correctly
This commit is contained in:
@@ -67,8 +67,15 @@ func (s *DeploymentBasicGeneratorV1) StructuredGenerate() (runtime.Object, error
|
||||
|
||||
podSpec := api.PodSpec{Containers: []api.Container{}}
|
||||
for _, imageString := range s.Images {
|
||||
// Retain just the image name
|
||||
imageSplit := strings.Split(imageString, "/")
|
||||
name := imageSplit[len(imageSplit)-1]
|
||||
// Remove any tag or hash
|
||||
if strings.Contains(name, ":") {
|
||||
name = strings.Split(name, ":")[0]
|
||||
} else if strings.Contains(name, "@") {
|
||||
name = strings.Split(name, "@")[0]
|
||||
}
|
||||
podSpec.Containers = append(podSpec.Containers, api.Container{Name: name, Image: imageString})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user