mirror of
https://github.com/containers/podman.git
synced 2025-11-29 01:28:22 +08:00
add option to remove Pod name prefix in resulting container name
Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com>
This commit is contained in:
@@ -205,6 +205,9 @@ func playFlags(cmd *cobra.Command) {
|
||||
exitFlagName := "service-exit-code-propagation"
|
||||
flags.StringVar(&playOptions.ExitCodePropagation, exitFlagName, "", "Exit-code propagation of the service container")
|
||||
_ = flags.MarkHidden(exitFlagName)
|
||||
|
||||
noPodPrefix := "no-pod-prefix"
|
||||
flags.BoolVar(&playOptions.NoPodPrefix, noPodPrefix, false, "Don't use pod name as prefix in resulting container name.")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -260,6 +260,10 @@ When no network option is specified and *host* network mode is not configured in
|
||||
|
||||
This option conflicts with host added in the Kubernetes YAML.
|
||||
|
||||
#### **--no-pod-prefix**
|
||||
|
||||
Don't use pod name as prefix in resulting container name.
|
||||
|
||||
#### **--publish**=*[[ip:][hostPort]:]containerPort[/protocol]*
|
||||
|
||||
Define or override a port definition in the YAML file.
|
||||
|
||||
@@ -81,6 +81,8 @@ type PlayKubeOptions struct {
|
||||
Wait bool
|
||||
// SystemContext - used when building the image
|
||||
SystemContext *types.SystemContext
|
||||
// Don't use pod name as prefix in resulting container name.
|
||||
NoPodPrefix bool
|
||||
}
|
||||
|
||||
// PlayKubePod represents a single pod and associated containers created by play kube
|
||||
|
||||
@@ -1089,6 +1089,7 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
|
||||
VolumesFrom: volumesFrom,
|
||||
ImageVolumes: automountImages,
|
||||
UtsNSIsHost: p.UtsNs.IsHost(),
|
||||
NoPodPrefix: options.NoPodPrefix,
|
||||
}
|
||||
|
||||
if podYAML.Spec.TerminationGracePeriodSeconds != nil {
|
||||
|
||||
@@ -185,6 +185,8 @@ type CtrSpecGenOptions struct {
|
||||
PodSecurityContext *v1.PodSecurityContext
|
||||
// TerminationGracePeriodSeconds is the grace period given to a container to stop before being forcefully killed
|
||||
TerminationGracePeriodSeconds *int64
|
||||
// Don't use pod name as prefix in resulting container name.
|
||||
NoPodPrefix bool
|
||||
}
|
||||
|
||||
func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGenerator, error) {
|
||||
@@ -217,7 +219,11 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener
|
||||
return nil, errors.New("got empty pod name on container creation when playing kube")
|
||||
}
|
||||
|
||||
if opts.NoPodPrefix {
|
||||
s.Name = opts.Container.Name
|
||||
} else {
|
||||
s.Name = fmt.Sprintf("%s-%s", opts.PodName, opts.Container.Name)
|
||||
}
|
||||
|
||||
s.Terminal = &opts.Container.TTY
|
||||
|
||||
|
||||
Reference in New Issue
Block a user