We are currently evaluating the kong-ingress-controller to replace our current setup where we configuring the Kong instance through its API.
Our current kong instance is running version 1.3 with postgres storage.
The evaluation instance is running kong v1.3 in dbless mode and kong-ingress-controller v0.6
We have a pod exposing an api on port 8080, and a corresponding kubernetes service that load balance the pod also on port 8080
We are currently exposing the api through kong with the following config:
curl -i -X POST "http://localhost:8001/services/" \
-d "name=demo-service" \
-d "url=http://demo-service:8080/api"
curl -i -X POST "http://localhost:8001/services/demo-service/routes" \
-d "paths[]=/api/demo_service" \
-d "strip_path=true"
When we are trying to accomplish the same setup but with the kong-ingress-controller the service is exposed on port 80 and we have not found a way to change this. At a first stage we would like to continue using the kube-proxy for loadbalancing and according to the documentation this should be possible by annotating the service with ingress.kubernetes.io/service-upstream
Below you can find the relevant part of our configuration, where we annotate both the service and the Ingress with the kong configuration. In addition we have annotated the service with ingress.kubernetes.io/service-upstream
but kong will still keep port 80 as the service port, ignoring the servicePort from the Ingress.
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: demo
namespace: dev
annotations:
configuration.konghq.com: api
kubernetes.io/ingress.class: "kong"
spec:
rules:
- http:
paths:
- path: /api/demo_service
backend:
serviceName: demo-service
servicePort: 8080
apiVersion: configuration.konghq.com/v1
kind: KongIngress
metadata:
name: api
namespace: dev
proxy:
path: /api
route:
preserve_host: false
apiVersion: v1
kind: Service
metadata:
annotations:
configuration.konghq.com: api
ingress.kubernetes.io/service-upstream: 'true'
labels:
app: demo-service
name: demo-service
namespace: dev
spec:
ports:
- name: http
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: demo-service
type: ClusterIP
When verifying the setup through Kong’s admin api we get the following result:
curl -k https://localhost:8444/services
{
"next": null,
"data": [{
"host": "demo-service.dev.svc",
"created_at": 1569921353,
"connect_timeout": 60000,
"id": "1fca4d48-68cd-5c0f-a3f5-ca20027b1759",
"protocol": "http",
"name": "dev.demo-service.8080",
"read_timeout": 60000,
"port": 80,
"path": "\/api",
"updated_at": 1569921353,
"client_certificate": null,
"tags": null,
"write_timeout": 60000,
"retries": 5
}]
}
curl -k https://localhost:8444/routes
{
"next": null,
"data": [{
"strip_path": true,
"tags": null,
"updated_at": 1569921353,
"destinations": null,
"headers": null,
"protocols": ["http", "https"],
"created_at": 1569921353,
"snis": null,
"service": {
"id": "1fca4d48-68cd-5c0f-a3f5-ca20027b1759"
},
"name": "dev.demo.00",
"preserve_host": false,
"regex_priority": 0,
"id": "d54da5df-7dce-5143-aee0-7f500ea65430",
"sources": null,
"paths": ["\/api\/demo_service"],
"https_redirect_status_code": 426,
"methods": null,
"hosts": null
}]
}
So my question is how we could properly configure a different port than 80 for our service?