redhat-developer / redhat-developer/vscode-openshift-tools

Context menu to expose a `Deployment` as a `Route` or `Ingress`.

Open
#3,072 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/enhancement
Dominant language
TypeScript
Stars
123
Forks
63
Avg merge
6h 16m
Merged PRs (30d)
74

Description

It would be nice to expose a running service to the internet using a Route (in the case of OpenShift) or Ingress (in the case of other Kubernetes distributions).

Here's how to create a Route in OpenShift, given that $NAME_OF_DEPLOYMENT is a deployment that's in the current name:

oc expose deployment $NAME_OF_DEPLOYMENT

Here's an example of an Ingress yaml in Kubernetes:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: wildwest-backend-ingress
spec:
  defaultBackend:
    service:
      name: wildwest-backend-app
      port:
        number: 8080

The values we will have to change depending on the deployment are:

  • metadata.name to the name of the deployment but with the suffix -ingress to help distinguish it
  • spec.defaultBackend.service.name to the name of the deployment
  • spec.defaultBackend.service.port.number to the port that the deployment exposes its service on

In order to create the ingress, you will need to run oc apply -f ingress-definition.yaml.

A few final thoughts:

  1. It might also be possible to include the route or ingress in the devfile by embedding the YAML using the additional Kubernetes resources feature. For instance, this is how odo creates ServiceBindings:
// ...
components:
- kubernetes:
    inlined: |
      apiVersion: binding.operators.coreos.com/v1alpha1
      kind: ServiceBinding
      metadata:
        creationTimestamp: null
        name: my-binding
      spec:
        application:
          group: apps
          kind: Deployment
          name: using-go-app
          version: v1
        bindAsFiles: true
        detectBindingResources: true
        services:
        - group: postgres-operator.crunchydata.com
          id: my-binding
          kind: PostgresCluster
          name: example-postgres
          namespace: default
          resource: postgresclusters
          version: v1beta1
      status:
        secret: ""
  name: my-binding
// ...

The benefit of this approach is that, if I understand correctly, odo will manage the lifecycle of this Kubernetes object by creating it when dev is started and deleting it when dev is stopped

  1. A final aspect of this change is that we should alert the user that this will expose the service to the public if the cluster is capable of exposing services to the public, and require an additional confirmation in order to do this. We shouldn't try to detect if the cluster is capable of exposing public endpoints, since that is really difficult. Instead we should always show this warning.

  2. Not all Kubernetes clusters are capable of creating an ingress. They require an ingress controller. On minikube the ingress controller that is automatically set up is the nginx one. Maybe we should hide the UI option if the cluster is not OpenShift and doesn't have an ingress controller set up?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start by locating the existing Deployment context-menu actions and how devfile additional Kubernetes resources are managed. Define whether the feature creates a Route, an Ingress, or both, then cover lifecycle management, public-exposure confirmation, and the ingress-controller behavior described in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
kubernetes, typescript, vscode
Domain
cloud, devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.