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 generate kube ignore "_" in container name. #7020

Closed
kaiyasuda opened this issue Jul 20, 2020 · 10 comments
Closed

podman generate kube ignore "_" in container name. #7020

kaiyasuda opened this issue Jul 20, 2020 · 10 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. stale-issue

Comments

@kaiyasuda
Copy link

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

/kind bug

Description

When podman generate kube writes container name, ignore "_".

Steps to reproduce the issue:

  1. check running container include "_" in its name.
# podman container ls -a
CONTAINER ID  IMAGE                              COMMAND     CREATED        STATUS            PORTS                   NAMES
128d10cc7413  docker.io/library/postgres:latest  postgres    6 minutes ago  Up 6 minutes ago  0.0.0.0:8080->8080/tcp  service_postgres_1
14dfcf8959ac  k8s.gcr.io/pause:3.2                           6 minutes ago  Up 6 minutes ago  0.0.0.0:8080->8080/tcp  84d68cb240c6-infra
945fedadb3e8  quay.io/keycloak/keycloak:latest   -b 0.0.0.0  6 minutes ago  Up 6 minutes ago  0.0.0.0:8080->8080/tcp  service_keycloak_1
  1. make kubernetes yaml with generate kube
# podman generate kube service > kubernetes-keycloak-postgres.yml

Describe the results you received:

  1. check containers name.
# cat kubernetes-keycloak-postgres.yml | grep "name: service."
    name: servicekeycloak1
    name: servicepostgres1

Describe the results you expected:

# cat kubernetes-keycloak-postgres.yml | grep "name: service."
    name: service_keycloak_1
    name: service_postgres_1

Output of podman version:

# podman version
Version:      2.0.2
API Version:  1
Go Version:   go1.13.4
Built:        Wed Dec 31 19:00:00 1969
OS/Arch:      linux/amd64

Output of podman info --debug:

# podman info --debug
host:
  arch: amd64
  buildahVersion: 1.15.0
  cgroupVersion: v1
  conmon:
    package: conmon-2.0.19-1.el8.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.0.19, commit: 4726cba6f219c7479c28f0687868bd2ffe894869'
  cpus: 2
  distribution:
    distribution: '"centos"'
    version: "8"
  eventLogger: file
  hostname: ycentos8.example.com
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 4.18.0-147.el8.x86_64
  linkmode: dynamic
  memFree: 5390655488
  memTotal: 8191717376
  ociRuntime:
    name: runc
    package: runc-1.0.0-60.rc8.module_el8.1.0+237+63e26edc.x86_64
    path: /usr/bin/runc
    version: 'runc version spec: 1.0.1-dev'
  os: linux
  remoteSocket:
    path: /run/podman/podman.sock
  rootless: false
  slirp4netns:
    executable: ""
    package: ""
    version: ""
  swapFree: 6874460160
  swapTotal: 6874460160
  uptime: 123h 36m 21.22s (Approximately 5.12 days)
registries:
  search:
  - registry.redhat.io
  - registry.access.redhat.com
  - quay.io
  - docker.io
store:
  configFile: /etc/containers/storage.conf
  containerStore:
    number: 3
    paused: 0
    running: 2
    stopped: 1
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /var/lib/containers/storage
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  imageStore:
    number: 11
  runRoot: /var/run/containers/storage
  volumePath: /var/lib/containers/storage/volumes
version:
  APIVersion: 1
  Built: 0
  BuiltTime: Wed Dec 31 19:00:00 1969
  GitCommit: ""
  GoVersion: go1.13.4
  OsArch: linux/amd64
  Version: 2.0.2

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

# rpm -q podman
podman-2.0.2-2.el8.x86_64

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

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jul 20, 2020
@zhangguanzhang
Copy link
Collaborator

could you put the file content to there which podman play kube xxx.yml?

@kaiyasuda
Copy link
Author

could you put the file content to there which podman play kube xxx.yml?

this pod made by podman-compose.
compose yml file is here.
https://github.com/keycloak/keycloak-containers/blob/master/docker-compose-examples/keycloak-postgres.yml

version: '3'

volumes:
  postgres_data:
      driver: local

services:
  postgres:
      image: postgres
      volumes:
        - postgres_data:/var/lib/postgresql/data
      environment:
        POSTGRES_DB: keycloak
        POSTGRES_USER: keycloak
        POSTGRES_PASSWORD: password
  keycloak:
      image: quay.io/keycloak/keycloak:latest
      environment:
        DB_VENDOR: POSTGRES
        DB_ADDR: postgres
        DB_DATABASE: keycloak
        DB_USER: keycloak
        DB_SCHEMA: public
        DB_PASSWORD: password
        KEYCLOAK_USER: admin
        KEYCLOAK_PASSWORD: Pa55w0rd
        # Uncomment the line below if you want to specify JDBC parameters. The parameter below is just an example, and it shouldn't be used in production without knowledge. It is highly recommended that you read the PostgreSQL JDBC driver documentation in order to use it.
        #JDBC_PARAMS: "ssl=true"
      ports:
        - 8080:8080
      depends_on:
        - postgres

and this is full list of reconverted to kubernetes yaml file.

# 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.0.2
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: "2020-07-20T06:47:49Z"
  labels:
    app: service
  name: service
