I'd like to expose some web services to be accessed from an external client in Kubernetes, many people recommended to use ingress. I've deployed an ingress controller following the guide: https://github.com/kubernetes/ingress-nginx/blob/master/docs/deploy/index.md.
I don't understand what's the next step to do, could anyone help explain the step with an example?
You need to create an Ingress resource and Service tied to that Ingress. For example for nginx ingress controller:
cat <<EOF
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
name: foo-boo
namespace: default
spec:
rules:
- host: foo.domain
http:
paths:
- backend:
serviceName: http-svc
servicePort: 80
path: /mypath
EOF | kubectl apply -f -
Then you can will able to see the ingress:
$ kubectl get ingress foo-boo
NAME HOSTS ADDRESS PORTS AGE
foo-boo foo.domain someloadbalancer.com 80 6d11h
Then you can test it with something like curl
:
$ curl -H 'Host: foo.domain' http://someloadbalancer.com/mypath
More about a Kubernetes Ingress here.