I have a deployed a K8s cluster on AKS using Terraform. I am unable to expose the Python service I used with a LoadBalancer. Below are my files;
Cluster information:
Kubernetes version: 1.19.0
Cloud being used: Azure
Installation method: Terraform
deployment.yml
apiVersion: v1
kind: Namespace
metadata:
name: identity
namespace: default
---
apiVersion: v1
kind: Service
metadata:
name: identity-svc
namespace: default
labels:
name: identity-svc
env: dev
app: identity-svc
annotations:
service.beta.kubernetes.io/azure-load-balancer-resource-group: MC_identity-k8s-rg_identity-k8s-aks_westeurope
spec:
type: LoadBalancer
ports:
- name: http
port: 80
targetPort: 8000
selector:
app: identity-svc
---
apiVersion: v1
data:
.dockerconfigjson: 50aXR5MngwIn19fQ...
kind: Secret
metadata:
creationTimestamp: null
name: acr-secret
namespace: default
type: kubernetes.io/dockerconfigjson
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: identity-deploy
namespace: default
labels:
name: identity-app
spec:
replicas: 1
selector:
matchLabels:
app: identity-svc
template:
metadata:
namespace: default
labels:
app: identity-svc
spec:
imagePullSecrets:
- name: acr-secret
containers:
- name: identityservice
image: identityservice.azurecr.io/identityservice:${{ github.run_id }}
env:
- name: SECRET_KEY
value: ${secrets.SECRET_KEY}
- name: ALLOWED_HOSTS
value: ${secrets.ALLOWED_HOSTS}
- name: DATABASE_HOST
value: ${secrets.DATABASE_HOST}
- name: DEBUG
value: true
resources:
requests:
cpu: 0.5
memory: "500Mi"
limits:
cpu: 2
memory: "1000Mi"
ports:
- containerPort: 8000
name: http
imagePullPolicy: Always
restartPolicy: Always
service.yml
apiVersion: v1
kind: Service
metadata:
name: identity-svc
namespace: default
labels:
name: identity-svc
env: dev
app: identity-svc
spec:
selector:
app: identity-svc
type: LoadBalancer
ports:
- protocol: TCP
port: 80
targetPort: 8000
name: http
When I check kubectl logs I see the pod, service, endpoint are running as supposed to. But external IP as shown below doesn’t load up the Python app.
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
identity-svc LoadBalancer 10.0.145.221 51.105.173.89 80:31723/TCP 95m
kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 134m
What am I missing here? The only strange thing I see is the following;
admin@Azure:~$ nslookup identity-svc
Server: 168.63.129.16
Address: 168.63.129.16#53
** server can't find identity-svc: NXDOMAIN
My ultimate goal is just to expose my app on an external IP to test out.
I also tried implementing nginx ingress you can see the post about that here
I really appreciate your help, and can gladly provide any other information if needed. Thanks