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

Is it possible to define a --domain only? #156

Closed
jarlarntzen opened this issue Nov 6, 2020 · 4 comments
Closed

Is it possible to define a --domain only? #156

jarlarntzen opened this issue Nov 6, 2020 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@jarlarntzen
Copy link

kubefwd services --namespace "namespace" --context "dev-cluster" --domain 'remote'
results in: " Adding custom domain remote to all forwarded entries"

So in addition to connecting to servicename:80 we can also connect to servicename.remote:80

Now, is it possible to somehow define that we should only be able to connect to servicename.remote:80?

The reason I'm asking is that if we're debugging a service locally, we'd like to port forward to the rest of the services running on the remote cluster using a different URL instead of the same name as the local services. This way 1 of the services can run locally, being accessible through servicename:80 while the rest of the services are accessible through servicename.remote:80 .

Is this possible to invoke through a CLI flag?

@ghost
Copy link

ghost commented Dec 25, 2020

I'd actually like to use this for localhost as my remote as currently it seems kubefwd is using local only and only localhost works around CORS issues properly in a local dev environment. An example of one such issue which is throwing a 500 on my machine when domain=localhost isn't a host file entry:

error invalid_request
error_description The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed
error_hint Redirect URL is using an insecure protocol, http is only allowed for hosts with suffix localhost, for example: http://myapp.localhost/.
state Plje6kkFntJSrpC4u80B6gD4

Screen Shot 2020-12-25 at 10 56 15 AM

Screen Shot 2020-12-25 at 11 00 27 AM

EDIT

Got clever and tried deploying my chart to a localhost namespace as a workaround and using kubefwd with -n localhost but unfortunately trying to access http://servicename.localhost causes an ERR_EMPTY_RESPONSE with unprimed cache.

@cjimti
Copy link
Member

cjimti commented Mar 8, 2021

@balibebas my team uses ingress annotations to allow localhost website development to access forwarded API services. If you use ingress nginx you might want to try the following annotations:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: web-site
  namespace: customerx
  annotations:
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/cors-allow-methods: "PUT, GET, POST, OPTIONS"
    nginx.ingress.kubernetes.io/cors-allow-origin: "http://localhost:3000"

@cjimti cjimti self-assigned this Mar 17, 2021
@cjimti cjimti added the enhancement New feature or request label Mar 17, 2021
@cjimti
Copy link
Member

cjimti commented Mar 17, 2021

@jarlarntzen this should probably not be that hard to implement, kubefwd only added the short names to services on the first cluster. I'll take a look at this.

@cjimti
Copy link
Member

cjimti commented Sep 23, 2021

Every service forwarded gets the following entries in `/etc/hosts':

[service-name] 
[service-name].[namespace]
[service-name].[namespace].svc 
[service-name].[namespace].svc.cluster.local
[service-name].[namespace].svc.[context]
[service-name].[namespace].svc.cluster.[context]

You can create any number contexts in your ~/.kube/config file:

  - context:
    name: funcluster
      cluster: funcluster
      namespace: fun
      user:  me
  - context:
    name: localhost
      cluster: funcluster
      namespace: fun
      user:  me

@cjimti cjimti closed this as completed Sep 23, 2021
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
Development

No branches or pull requests

2 participants