kubectl create-ingress - Create an ingress with the specified name
kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]
Options you will use
--rule=[]- Rule in format host/path=service:port[,tls=secretname]. Paths containing the leading character '*' are considered pathType=Prefix. tls argument is optional.
--class=- Ingress Class to be used
--default-backend=- Default service for backend, in format of svcname:port
--annotation=[]- Annotation to insert in the ingress object, in the format annotation=value
Examples
$ kubectl create ingress shop --class=nginx --rule="shop.lab/*=web:80"Prefix / -> web:80 (the trailing * makes it Prefix)
$ kubectl create ingress shop --rule="shop.lab/api=api:8080"no *: pathType Exact - /api/orders does NOT match
$ kubectl create ingress shop --rule="shop.lab/*=web:80,tls=shop-tls"TLS for shop.lab with secret shop-tls
Gotchas
- A path without a trailing * is Exact. This is the most common create-ingress mistake.
Try kubectl create-ingress in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.