Horizontal Pod Autoscaler
- This allows to autoscale pods based on metrics
- Refer Here for offical docs
- Refer Here for the changes


Scheduling in K8s using taints and tolerations
- There are certain cases where you would want to run a pod on specific set of nodes.
- Refer Here
- Refer Here for the article on taints and tolerations
- Lets taint some node with poc
kubectl taint nodes <node-name> poc=true:NoSchedule
#aws
kubectl taint nodes ip-10-0-1-119.us-east-2.compute.internal poc=true:NoSchedule
for other nodes
kubectl taint nodes ip-10-0-1-199.us-east-2.compute.internal poc=false:NoSchedule
kubectl taint nodes ip-10-0-3-230.us-east-2.compute.internal poc=false:NoSchedule
# azure
kubectl taint nodes aks-nodepool1-42348830-vmss000000 poc=true:NoSchedule
- Ensure all the nodes are tainted and then apply
-
Refer Here for the changes done in the Pod to tolerate the taint on the node
-
You can also schedule Pods on specific node by nodeSelector property in Pod spec which matches exact labels
---
apiVersion: v1
kind: Pod
metadata:
name: node-selector
spec:
nodeSelector:
beta.kubernetes.io/os: linux
containers:
- image: nginx:1.23
name: nginx-container
ports:
- containerPort: 80
Annotations
- Annotations are also key value pairs, they are used by the tools i.e. aks or eks to extend functionality
- Refer Here for offical docs
- azure ingress annotations Refer Here
- AWS Loadbalancer annotations Refer Here
- Lets use annotations to create internal load balancer in azure
---
apiVersion: v1
kind: Service
metadata:
name: nginx-svc-lb
annotations:
service.beta.kubernetes.io/azure-load-balancer-internal: "true"
spec:
type: LoadBalancer
selector:
app: nginx
ports:
- name: webport
port: 35000
targetPort: 80
apiVersion: v1
kind: Service
metadata:
name: nginx-svc-lb
annotations:
kubernetes.io/role/internal-elb: "1"
spec:
type: LoadBalancer
selector:
app: nginx
ports:
- name: webport
port: 35000
targetPort: 80
Ingress and Ingress Controller
- Ingress in Layer 7 load balancer.
- When we need path based or hostname based routing we can use ingress.
- Ingress supports layer7 lb with in k8s cluster but to expose this functionality outside of k8s cluster it needs ingress controller.
- k8s doesnot have default ingress controller.
- There are many free ingress controller
- nginx ingress controller
- haproxy ingress controller
- contour ingress controller
- All the cloud providers have layer 7 lb they support cloud specific ingress controller
- aws supports application load balancer ingress controller
- azure supports application gateway ingress controller.
- azure aks ingress controller
apiVersion: v1
kind: Pod
metadata:
name: aspnetapp
labels:
app: aspnetapp
spec:
containers:
- image: "mcr.microsoft.com/dotnet/core/samples:aspnetapp"
name: aspnetapp-image
ports:
- containerPort: 80
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
name: aspnetapp
spec:
selector:
app: aspnetapp
ports:
- protocol: TCP
port: 80
targetPort: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: aspnetapp
annotations:
kubernetes.io/ingress.class: azure/application-gateway
spec:
rules:
- http:
paths:
- path: /
backend:
service:
name: aspnetapp
port:
number: 80
pathType: Exact