Components of any type can specify the endpoints that the container exposes. You can create an endpoint for your application if your application server is listening on a port.
Specify endpoints properties as shown in the following example:Example 1. Specifying endpoint properties
schemaVersion: 2.1.0 metadata: name: mydevfile projects: - name: my-go-project clonePath: go/src/github.com/acme/my-go-project git: remotes: origin: "https://github.com/acme/my-go-project.git" components: - name: go container: image: golang memoryLimit: 512Mi mountSources: true command: ['sleep', 'infinity'] env: - name: gopath value: $(PROJECTS_ROOT)/go - name: gocache value: /tmp/go-cache endpoints: - name: web targetPort: 8080 exposure: public - name: postgres container: image: postgres memoryLimit: 512Mi env: - name: postgres_user value: user - name: postgres_password value: password - name: postgres_db value: database endpoints: - name: postgres targetPort: 5432 exposure: none
This example has two containers, each defining a single endpoint. The endpoint is an accessible port that can be made accessible inside the workspace. Each endpoint has a name and port, which is the port on which the server running inside the container is listening. See the following attributes that you can set on the endpoint:
exposure: When its value is
public, the endpoint is accessible outside the workspace and is exposed on port
443depending on whether TLS is enabled in devfiles. Access this endpoint from the devfile user interface.
protocol: For public endpoints, the protocol is a hint to the UI on how to construct the URL for the endpoint access. Typical values are
secure: A boolean defaulting to
falsethat specifies whether the endpoint is put behind a JWT proxy requiring a JWT workspace token to grant access. The JWT proxy is deployed in the same Pod as the server and assumes the server listens solely on the local loopback interface, such as
Listening on any other interface than the local loopback poses a security risk because such server is accessible without the JWT authentication within the cluster network on the corresponding IP addresses.
path: The URL of the endpoint.
When starting a new server within a component, the devfile autodetects this, and the component UI offers to automatically expose this port as an
exposure port. Use this port to debug a web application. You cannot debug a web application for servers that autostart with the container, such as a database server. For such components, specify the endpoints explicitly.
schemaVersion: 2.1.0 metadata: name: mydevfile components: - openshift: name: webapp uri: webapp.yaml endpoints: - name: 'web' targetPort: 8080 exposure: public - openshift: name: mongo uri: mongo-db.yaml endpoints: - name: 'mongo-db' targetPort: 27017 exposure: public