I want to publish my website. I have created Azure Kubernetes Service on portal.azure.com but I don't have LoadBalancer:

Should I create a "Service" with type "LoadBalancer"? But I don't know what I should enter in "Port number" and "Target port". Could you tell me? Or maybe I should create "Ingress (preview)", not the "Service"?
On dev.azure.com during creating pipeline - Deploy to Azure Kubernetes Service I have choosen "8080" as a Service Port so maybe I should enter "8080" as a "Port Number" and "Target Port"?



To expose your website running on Azure Kubernetes Service, both ways are correct as I mentioned in the comment section, you can create a Service with type Load Balancer. In the Service manifest, you can specify the port number and target port for your website. If you have chosen "8080" as a Service Port during pipeline creation, then you should enter "8080" as the Port Number and Target Port. Here is an example manifest:
After you deploy the manifest, you can confirm that the Service is created, and the Load Balancer is configured using the following command:
When you view the service details, the public IP address created for this service on the load balancer is shown in the EXTERNAL-IP column. It might take a few minutes for the IP address to change from
<pending>to an actual public IP address.Let me take a flask app example that says This is a Hello World application using the below code.
Then containerize the app using docker and then build it using
docker build -t bravinwasike/flask-kubernetes .Output:
after that push the Docker image into my Azure container repository using the following commands:
then I deployed the containerized application to the created AKS cluster
Followed by creating a deployment and service (Load Balancer) yaml file that refers to the image that I just pushed in my acr
Deployment and service yaml file combined
then apply the yaml
Done.. Now when I do
kubectl get podsmy pods are upand my flask app is up and reachable via the load balancer.
Alternatively, you can use Ingress to expose your website as well. To use Ingress, you need to deploy an Ingress controller in your cluster. Here is an example Ingress manifest:
In this example, the Ingress controller listens on port 80 for requests to the host
my-website.com. Requests to the root path/are forwarded to themy-websiteservice on port 80. Thenginx.ingress.kubernetes.io/rewrite-targetannotation rewrites the URL path to remove the/prefix. You can deploy this manifest usingkubectl apply -f <filename>.References: