AKS Cluster External IP - Azure SDK for Python

2/19/2019

I have an aks cluster deployed and assigned with an internal ip, but no external ip:

NAME               TYPE           CLUSTER-IP    EXTERNAL-IP      PORT(S)        AGE
kubernetes         ClusterIP      10.0.0.1      <none>           443/TCP        11h

I may be going about this the wrong way, but the goal is to create the external endpoints for the cluster IP. Would the correct approach using the python SDK be creating a service load balancer? I have been unsuccessful finding the azure python SDK for that. Some help, please.

My python function for creating the cluster:

def create_cluster(node_count):
    cluster_resource = container_client.managed_clusters.create_or_update(
        resource_group,
        cluster_name,
        parameters=ManagedCluster(
            location='eastus',
            dns_prefix = dns_prefix,
            tags=None,
            service_principal_profile = self.service_principal_profile,
            agent_pool_profiles=[{
                'name': 'agentpool',
                'vm_size': 'Standard_DS2_v2',
                'count': 3,
            }],
        ),
    )
    return cluster_resource
-- ghenzi83
azure
azure-aks
azure-kubernetes
azure-sdk-python
kubernetes

1 Answer

2/19/2019

This is not really a right approach. Right approach is creating a kubernetes services of type LoadBalancer:

kind: Service
apiVersion: v1
metadata:
  name: my-service
spec:
  selector:
    app: MyApp
  ports:
  - protocol: TCP
    port: 80
    targetPort: 9376
  type: LoadBalancer

that will create a load balancer and a public ip address for you. Topic is a bit complicated to just jump on it, but basically, kubernetes will managed those external endpoints for you, you only need to declare valid kubernetes primitives. You could precreate those, but it really makes no sense. Just let kubernetes do the hard work.

Reading:
https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer

-- 4c74356b41
Source: StackOverflow