Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"podman play kube" yaml multiple resources #9129

Closed
ADIX7 opened this issue Jan 27, 2021 · 13 comments · Fixed by #9759
Closed

"podman play kube" yaml multiple resources #9129

ADIX7 opened this issue Jan 27, 2021 · 13 comments · Fixed by #9759
Assignees
Labels
Good First Issue This issue would be a good issue for a first time contributor to undertake. kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@ADIX7
Copy link

ADIX7 commented Jan 27, 2021

/kind feature

Add support for multiple resources in yaml used by podman play kube like kubernetes does have.

@openshift-ci-robot openshift-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Jan 27, 2021
@baude
Copy link
Member

baude commented Jan 27, 2021

interested in contributing?

@ADIX7
Copy link
Author

ADIX7 commented Jan 27, 2021

Unfortunately I won't have time to do this in the near future.

@mheon
Copy link
Member

mheon commented Jan 27, 2021

Can you provide more details here? An example YAML file with the exact resources you want us to support identified, perhaps?

@ADIX7
Copy link
Author

ADIX7 commented Jan 27, 2021

I mean to concate multiple yaml-s generated by podman generate kube separeted by --- just like in a kubernetes yaml.
I would like to use this feature with #8996 to do something like kustomize build my-overlay | podman play kub -. The pipe features is WIP but kustomize create a yaml with multiple resources separeted by ---.

As for this issue:
For example if I create 2 pod like this:

podman create --pod new:nginxpod1 --name nginx1 nginx1
podman create --pod new:nginxpod2 --name nginx1 nginx2

And generate kubernetes yamls

Pod1: podman generate kube nginxpod1 > pod1.yaml

pod1.yaml

# Generation of Kubernetes YAML is still under development!
#
# Save the output of this file and use kubectl create -f to import
# it into Kubernetes.
#
# Created with podman-2.2.1
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: "2021-01-27T20:08:05Z"
  labels:
    app: nginxpod1
  name: nginxpod1
spec:
  containers:
  - command:
    - nginx
    - -g
    - daemon off;
    env:
    - name: PATH
      value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    - name: TERM
      value: xterm
    - name: container
      value: podman
    - name: NGINX_VERSION
      value: 1.19.6
    - name: NJS_VERSION
      value: 0.5.0
    - name: PKG_RELEASE
      value: 1~buster
    - name: HOSTNAME
      value: nginxpod1
    image: docker.io/library/nginx:latest
    name: nginx1
    resources: {}
    securityContext:
      allowPrivilegeEscalation: true
      capabilities: {}
      privileged: false
      readOnlyRootFilesystem: false
      seLinuxOptions: {}
    workingDir: /
  restartPolicy: Never
status: {}
---
metadata:
  creationTimestamp: null
spec: {}
status:
  loadBalancer: {}

Pod2: podman generate kube nginxpod2 > pod2.yaml

pod2.yaml

# Generation of Kubernetes YAML is still under development!
#
# Save the output of this file and use kubectl create -f to import
# it into Kubernetes.
#
# Created with podman-2.2.1
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: "2021-01-27T20:08:56Z"
  labels:
    app: nginxpod2
  name: nginxpod2
spec:
  containers:
  - command:
    - nginx
    - -g
    - daemon off;
    env:
    - name: PATH
      value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    - name: TERM
      value: xterm
    - name: container
      value: podman
    - name: NGINX_VERSION
      value: 1.19.6
    - name: NJS_VERSION
      value: 0.5.0
    - name: PKG_RELEASE
      value: 1~buster
    - name: HOSTNAME
      value: nginxpod2
    image: docker.io/library/nginx:latest
    name: nginx2
    resources: {}
    securityContext:
      allowPrivilegeEscalation: true
      capabilities: {}
      privileged: false
      readOnlyRootFilesystem: false
      seLinuxOptions: {}
    workingDir: /
  restartPolicy: Never
status: {}
---
metadata:
  creationTimestamp: null
spec: {}
status:
  loadBalancer: {}

I would like create a combined yaml like:

combined.yaml:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: "2021-01-27T20:08:05Z"
  labels:
    app: nginxpod1
  name: nginxpod1
spec:
  containers:
  - command:
    - nginx
    - -g
    - daemon off;
    env:
    - name: PATH
      value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    - name: TERM
      value: xterm
    - name: container
      value: podman
    - name: NGINX_VERSION
      value: 1.19.6
    - name: NJS_VERSION
      value: 0.5.0
    - name: PKG_RELEASE
      value: 1~buster
    - name: HOSTNAME
      value: nginxpod1
    image: docker.io/library/nginx:latest
    name: nginx1
    resources: {}
    securityContext:
      allowPrivilegeEscalation: true
      capabilities: {}
      privileged: false
      readOnlyRootFilesystem: false
      seLinuxOptions: {}
    workingDir: /
  restartPolicy: Never
status: {}

---
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: "2021-01-27T20:08:56Z"
  labels:
    app: nginxpod2
  name: nginxpod2
spec:
  containers:
  - command:
    - nginx
    - -g
    - daemon off;
    env:
    - name: PATH
      value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    - name: TERM
      value: xterm
    - name: container
      value: podman
    - name: NGINX_VERSION
      value: 1.19.6
    - name: NJS_VERSION
      value: 0.5.0
    - name: PKG_RELEASE
      value: 1~buster
    - name: HOSTNAME
      value: nginxpod2
    image: docker.io/library/nginx:latest
    name: nginx2
    resources: {}
    securityContext:
      allowPrivilegeEscalation: true
      capabilities: {}
      privileged: false
      readOnlyRootFilesystem: false
      seLinuxOptions: {}
    workingDir: /
  restartPolicy: Never
status: {}

and start it like podman play kube combined.yaml which create the 2 pods the same way as podman play kube pod1.yaml and podman play kube pod2.yaml would.

@mheon
Copy link
Member

mheon commented Jan 27, 2021

I don't think that's going to be possible as you suggest - we'd basically need to put the separate pod definitions together in a YAML array, which would prevent straight concatenation (you'd need some pretty significant modifications to the YAML).

Ought to be possible to make play kube accept multiple files at once, though. podman play kube pod1.yaml pod2.yaml or similar.

@ADIX7
Copy link
Author

ADIX7 commented Jan 28, 2021

What do you mean by "which would prevent straight concatenation"?

Podman in the play kube command could split the yaml at every --- and iterate through these resources. These resources would be the same as the currently accepted yaml format. The yaml input is only used in play kube command, isn't it?

@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

@rhatdan
Copy link
Member

rhatdan commented Mar 1, 2021

Is your description legal YAML? Would this YAML file be used if it was sent to Kubernetes/OpenShift? If yes, then we should support it, if No then we should not support it, and you should just script out a solution for it.
podman play kube should only support legal kubernetes yaml files.

@ADIX7
Copy link
Author

ADIX7 commented Mar 2, 2021

@rhatdan rhatdan added Good First Issue This issue would be a good issue for a first time contributor to undertake. and removed stale-issue labels Mar 2, 2021
@rhatdan
Copy link
Member

rhatdan commented Mar 2, 2021

Awesome. Interested in opening a PR to add this feature?

@ParkerVR Interested in taking a look?

@ADIX7
Copy link
Author

ADIX7 commented Mar 2, 2021

Unfortunately I won't have time to implement this.

@EduardoVega
Copy link
Contributor

I can work on this one.

@rhatdan
Copy link
Member

rhatdan commented Mar 3, 2021

Great.

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Good First Issue This issue would be a good issue for a first time contributor to undertake. kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants