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

Allow stdin for kube play #463

Open
mcexit opened this issue Aug 21, 2022 · 4 comments
Open

Allow stdin for kube play #463

mcexit opened this issue Aug 21, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@mcexit
Copy link

mcexit commented Aug 21, 2022

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind feature

Description

podman_play module only allows file input.

Describe the results you received: podman_play only allows file input using kube_file which is required.

Describe the results you expected: podman_play module should allow for variable input, not just file. This allows the utilization of something like kubernetes.core.kustomize lookup

Version of the containers.podman collection:
Either git commit if installed from git: git show --summary
Or version from ansible-galaxy if installed from galaxy: ansible-galaxy collection list | grep containers.podman

1.9.4

Output of ansible --version:

ansible [core 2.13.3]
  config file = /home/user/.ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.10/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.6 (main, Aug  3 2022, 17:39:45) [GCC 12.1.1 20220730]
  jinja version = 3.1.2
  libyaml = True

Output of podman version:

Client:       Podman Engine
Version:      4.2.0
API Version:  4.2.0
Go Version:   go1.19
Git Commit:   7fe5a419cfd2880df2028ad3d7fd9378a88a04f4-dirty
Built:        Sat Aug 13 03:26:55 2022
OS/Arch:      linux/amd64

Output of podman info --debug:

host:
  arch: amd64
  buildahVersion: 1.27.0
  cgroupControllers:
  - cpuset
  - cpu
  - io
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: /usr/bin/conmon is owned by conmon 1:2.1.3-1
    path: /usr/bin/conmon
    version: 'conmon version 2.1.3, commit: ab52a597278b20173440140cd810dc9fa8785c93'
  cpuUtilization:
    idlePercent: 98.36
    systemPercent: 0.45
    userPercent: 1.18
  cpus: 8
  distribution:
    distribution: arch
    version: unknown
  eventLogger: journald
  hostname: hostname
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 5.19.2-zen1-1-zen
  linkmode: dynamic
  logDriver: journald
  memFree: 3715461120
  memTotal: 16635138048
  networkBackend: netavark
  ociRuntime:
    name: crun
    package: /usr/bin/crun is owned by crun 1.5-1
    path: /usr/bin/crun
    version: |-
      crun version 1.5
      commit: 54ebb8ca8bf7e6ddae2eb919f5b82d1d96863dea
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
  os: linux
  remoteSocket:
    exists: true
    path: /run/user/1000/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /etc/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: /usr/bin/slirp4netns is owned by slirp4netns 1.2.0-1
    version: |-
      slirp4netns version 1.2.0
      commit: 656041d45cfca7a4176f6b7eed9e4fe6c11e8383
      libslirp: 4.7.0
      SLIRP_CONFIG_VERSION_MAX: 4
      libseccomp: 2.5.4
  swapFree: 17179865088
  swapTotal: 17179865088
  uptime: 16h 25m 52.00s (Approximately 0.67 days)
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  volume:
  - local
registries: {}
store:
  configFile: /home/user/.config/containers/storage.conf
  containerStore:
    number: 2
    paused: 0
    running: 2
    stopped: 0
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/user/.local/share/containers/storage
  graphRootAllocated: 102227316736
  graphRootUsed: 71527297024
  graphStatus:
    Backing Filesystem: btrfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 9
  runRoot: /run/user/1000/containers
  volumePath: /home/user/.local/share/containers/storage/volumes
version:
  APIVersion: 4.2.0
  Built: 1660386415
  BuiltTime: Sat Aug 13 03:26:55 2022
  GitCommit: 7fe5a419cfd2880df2028ad3d7fd9378a88a04f4-dirty
  GoVersion: go1.19
  Os: linux
  OsArch: linux/amd64
  Version: 4.2.0

Package info (e.g. output of rpm -q podman or apt list podman):

pacman --query --info podman
Name            : podman
Version         : 4.2.0-1
Description     : Tool and library for running OCI-based containers in pods
Architecture    : x86_64
URL             : https://github.com/containers/podman
Licenses        : Apache
Groups          : None
Provides        : None
Depends On      : catatonit  conmon  containers-common  crun  iptables  libdevmapper.so=1.02-64  libgpgme.so=11-64  libseccomp.so=2-64  slirp4netns
Optional Deps   : apparmor: for AppArmor support [installed]
                  btrfs-progs: support btrfs backend devices [installed]
                  netavark: for a new container-network-stack implementation [installed]
                  podman-compose: for docker-compose compatibility [installed]
                  podman-docker: for Docker-compatible CLI [installed]
