Deploy and create Nginx service on kubernetes

Tram Ho

For deploying nginx to kubernetes, it’s like hello word of programming language. Then learn anything, learn, just run the first ?

From now on we will mostly work with this Master Node

Initialize .yaml file

paste the following

Finally run

So deploying finished, quite easy.

Check deploy is not

I got 2 pods

Now try deleting a pods to see what happens

Remember that nginx-deployment pods can be spread evenly across the other two worker nodes. The question is, what 1 server worker node is shutdown? I think this question can be found through this visual image ?

For example, the pod has the address 10.10.10.2 died due to worker node shutdown, it will automatically generate a new pods of 10.10.10.5 at another node and Service will still function normally.

then get pods then immediately a new pods created 9s before is almost preserved realtime

Run some commands to see how

result:

Now let’s try scale nginx-deployment and get pods and try =))

Details of service nginx-svc

result:

SSH into any worker node and run the following command

are welcome nginx ...

Want to access the browser, you need to change the type: ClusterIP => type: NodePort this will directly access the worker node (this way is warned not to use for security reasons). Another approach is to use the LoadBalancer type of cloud services such as AWS, Azure, Google Cloud or MetalLB software.

MetalLB provides network load balancing deployment for Kubernetes clusters that do not run on cloud service provider platforms, enabling the efficient use of the LoadBalancer Service in any cluster.

The final way to use Ingress tools such as kubernetes-ingress , nginx-ingress , traefik … to traefik out proxy routing rules inside kubernetes.

CleanUp

Delete service and deployment

Next

Use kubernetes-ingress with sample project to deploy that external network, browser can access. In the future, I will have part of kubernetes deploy using AWS loadbalancer and many utilities to shorten system configuration. Since learning DevOps is quite expensive in terms of funding, it takes a few dollars on AWS just to deploy kubernetes types. ?

facebook: facebook.com/quanghung997

Share the news now

Source : Viblo