Odo: Implement container endpoints from devfile v2 spec

Created on 8 Jul 2020  Â·  10Comments  Â·  Source: openshift/odo

We need to implement the endpoints section from devfile v2 container definition.

Acceptance criteria

  • [ ] odo push against OpenShift should create resources based on described mappings with Route
  • [ ] odo push against Kubernetes will create Services based on described mappings. If Ingress needs to be created we have problem with missing host information. In this case, odo should print a warning explaining what is the problem, and how user can create URL (example command should be automatically constructed with all flags based on endpoint definition) example: "Devfile defined exposed port 8080. In order to make this port accessible via URL you need to run odo url create --port 8080 --path /api --host <yourIngressHost>"

https://devfile.github.io/devfile/_attachments/api-reference.html

Mapping to Kubernetes Resource:

  • exposure:

    • public - create Route/Ingress and Service (default)

    • internal - create only Service

    • none - don't create Service nor Route/Ingress

  • protocol:

    • http - Protocol for port in Service will be tcp,

    • https - Protocol for port in Service will be tcp, Ingress/Route (when exposure: public is set should be securet with SSL (the same way that odo dues when odo url create --secure is executed

    • ws - Protocol for port in Service will be tcp,

    • wss - Protocol for port in Service will be tcp, Ingress/Route (when exposure: public is set should be securet with SSL (the same way that odo dues when odo url create --secure is executed

    • tcp - Service port will be tcp,

    • udp - Protocol for port in Service will be udp,

example of endpoint definition:

endpoints:
 - name: web
    path: /api
    exposure: public
    protocol: http
    secure: false
    targetPort: 8080

Based on this definition odo should create:

  • Service for container port 8080
  • Ingress or Route for Service on port 8080 with path: /api
aredevfile prioritHigh required-for-v2

All 10 comments

/priority high
/area devfile
/area url

This issue is blocked by: #3544

3544 was closed

This issue will require updating devfile json schema embedded in odo and updating the parsers structs.

@kadel
Since secure for each TargetPort is defined in devfile endpoint, do we still need the --secure flag for url creation?

I think we can safely remove the flag, and just use the endpoint definition in devfile to avoid unnecessary validation for secure setting.

After thinking this deeper:
Since all the properties in Endpoint, other than Name and TargetPort, are optional. Do we accept the scenario that all the optional properties are empty? And user use url create to set the values in env.yaml?
i.e: in devfile

endpoints:
 - name: web
    targetPort: 8080

User run odo url create --host 1.2.3.4.com --port 8080 --ingress --secure

Now the env.yaml file contains

  Url:
  - Name: nodejs-8080
    Port: 8080
    Secure: true
    Host: 1.2.3.4.com
    Kind: ingress

In addition, do we support user modifying the devfile to update the endpoint entry?
This may cause conflict between devfile and env.yaml file. And when there is conflict, which definition should we use? or should we even delete the previously pushed igress/route if we find there is a conflict between devfile & env.yaml?

Furthermore, this issue allows URL creation using definition in devfile.yaml, the logic of url list and url describe also requires update. Issue created: https://github.com/openshift/odo/issues/3615
If urls defined in env.yaml and devfile.yaml have conflicts, how should url list and url describe act in that case?

After discussion with the team, we are now proposing remove --secure and --path from url create. If the path/secure is specified in the endpoint definition, we’ll just use it. So that we can avoid conflicts for these two settings.

--port in url create should match TargetPort defined in devfile, if the port specified is not found in devfile, cli should prompt an error. (This is already our current behavior)

And if for same port, different urlName are defined in devfile.yaml & env.yaml, we will use the one defined in env.yaml file, since the value is specified by user from cli, and env.yaml is considered as the “local” settings, which should has precedence over devfile.yaml.

@kadel Any thoughts on that? or any concerns?

After discussion with the team, we are now proposing remove --secure and --path from url create. If the path/secure is specified in the endpoint definition, we’ll just use it. So that we can avoid conflicts for these two settings.

--port in url create should match TargetPort defined in devfile, if the port specified is not found in devfile, cli should prompt an error. (This is already our current behavior)

And if for same port, different urlName are defined in devfile.yaml & env.yaml, we will use the one defined in env.yaml file, since the value is specified by user from cli, and env.yaml is considered as the “local” settings, which should has precedence over devfile.yaml.

@kadel Any thoughts on that? or any concerns?

@yangcao77 I think we can remove these flags for devfile but --secure flag is being used for s2i components.

@yangcao77 I think we can remove these flags for devfile but --secure flag is being used for s2i components.

@adisky Sorry to cause the confusion. What I meant was remove those flags only if experimental mode is on.

In addition, do we support user modifying the devfile to update the endpoint entry?
This may cause conflict between devfile and env.yaml file. And when there is conflict, which definition should we use? or should we even delete the previously pushed igress/route if we find there is a conflict between devfile & env.yaml?

Most of the options from evn.yaml should move to devfile.yaml.
The only thing that will need to stay in env.yaml is host kind and name to match configuration from env.yaml to endpoint from devfile.yaml

I originally intended this issue to be mostly about push logic and devfile.yaml. We need to make sure that if devfile.yaml contains endpoint definition URL is automatically created without needing to run odo url create first.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rnapoles-rh picture rnapoles-rh  Â·  4Comments

maysunfaisal picture maysunfaisal  Â·  8Comments

amitkrout picture amitkrout  Â·  3Comments

kadel picture kadel  Â·  7Comments

prietyc123 picture prietyc123  Â·  3Comments