Required By     : nomad-driver-podman  podman-compose  podman-docker
Optional For    : cross
Conflicts With  : None
Replaces        : None
Installed Size  : 67.27 MiB
Packager        : David Runge <[email protected]>
Build Date      : Sat 13 Aug 2022 03:26:55 AM PDT
Install Date    : Sun 21 Aug 2022 04:43:58 AM PDT
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Signature

Additional environment details (AWS, VirtualBox, physical, etc.): physical

@sshnaidm
Copy link
Member

@mcexit can you please post an example of what you would like to have? What can be in stdin?

@sshnaidm sshnaidm added the enhancement New feature or request label Aug 22, 2022
@mcexit
Copy link
Author

mcexit commented Aug 23, 2022

An example is whatever manifest you want to pass to podman_play (akin to kustomize build <path> | podman play kube -. This could be created with the kubernetes.core.kustomize Ansible lookup module:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  annotations:
    volume.podman.io/device: syncthing/files
    volume.podman.io/mount-options: bind
  labels:
    app.kubernetes.io/component: server
    app.kubernetes.io/created-by: podman
    app.kubernetes.io/managed-by: kustomize-4.5.7
    app.kubernetes.io/name: syncthing
    app.kubernetes.io/part-of: examples
    app.kubernetes.io/version: official
  name: podman-syncthing
  namespace: examples
spec:
  volumeName: syncthing
---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    volume.podman.io/device: syncthing/files
    volume.podman.io/mount-options: bind
  labels:
    app.kubernetes.io/component: server
    app.kubernetes.io/created-by: podman
    app.kubernetes.io/managed-by: kustomize-4.5.7
    app.kubernetes.io/name: syncthing
    app.kubernetes.io/part-of: examples
    app.kubernetes.io/version: official
  name: podman-syncthing
  namespace: examples
spec:
  selector:
    matchLabels:
      app.kubernetes.io/component: server
      app.kubernetes.io/created-by: podman
      app.kubernetes.io/name: syncthing
      app.kubernetes.io/part-of: examples
      app.kubernetes.io/version: official
  template:
    metadata:
      annotations:
        volume.podman.io/device: syncthing/files
        volume.podman.io/mount-options: bind
      labels:
        app.kubernetes.io/component: server
        app.kubernetes.io/created-by: podman
        app.kubernetes.io/name: syncthing
        app.kubernetes.io/part-of: examples
        app.kubernetes.io/version: official
    spec:
      containers:
      - image: syncthing/syncthing
        name: syncthing
        ports:
        - containerPort: 8384
          hostIP: 127.0.0.1
          hostPort: 8384
        - containerPort: 21027
          hostPort: 21027
          protocol: UDP
        - containerPort: 22000
          hostPort: 22000
          protocol: TCP
        - containerPort: 22000
          hostPort: 22000
          protocol: UDP
        volumeMounts:
        - mountPath: /var/syncthing
          name: syncthing
      volumes:
      - name: syncthing
        persistentVolumeClaim:
          claimName: podman-syncthing

@sshnaidm
Copy link
Member

An example is whatever manifest you want to pass to podman_play (akin to kustomize build <path> | podman play kube -. This could be created with the kubernetes.core.kustomize Ansible lookup module:

I'd like to understand how would look ansible task with it. Can you please provide a desired example? Like registering stdout from kustomize or something else?

@sshnaidm sshnaidm added the needs_info More information about case is required label Aug 28, 2022
@mcexit
Copy link
Author

mcexit commented Aug 31, 2022

That is one possibility, but there is a kustomize lookup module already in ansible:

https://docs.ansible.com/ansible/latest/collections/kubernetes/core/kustomize_lookup.html

So it would look like:

- name: Play kube file
  containers.podman.podman_play:
    stdin: "{{ lookup('kubernetes.core.kustomize', dir='/path/to/kustomization') }}"

You could even use "{{ lookup('template', 'somefile.yaml') }}"

@sshnaidm sshnaidm removed the needs_info More information about case is required label Sep 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants