I have installed a K8S cluster via Rancher and it is up and running. For testing purpose, I've deployed a helloworld nginx pod:
To call the service, I have to call the NodePort IP address, for example:
http://111.111.111.111:30359/
But I would like to call it by a name, for example:
https://helloworld.co.example.org
The ingress controller Nginx is installed:
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default kubernetes ClusterIP 10.43.0.1 <none> 443/TCP 162m
dev helloworld ClusterIP 10.43.187.230 <none> 80/TCP 17m
dev helloworld-nodeport NodePort 10.43.9.147 <none> 80:30359/TCP 17m
ingress-nginx default-http-backend ClusterIP 10.43.86.105 <none> 80/TCP 161m
kube-system kube-dns ClusterIP 10.43.0.10 <none> 53/UDP,53/TCP,9153/TCP 161m
kube-system metrics-server ClusterIP 10.43.220.198 <none> 443/TCP 161m
But it does not have EXTERNAL-IP
. The question is, how to get it.
A ClusterIP type service will never create an EXTERNAL IP because it's cluster-internal IP. Follow this guide on how to use nginx ingress on digital ocean to expose hello world app via a hostname.
Following the guide after you install the nginx ingress controller it will be exposed by a LoadBalancer provided by digital ocean.
As you can see in the guide you will use your domain in the ingress rules.You’ll need to ensure that your domain is pointed to the Load Balancer via A records. This is done through your DNS provider.
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: hello-kubernetes-ingress
annotations:
kubernetes.io/ingress.class: nginx
spec:
rules:
- host: helloworld.co.example.org
http:
paths:
- backend:
serviceName: hello-kubernetes
servicePort: 80