Kubernetes
In the Kubernetes cluster, we want to connect to the Pod we can use the “port-forward” to achieve the port forwarding. However, we have many Pods need to connect. We can use the Service to connect.
An abstract way to expose an application running on a set of Pods as a network service. Every Pod get its own IP address, however in Deployment the Pod may be create or delete. The IP address of Pod will be changed.
<NodeIP>:<NodePort>
.If we want to create a service on k8s we need to create a deployment first.
kubectl apply -f demo-deployment.yml
Then use
kubectl expose deploy blue-nginx --type=NodePort --name=my-deployment-service
to create Service.
We also can use the yaml file to create Service.
Now we can use
<Node IP>:<Node Port>
to connect the Pod.
An API object that manages external access to the services in a cluster, typically HTTP. Ingress may provide load balancing, SSL termination and name-based virtual hosting.
When we have many services, there have many ports to manage. If we want to easy to manage. We can use the Ingress.
Follow this figure, we can see the how service and Ingress to work.
Use the ingress we only just use the hostname, then we can connect to the Pod. Because the ingress can automatically distribute. In Kubernetes there have no ingress-controller, so we need to install the ingress-controller.
(Installation guide https://hackmd.io/@CharlieChan/SkKXtrSgv)
We can use this yaml file to create the Ingress.
Than we can use the
kubectl get ingress
to get the information. If we use the ingress, we need to edit the/etc/hosts
let the DNS Server to find the hostname.
Now we can type the
blue.demo.com
on browser, then we can see the picture like this.
https://medium.com/@C.W.Hu/kubernetes-implement-ingress-deployment-tutorial-7431c5f96c3e
https://kubernetes.io/docs/concepts/services-networking/ingress/