summaryrefslogtreecommitdiff
path: root/cmd/podman/generate_kube.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-04-07 13:38:58 -0500
committerbaude <bbaude@redhat.com>2019-04-12 12:05:09 -0500
commit80b2c097fe333fd43634753b574d4b5bdf155b82 (patch)
treebfb3e032c0b6b4e7f08d087fa00d3919cdf62751 /cmd/podman/generate_kube.go
parent4596c39655f7ff5e741adbc97aaa49bb3a9d453e (diff)
downloadpodman-80b2c097fe333fd43634753b574d4b5bdf155b82.tar.gz
podman-80b2c097fe333fd43634753b574d4b5bdf155b82.tar.bz2
podman-80b2c097fe333fd43634753b574d4b5bdf155b82.zip
podman-remote generate kube
Allow the ability to generate kube YAML from the podman remote-client. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/generate_kube.go')
-rw-r--r--cmd/podman/generate_kube.go40
1 files changed, 10 insertions, 30 deletions
diff --git a/cmd/podman/generate_kube.go b/cmd/podman/generate_kube.go
index c58372899..30818403b 100644
--- a/cmd/podman/generate_kube.go
+++ b/cmd/podman/generate_kube.go
@@ -3,13 +3,11 @@ package main
import (
"fmt"
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/cmd/podman/libpodruntime"
- "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/pkg/adapter"
podmanVersion "github.com/containers/libpod/version"
"github.com/ghodss/yaml"
"github.com/pkg/errors"
"github.com/spf13/cobra"
- "k8s.io/api/core/v1"
)
var (
@@ -42,14 +40,12 @@ func init() {
func generateKubeYAMLCmd(c *cliconfig.GenerateKubeValues) error {
var (
- podYAML *v1.Pod
- container *libpod.Container
- err error
- output []byte
- pod *libpod.Pod
+ //podYAML *v1.Pod
+ err error
+ output []byte
+ //pod *libpod.Pod
marshalledPod []byte
marshalledService []byte
- servicePorts []v1.ServicePort
)
args := c.InputArgs
@@ -57,43 +53,27 @@ func generateKubeYAMLCmd(c *cliconfig.GenerateKubeValues) error {
return errors.Errorf("you must provide exactly one container|pod ID or name")
}
- runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand)
+ runtime, err := adapter.GetRuntime(&c.PodmanCommand)
if err != nil {
return errors.Wrapf(err, "could not get runtime")
}
defer runtime.Shutdown(false)
- // Get the container in question
- container, err = runtime.LookupContainer(args[0])
+ podYAML, serviceYAML, err := runtime.GenerateKube(c)
if err != nil {
- pod, err = runtime.LookupPod(args[0])
- if err != nil {
- return err
- }
- podYAML, servicePorts, err = pod.GenerateForKube()
- } else {
- if len(container.Dependencies()) > 0 {
- return errors.Wrapf(libpod.ErrNotImplemented, "containers with dependencies")
- }
- podYAML, err = container.GenerateForKube()
+ return err
}
+ // Marshall the results
+ marshalledPod, err = yaml.Marshal(podYAML)
if err != nil {
return err
}
-
if c.Service {
- serviceYAML := libpod.GenerateKubeServiceFromV1Pod(podYAML, servicePorts)
marshalledService, err = yaml.Marshal(serviceYAML)
if err != nil {
return err
}
}
- // Marshall the results
- marshalledPod, err = yaml.Marshal(podYAML)
- if err != nil {
- return err
- }
-
header := `# Generation of Kubernetes YAML is still under development!
#
# Save the output of this file and use kubectl create -f to import