Create Kong Service with Kong Ingress without Kubernetes Service

Ok, so I would like to do EXACTLY this:

curl -i -X POST \
  --url http://localhost:8001/services/ \
  --data 'name=example-service' \
  --data 'url=http://mockbin.org'

but using kong-ingress…

I know there is the External Service option, but this only supports the host (mockbin.org) and not the url (http://mockbin.org).
For me this causes some problems, because I can only specify that its supposed to be port 443, but not that its supposed to be https.

But since I create certificates in k8s via cert-manager, I need to create the kong service inside k8s… How can I do that?

External Service supports 443, you only need to add that

{{- if .Values.externalService.enabled }}
apiVersion: v1
kind: Service
metadata:
  name: {{ .Values.name }}
  annotations:
{{- if .Values.kong.enabled }}
{{- template "kong-service-annotations" . }}
{{- end}}
spec:
  type: ExternalName
  externalName: {{ .Values.externalService.externalName }}
  ports:
{{- if .Values.externalService.https.enabled }}
    - name: https
      port: 443
      targetPort: 443
{{- else }}
    - name: http
      port: 80
      targetPort: 80
{{- end }}
{{- end }}

But this would still leave the external service only requestion port 443, NOT https (there is a difference, since https port could be any other port than 443 as well)

Try adding below annotation to service -

konghq.com/protocol: “https”

Reference

1 Like

As anup.rai mentioned, setting the konghq.com/protocol annotation on the Service controls whether the controller will create an HTTP or HTTPS (or other protocol) Kong service.

The konghq.com/path annotation on a Service allows you to set the path to something other than /.

Both of these require vendor annotations because there’s no standard field in the Kubernetes Service or Ingress spec for them.

1 Like