spec:
  containers:
  - command:
    - docker-entrypoint.sh
    - postgres
    env:
    - name: PATH
      value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/postgresql/12/bin
    - name: TERM
      value: xterm
    - name: HOSTNAME
    - name: POSTGRES_USER
      value: keycloak
    - name: DB_PASSWORD
      value: password
    - name: JDBC_MYSQL_VERSION
      value: 8.0.19
    - name: JBOSS_HOME
      value: /opt/jboss/keycloak
    - name: JDBC_MSSQL_VERSION
      value: 7.4.1.jre11
    - name: KEYCLOAK_USER
      value: admin
    - name: DB_VENDOR
      value: POSTGRES
    - name: container
      value: podman
    - name: DB_SCHEMA
      value: public
    - name: PROXY_ADDRESS_FORWARDING
      value: "false"
    - name: DB_DATABASE
      value: keycloak
    - name: JDBC_MARIADB_VERSION
      value: 2.5.4
    - name: PG_MAJOR
      value: "12"
    - name: DB_USER
      value: keycloak
    - name: KEYCLOAK_VERSION
      value: 10.0.2
    - name: LANG
      value: en_US.utf8
    - name: PG_VERSION
      value: 12.3-1.pgdg100+1
    - name: DB_ADDR
      value: postgres
    - name: GOSU_VERSION
      value: "1.12"
    - name: LAUNCH_JBOSS_IN_BACKGROUND
      value: "1"
    - name: POSTGRES_PASSWORD
      value: password
    - name: POSTGRES_DB
      value: keycloak
    - name: KEYCLOAK_PASSWORD
      value: Pa55w0rd
    - name: JDBC_POSTGRES_VERSION
      value: 42.2.5
    - name: PGDATA
      value: /var/lib/postgresql/data
    image: docker.io/library/postgres:latest
    name: postgres_1
    ports:
    - containerPort: 8080
      hostPort: 8080
      protocol: TCP
    resources: {}
    securityContext:
      allowPrivilegeEscalation: true
      capabilities: {}
      privileged: false
      readOnlyRootFilesystem: false
      seLinuxOptions: {}
    workingDir: /
  - command:
    - /opt/jboss/tools/docker-entrypoint.sh
    - -b
    - 0.0.0.0
    env:
    - name: PATH
      value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    - name: TERM
      value: xterm
    - name: HOSTNAME
    - name: JBOSS_HOME
      value: /opt/jboss/keycloak
    - name: JDBC_MSSQL_VERSION
      value: 7.4.1.jre11
    - name: LANG
      value: en_US.UTF-8
    - name: KEYCLOAK_USER
      value: admin
    - name: DB_PASSWORD
      value: password
    - name: KEYCLOAK_VERSION
      value: 10.0.2
    - name: JDBC_MYSQL_VERSION
      value: 8.0.19
    - name: DB_SCHEMA
      value: public
    - name: PROXY_ADDRESS_FORWARDING
      value: "false"
    - name: DB_DATABASE
      value: keycloak
    - name: DB_VENDOR
      value: POSTGRES
    - name: container
      value: podman
    - name: DB_ADDR
      value: postgres
    - name: LAUNCH_JBOSS_IN_BACKGROUND
      value: "1"
    - name: JDBC_MARIADB_VERSION
      value: 2.5.4
    - name: KEYCLOAK_PASSWORD
      value: Pa55w0rd
    - name: JDBC_POSTGRES_VERSION
      value: 42.2.5
    - name: DB_USER
      value: keycloak
    image: quay.io/keycloak/keycloak:latest
    name: keycloak_1
    resources: {}
    securityContext:
      allowPrivilegeEscalation: true
      capabilities: {}
      privileged: false
      readOnlyRootFilesystem: false
      runAsGroup: 0
      runAsUser: 1000
      seLinuxOptions: {}
    workingDir: /
status: {}
---
metadata:
  creationTimestamp: null
spec: {}
status:
  loadBalancer: {}

I fix container name and play this reconverted file, but it was not solve.

# cat kubernetes-keycloak-postgres.yml | grep "    name: ."
    name: postgres_1
    name: keycloak_1
# podman play kubernetes-keycloak-postgres.yml
# podman container ls -a
CONTAINER ID  IMAGE                              COMMAND               CREATED         STATUS             PORTS                   NAMES
3e759ac0523b  quay.io/keycloak/keycloak:latest   /opt/jboss/tools/...  18 seconds ago  Up 16 seconds ago  0.0.0.0:8080->8080/tcp  service-keycloak_1
7a67cd3ad752  k8s.gcr.io/pause:3.2                                     26 seconds ago  Up 18 seconds ago  0.0.0.0:8080->8080/tcp  4d2a256d3921-infra
d833d321b8ec  docker.io/library/postgres:latest  docker-entrypoint...  22 seconds ago  Up 17 seconds ago  0.0.0.0:8080->8080/tcp  service-postgres_1
# podman generate service > kubernetes-keycloak-postgres2.yml
# cat kubernetes-keycloak-postgres2.yml | grep "name: service."
    name: service-keycloak1
    name: service-postgres1

@rhatdan
Copy link
Member

rhatdan commented Jul 20, 2020

@haircommander PTAL

@haircommander
Copy link
Collaborator

kubeContainer.Name = removeUnderscores(c.Name())

git blame points to @baude's original implementation of generate kube
f11a74e

any reason to keep it? I also see we're scrubbing podName for underscores

@mheon
Copy link
Member

mheon commented Jul 20, 2020

I think there was a reason for it, but I can't recall what it actually was. @baude might be able to tell us were he not on vacation.

@mheon
Copy link
Member

mheon commented Jul 20, 2020

I thought it might be because we don't allow _ in container/pod names, but I checked and we do allow them.

@github-actions
Copy link

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

@rhatdan
Copy link
Member

rhatdan commented Aug 20, 2020

@baude Any ideas on this one?

@mheon
Copy link
Member

mheon commented Sep 8, 2020

@ParkerVR PTAL. Since no one remembers why we stripped them originally, I think it should be safe to put them in.

@mheon
Copy link
Member

mheon commented Sep 11, 2020

Fixed by #7587

@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
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. stale-issue
Projects
None yet
Development

No branches or pull requests

7 participants