'Kubernetes pod failed to connect to external service

enter image description here

I have an Azure Kubernetes Cluster Running with Azure CNI (virtual network) as the Network. The cluster is running on 1 subnet of the network.

On another subnet, I have a Virtual Machine running as it has a private IP of 10.1.0.4.

Now I have a pod in the K8S cluster, which is trying to connect with the Virtual Machine. But it's not able to do so.

Also, the ping 10.1.0.4 from inside the pod gives a timeout.

Please help me to figure out, what I am doing wrong so that I can connect the Pod with the VM.



Solution 1:[1]

You cannot directly create communication between an AKS cluster pod and a Virtual Machine as the IP assigned to a pod/node in an AKS cluster is a subset range of the address space of the higher CIDR IP address range assigned while deploying the cluster. And communication within the cluster between the nodes is uninterrupted and possible readily. But the same with resources other AKS is restricted as they are governed by Azure CNI framework policy which directs the Kubernetes cluster to direct traffic outbound of the cluster in a regulated and conditional way.

• Thus, the above said can only be achieved by initiating intermediate services such as an internal load balancer between the AKS and the VMs as the CIDR of the VM and the AKS is different. So, leveraging the Azure plugin to deploy an internal load balancer as a service through AKS is only way through which you can achieve communication between AKS pod and a VM deployed in Azure. Below is a diagram for illustration purposes.

AKS with ILB

To deploy the internal load balancer through YAML files in AKS for external communication with VMs, kindly refer to the link below for details: -

https://fabriciosanchez-en.azurewebsites.net/implementing-virtual-machine-to-pod-communication-in-azure-kubernetes-service-aks/

Solution 2:[2]

1. A quick rule based solution: language-tool This library allows you to make to detect grammar errors and spelling mistakes

Example Usage:

import language_tool_python
tool = language_tool_python.LanguageTool('en-US')
text = 'A sentence with a error in the Hitchhiker’s Guide tot he Galaxy'
matches = tool.check(text)
len(matches)
2

Check out some Match object attributes:

matches[0].ruleId, matches[0].replacements # ('EN_A_VS_AN', ['an'])
('EN_A_VS_AN', ['an'])
matches[1].ruleId, matches[1].replacements
('TOT_HE', ['to the'])

Print a Match object:

print(matches[1])

Line 1, column 51, Rule ID: TOT_HE[1]
Message: Did you mean 'to the'?
Suggestion: to the

2 If this doesn't work for you, try deep learning based solutions. You will have to train a text classification model for sentence correctness. You can train your model on Corpus of Linguistic Acceptability (CoLA) dataset as explained in this tutorial for BERT. The colab-notebook may require some debugging. Another tutorial.

3. An even better solution would be to modify the T5 based sentence doctor. It attempts to correct the errors or mistakes found in sentences. You just need to know whether a sentence is correct or not, so you will have to modify the last layer of this model and then fine-tune. GPU memory might be a restriction as T5 is huge.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 KartikBhiwapurkar-MT
Solution 2 Abhi25t