summaryrefslogtreecommitdiff
path: root/cmd/podman/play
diff options
context:
space:
mode:
authorPaul Holzinger <paul.holzinger@web.de>2021-05-04 17:06:57 +0200
committerPaul Holzinger <paul.holzinger@web.de>2021-05-04 20:14:13 +0200
commitfb7d16c7a841bbe2c02cb97b2820334b617e7f44 (patch)
treebb82d46a3565624611c0696ef51efd903e82e6c1 /cmd/podman/play
parentdea6189982b4d128aa1ae9ce379a1f94b4eb8a8f (diff)
downloadpodman-fb7d16c7a841bbe2c02cb97b2820334b617e7f44.tar.gz
podman-fb7d16c7a841bbe2c02cb97b2820334b617e7f44.tar.bz2
podman-fb7d16c7a841bbe2c02cb97b2820334b617e7f44.zip
add --mac-address to podman play kube
Add a new --mac-address flag to podman play kube. This is used to specify a static MAC address which should be used for the pod. This option can be specified several times because play kube can create more than one pod. Fixes #9731 Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Diffstat (limited to 'cmd/podman/play')
-rw-r--r--cmd/podman/play/kube.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/cmd/podman/play/kube.go b/cmd/podman/play/kube.go
index 30d6d86f0..fe382bdfb 100644
--- a/cmd/podman/play/kube.go
+++ b/cmd/podman/play/kube.go
@@ -2,6 +2,7 @@ package pods
import (
"fmt"
+ "net"
"os"
"github.com/containers/common/pkg/auth"
@@ -27,6 +28,7 @@ type playKubeOptionsWrapper struct {
}
var (
+ macs []string
// https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/
defaultSeccompRoot = "/var/lib/kubelet/seccomp"
kubeOptions = playKubeOptionsWrapper{}
@@ -61,6 +63,10 @@ func init() {
flags.StringVar(&kubeOptions.CredentialsCLI, credsFlagName, "", "`Credentials` (USERNAME:PASSWORD) to use for authenticating to a registry")
_ = kubeCmd.RegisterFlagCompletionFunc(credsFlagName, completion.AutocompleteNone)
+ staticMACFlagName := "mac-address"
+ flags.StringSliceVar(&macs, staticMACFlagName, nil, "Static MAC addresses to assign to the pods")
+ _ = kubeCmd.RegisterFlagCompletionFunc(staticMACFlagName, completion.AutocompleteNone)
+
networkFlagName := "network"
flags.StringVar(&kubeOptions.Network, networkFlagName, "", "Connect pod to CNI network(s)")
_ = kubeCmd.RegisterFlagCompletionFunc(networkFlagName, common.AutocompleteNetworkFlag)
@@ -128,6 +134,15 @@ func kube(cmd *cobra.Command, args []string) error {
if yamlfile == "-" {
yamlfile = "/dev/stdin"
}
+
+ for _, mac := range macs {
+ m, err := net.ParseMAC(mac)
+ if err != nil {
+ return err
+ }
+ kubeOptions.StaticMACs = append(kubeOptions.StaticMACs, m)
+ }
+
report, err := registry.ContainerEngine().PlayKube(registry.GetContext(), yamlfile, kubeOptions.PlayKubeOptions)
if err != nil {
return err