diff options
author | Chen Zhiwei <zhiweik@gmail.com> | 2019-08-17 02:42:36 +0000 |
---|---|---|
committer | Chen Zhiwei <zhiweik@gmail.com> | 2019-08-18 03:48:40 +0000 |
commit | 7aefc1ac33ba153f6177e9fe3c4da886de49a9e2 (patch) | |
tree | fdd2f01237c17263ea06655321696ac3f9f754e0 /pkg/adapter | |
parent | 8eab96ec3afdc04c02b5ea1c2067e4a36c14c783 (diff) | |
download | podman-7aefc1ac33ba153f6177e9fe3c4da886de49a9e2.tar.gz podman-7aefc1ac33ba153f6177e9fe3c4da886de49a9e2.tar.bz2 podman-7aefc1ac33ba153f6177e9fe3c4da886de49a9e2.zip |
Allow customizing pod hostname
* set hostname in pod yaml file
* set --hostname in pod create command
Signed-off-by: Chen Zhiwei <zhiweik@gmail.com>
Diffstat (limited to 'pkg/adapter')
-rw-r--r-- | pkg/adapter/pods.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/pkg/adapter/pods.go b/pkg/adapter/pods.go index 2743dfdc6..87092b458 100644 --- a/pkg/adapter/pods.go +++ b/pkg/adapter/pods.go @@ -255,6 +255,10 @@ func (r *LocalRuntime) CreatePod(ctx context.Context, cli *cliconfig.PodCreateVa options = append(options, libpod.WithPodName(cli.Name)) } + if cli.Flag("hostname").Changed { + options = append(options, libpod.WithPodHostname(cli.Hostname)) + } + if cli.Infra { options = append(options, libpod.WithInfraContainer()) nsOptions, err := shared.GetNamespaceOptions(strings.Split(cli.Share, ",")) @@ -475,6 +479,12 @@ func (r *LocalRuntime) PlayKubeYAML(ctx context.Context, c *cliconfig.KubePlayVa podOptions = append(podOptions, libpod.WithPodName(podName)) // TODO for now we just used the default kernel namespaces; we need to add/subtract this from yaml + hostname := podYAML.Spec.Hostname + if hostname == "" { + hostname = podName + } + podOptions = append(podOptions, libpod.WithPodHostname(hostname)) + nsOptions, err := shared.GetNamespaceOptions(strings.Split(shared.DefaultKernelNamespaces, ",")) if err != nil { return nil, err |