How to expose GRPC service (.net core) in kubernetes using YAML through azure devops pipeline

Sanjib Adhikary 20 Reputation points
2024-02-09T07:49:36.06+00:00

        - name: Kestrel__EndpointDefaults           value: "Http2" and in service,   ports:   - name: http     protocol: TCP     port: 80     targetPort: 80   - name: https     protocol: TCP     port: 443     targetPort: 443   type: LoadBalancer   I have tried configuring in kube cluster ingress also but no luck

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
39,712 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sina Salam 12,011 Reputation points
    2024-02-13T16:47:05.47+00:00

    Hi @Sanjib Adhikary

    Welcome to the Microsoft Q&A and thank you for posting your questions here. For certainty! Despite your configuration in Kube cluster ingress without luck, your question is to know how to expose GRPC service (.net core) in kubernetes using YAML through azure devops pipeline.

    Let me start with this, in your provided Kubernetes Service YAML configuration, there is no issue related to an Ingress. The configuration specifically defines a Service with type LoadBalancer, which is a valid way to expose a gRPC service in Kubernetes. You did not provide why is not successful.

    However, to answer your question; expose a gRPC service (.NET Core) in Kubernetes using YAML through Azure DevOps pipeline, one of the best options is to use a Kubernetes Service with type LoadBalancer along with appropriate service configuration. The below six steps will guide you:

    1. Create your Kubernetes Service YAML file (service.yaml) to expose your gRPC service. For example:
       apiVersion: v1 # Use latest version
       kind: Service
       metadata:
         name: your-grpc-service
       spec:
         selector:
           app: your-app-label
         ports:
           - name: grpc
             protocol: TCP
             port: 50051  # Assuming your gRPC service listens on port 50051
             targetPort: 50051
         type: LoadBalancer
       
    
    • Integrate the deployment of this service YAML file into your Azure DevOps pipeline with necessary authentication and authorization.
    • In your Azure DevOps pipeline, use kubectl apply command to apply the Kubernetes Service YAML to your Kubernetes cluster. Example of your file will look similar to the following:
       task: Kubernetes@1 # Use latest version number incase is not the first.
         displayName: 'Apply Kubernetes Service'
         inputs:
           connectionType: 'Azure Resource Manager'
           azureSubscriptionEndpoint: 'your-azure-service-connection'
           command: 'apply'
           useConfigurationFile: true
           configurationType: 'filePath'
           filePath: 'path/to/your/service.yaml'
           arguments: '--prune --namespace your-namespace' # Add any additional arguments you may need
       
    
    • Once the service is applied, Kubernetes should provision a LoadBalancer in Azure. You should check your cloud provider's console to see if the LoadBalancer is created and if it's assigning external IP addresses correctly.
    • In Kestrel configuration, make sure that your gRPC service is configured to use HTTP/2 with Kestrel. You've mentioned that you've configured this, so ensure this configuration is correct.
    • Finally, after the LoadBalancer is provisioned, you should be able to access your gRPC service using the external IP provided by the LoadBalancer

    I hope this will be helpful! Do not hesitate to let me know if you have any other questions.

    Please remember to "Accept Answer" if answer helped, so that others in the community facing similar issues can easily find the solution. Best Regards. Sina


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.