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

How can I configure service/path? #39

Closed
subicura opened this issue May 13, 2018 · 9 comments
Closed

How can I configure service/path? #39

subicura opened this issue May 13, 2018 · 9 comments

Comments

@subicura
Copy link
Contributor

subicura commented May 13, 2018

Is this a BUG REPORT or FEATURE REQUEST? (choose one):
Feature request

Kong Ingress controller version:
0.0.3

Kubernetes version (use kubectl version):
1.9.6

Environment:
Docker for mac

What happened:
I can't configure service/path.
I want to "http://localhost/sample" to "http://sample-http/external".

What you expected to happen:
Use Ingress or KongIngress .

Ingress (ingress.kubernetes.io/rewrite-target is not working)

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: sample-http
  annotations:
    ingress.kubernetes.io/rewrite-target: "/external"
spec:
  rules:
  - host: localhost
    http:
      paths:
      - path: /sample
        backend:
          serviceName: sample-http
          servicePort: 80

KongIngress (proxy/path is not working)

apiVersion: configuration.konghq.com/v1
kind: KongIngress
metadata:
  name: sample-http
proxy:
  path: /external
route:
  strip_path: true
@subicura
Copy link
Contributor Author

@ddy86
Copy link
Contributor

ddy86 commented May 14, 2018

You can try to add an annotation named "request-transformer.plugin.konghq.com" to the Ingress. see more info in https://github.com/Kong/kubernetes-ingress-controller/blob/master/deploy/minikube.md
I config the k8s Ingress like the guid and go right.

  • ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: proxy-from-k8s-to-mockbin
  namespace: kong
  annotations:
    request-transformer.plugin.konghq.com: |
      transform-request-to-mockbin
    jwt.plugin.konghq.com: |
      wechat-jwt
spec:
  rules:
  - host: foo.bar
    http:
      paths:
      - path: /request
        backend:
          serviceName: proxy-to-mockbin
          servicePort: 80
  • svc.yaml
kind: Service
apiVersion: v1
metadata:
  name: proxy-to-mockbin
  namespace: kong
spec:
  ports:
  - protocol: TCP
    port: 80
  type: ExternalName
  externalName: mockbin.org
  • request-transformer.yaml
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: transform-request-to-mockbin
  namespace: kong
config:
  remove:
    headers: host

@subicura
Copy link
Contributor Author

@Daiyoung thanks for reply!

But, I want to tranform "path".

For example, I create 2 api(service/route).

Is it possible to use request-transformer?

@ddy86
Copy link
Contributor

ddy86 commented May 14, 2018

@subicura kubernetes-ingress-controller for kong is released just a few days, the document is not very perfect. I also get some problems,like I can't create the jwt credential bound one consumer.
Yours issue is same to me, I will try again and then tell you.

subicura added a commit to subicura/kubernetes-ingress-controller that referenced this issue May 14, 2018
@elboletaire
Copy link

Sorry to revive this post but I can't get this working 😕

I'm trying to configure a service using the /doc path.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: html2doc-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - http:
      paths:
      - path: /doc
        backend:
          serviceName: html2doc-svc
          servicePort: 80

My service receives calls at /{format} where format can be, among others, pdf.

apiVersion: configuration.konghq.com/v1
kind: KongIngress
metadata:
  name: html2doc-kongingress
proxy:
  path: /
route:
  strip_path: true

Even after adding the above KongIngress controller nothing seems to change. When I call /doc I can see in my pod logs that it's trying to access /doc:

imatge

Am I doing something wrong? BTW sorry to bother you, I'm kinda newbie in k8s....

@elboletaire
Copy link

Ok, I got it... the Ingress controller and the KongIngress controller need to have the same metadata.name. BTW if anyone can confirm me I'm not doing something evil, I'll thank them.

@hbagdi
Copy link
Member

hbagdi commented Dec 19, 2018

@elboletaire That's correct.
Reference: https://github.com/Kong/kubernetes-ingress-controller/blob/master/docs/custom-resources.md#kongingress

@Raghavendarlokineni
Copy link

@elboletaire That's correct.
Reference: https://github.com/Kong/kubernetes-ingress-controller/blob/master/docs/custom-resources.md#kongingress

this seems to be a broken link now

@hbagdi
Copy link
Member

hbagdi commented Dec 2, 2020

this seems to be a broken link now

Here is the new one:
https://github.com/Kong/kubernetes-ingress-controller/blob/master/docs/concepts/custom-resources.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants