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

No Ports exposed inside Deployment in case of Zero Config Dockerfile Mode #240

Closed
rohanKanojia opened this issue Jun 10, 2020 · 3 comments · Fixed by #468
Closed

No Ports exposed inside Deployment in case of Zero Config Dockerfile Mode #240

rohanKanojia opened this issue Jun 10, 2020 · 3 comments · Fixed by #468
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@rohanKanojia
Copy link
Member

rohanKanojia commented Jun 10, 2020

While modifying integration test PR(eclipse-jkube/jkube-integration-tests#45), I noticed that generated resource manifest seem to be missing ports. Our Enricher API relies only on ImageConfiguration field to fetch ports:
https://github.com/eclipse/jkube/blob/07477a232e9ed4d3441622e43fda8f1c9d8466bf/jkube-kit/enricher/api/src/main/java/org/eclipse/jkube/kit/enricher/handler/ContainerHandler.java#L164-L170

Here is an example of generated Deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    jkube.io/git-url: [email protected]:jkubeio/jkube-integration-tests.git
    jkube.io/git-commit: abf5c3014bd084a15c59e8b4fd19becf08b2bc0e
    jkube.io/git-branch: pr/simple-dockerfile-test
  labels:
    app: spring-boot-zero-config-dockerfile
    provider: jkube
    version: 0.0.0-SNAPSHOT
    group: org.eclipse.jkube.integration-tests
  name: spring-boot-zero-config-dockerfile
spec:
  replicas: 1
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: spring-boot-zero-config-dockerfile
      provider: jkube
      group: org.eclipse.jkube.integration-tests
  template:
    metadata:
      annotations:
        jkube.io/git-url: [email protected]:jkubeio/jkube-integration-tests.git
        jkube.io/git-commit: abf5c3014bd084a15c59e8b4fd19becf08b2bc0e
        jkube.io/git-branch: pr/simple-dockerfile-test
      labels:
        app: spring-boot-zero-config-dockerfile
        provider: jkube
        version: 0.0.0-SNAPSHOT
        group: org.eclipse.jkube.integration-tests
    spec:
      containers:
      - env:
        - name: KUBERNETES_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        image: integration-tests/spring-boot-zero-config-dockerfile:latest
        imagePullPolicy: IfNotPresent
        name: integration-tests-spring-boot-zero-config-dockerfile
        securityContext:
          privileged: false

As you can see, there is no port being provided inside .spec.template.spec.containers[0]. Sadly DefaultControllerEnricher doesn't have any parameter to configure ports:

https://github.com/eclipse/jkube/blob/07477a232e9ed4d3441622e43fda8f1c9d8466bf/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/DefaultControllerEnricher.java#L76-L83

Maybe we can add an option just like DefaultServiceEnricher:
https://github.com/eclipse/jkube/blob/07477a232e9ed4d3441622e43fda8f1c9d8466bf/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/DefaultServiceEnricher.java#L85-L100

@rohanKanojia
Copy link
Member Author

As a workaround, I was able to generate correct Deployment by using this resource fragment:

spec:
  template:
    spec:
      containers:
      - ports:
        - containerPort: 8080
          name: http
          protocol: TCP

But ideally, JKube should be smart enough to detect ports from provided Dockerfile EXPOSE statements

@manusa
Copy link
Member

manusa commented Jun 11, 2020

But ideally, JKube should be smart enough to detect ports from provided Dockerfile EXPOSE statements

Yes, this should be applicable for Service enrichers too.

@manusa manusa added the enhancement New feature or request label Jun 22, 2020
@manusa manusa added this to the 1.1.0 milestone Jun 22, 2020
@manusa
Copy link
Member

manusa commented Jun 22, 2020

We already have a Dockerfile parser, we can easily take advantage of this to pick up the required ports.

@rohanKanojia rohanKanojia self-assigned this Nov 2, 2020
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 2, 2020
…Zero Config Dockerfile Mode

Add ports to ImageConfiguration generated in DockerFileUtil.createSimpleDockerfileConfig
by parsing contents of Dockerfile
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 3, 2020
…Zero Config Dockerfile Mode

Add ports to ImageConfiguration generated in DockerFileUtil.createSimpleDockerfileConfig
by parsing contents of Dockerfile
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 3, 2020
…Zero Config Dockerfile Mode

Add ports to ImageConfiguration generated in DockerFileUtil.createSimpleDockerfileConfig
by parsing contents of Dockerfile
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 4, 2020
…Zero Config Dockerfile Mode

Add ports to ImageConfiguration generated in DockerFileUtil.createSimpleDockerfileConfig
by parsing contents of Dockerfile
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 4, 2020
…Zero Config Dockerfile Mode

Add ports to ImageConfiguration generated in DockerFileUtil.createSimpleDockerfileConfig
by parsing contents of Dockerfile
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Nov 4, 2020
…Zero Config Dockerfile Mode

Add ports to ImageConfiguration generated in DockerFileUtil.createSimpleDockerfileConfig
by parsing contents of Dockerfile
manusa pushed a commit that referenced this issue Nov 5, 2020
…ockerfile Mode

Add ports to ImageConfiguration generated in DockerFileUtil.createSimpleDockerfileConfig
by parsing contents of Dockerfile
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
2 participants