Azure Kubernetes Service does not currently have a way to automatically assign Public IPs to worker nodes/virtual machines. This project aims to solve this problem by utilizing a custom Kubernetes controller (based on sample-controller) and using Azure SDK for Go. The ID for the new Public IPs is always "ipconfig-" + name of the Node/Virtual Machine. It also assigns a Kubernetes Label to the Node, with name "HasPublicIP" and value "true".
(This is probably what you're using)
If you have an RBAC enabled cluster, just run:
kubectl create -n kube-system -f https://raw.githubusercontent.com/dgkanatsios/AksNodePublicIPController/master/deploy.yaml
# this gets created into *kube-system* namespace, change it on the deploy.yaml
else, run:
kubectl create -f https://raw.githubusercontent.com/dgkanatsios/AksNodePublicIPController/master/deploy-no-rbac.yaml
If you're looking for a non-Kubernetes native solution, you should check out the AksNodePublicIP project, it uses Azure Functions and Azure Event Grid technologies.
If you have created an AKS cluster using Virtual Machine Scale Set (VMSS) functionality, then the process is easier, since you don't need to deploy anything. What you need to do is:
- Visit resources.azure.com to view your deployed Azure resources
- Find the resource group where your AKS resources are deployed. It should have a name like
MC_aksInstanceName_aksResourceGroupName_dataCenterLocation
- Find and extend your VMSS information. VMSS should have a name like
aks-nodepool1-34166363-vmss
- Edit it and add the following JSON into
ipConfigurations.properties
section (source):
"publicIpAddressConfiguration": {
"name": "pub1"
}
To better understand where to place it, check here
- Press
Patch
orPut
on the UI. VMSS should now be configured so that newly created VMs get a Public IP by default - Execute a scale out and a scale in operation on the cluster so existing VMs get a Public IP
- Run
kubectl get node -o wide
and verify that all your Nodes have got a Public IP
To debug, you should run it like:
TENANT_ID=XXX SUBSCRIPTION_ID=XXX AAD_CLIENT_ID=XXX AAD_CLIENT_SECRET=XXX LOCATION=XXX RESOURCE_GROUP=XXX go run . --kubeconfig=~/.kube/config-aksopenarena
after getting the env details via this Pod:
apiVersion: v1
kind: Pod
metadata:
name: busybox
spec:
containers:
- image: busybox
command: ["cat","/akssp/azure.json"]
name: busybox
volumeMounts:
- name: akssp
mountPath: /akssp
restartPolicy: Never
volumes:
- name: akssp
hostPath:
path: /etc/kubernetes
type: Directory
kubect logs busybox -f
Kudos to Andreas Pohl for the guidance with VMSS