AWS - Classic Load Balancer - CLB ¶
Step-00: Kubernetes Manifests ¶
#02-UserManagementMicroservice-Deployment-Service.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: usermgmt-microservice
labels:
app: usermgmt-restapp
spec:
replicas: 1
selector:
matchLabels:
app: usermgmt-restapp
template:
metadata:
labels:
app: usermgmt-restapp
spec:
initContainers:
- name: init-db
image: busybox:1.31
command: ['sh', '-c', 'echo -e "Checking for the availability of MySQL Server deployment"; while ! nc -z mysql 3306; do sleep 1; printf "-"; done; echo -e " >> MySQL DB Server has started";']
containers:
- name: usermgmt-restapp
image: stacksimplify/kube-usermanagement-microservice:1.0.0
ports:
- containerPort: 8095
env:
- name: DB_HOSTNAME
value: "mysql"
- name: DB_PORT
value: "3306"
- name: DB_NAME
value: "usermgmt"
- name: DB_USERNAME
value: "dbadmin" # RDS DB Username is dbadmin
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-db-password
key: db-password
livenessProbe:
exec:
command:
- /bin/sh
- -c
- nc -z localhost 8095
initialDelaySeconds: 60
periodSeconds: 10
readinessProbe:
httpGet:
path: /usermgmt/health-status
port: 8095
initialDelaySeconds: 60
periodSeconds: 10
#03-UserManagement-Service.yml
apiVersion: v1
kind: Service
metadata:
name: usermgmt-restapp-service
labels:
app: usermgmt-restapp
spec:
type: NodePort
selector:
app: usermgmt-restapp
ports:
- port: 8095
targetPort: 8095
nodePort: 31231
#04-ClassicLoadBalancer.yml
apiVersion: v1
kind: Service
metadata:
name: clb-usermgmt-restapp
labels:
app: usermgmt-restapp
spec:
type: LoadBalancer # Default - CLB
selector:
app: usermgmt-restapp
ports:
- port: 80
targetPort: 8095
Step-01: Create AWS Classic Load Balancer Kubernetes Manifest & Deploy ¶
- 04-ClassicLoadBalancer.yml
apiVersion: v1 kind: Service metadata: name: clb-usermgmt-restapp labels: app: usermgmt-restapp spec: type: LoadBalancer # Regular k8s Service manifest with type as LoadBalancer selector: app: usermgmt-restapp ports: - port: 80 targetPort: 8095
- Deploy all Manifest
# Deploy all manifests kubectl apply -f kube-manifests/ # List Services (Verify newly created CLB Service) kubectl get svc # Verify Pods kubectl get pods
AWS EKS - Elastic Kubernetes Service - Masterclass ¶
Step-02: Verify the deployment ¶
- Verify if new CLB got created
- Go to Services -> EC2 -> Load Balancing -> Load Balancers
- CLB should be created
- Copy DNS Name (Example: a85ae6e4030aa4513bd200f08f1eb9cc-7f13b3acc1bcaaa2.elb.us-east-1.amazonaws.com)
- Go to Services -> EC2 -> Load Balancing -> Target Groups
- Verify the health status, we should see active.
- Access Application
# Access Application http://<CLB-DNS-NAME>/usermgmt/health-status
Step-03: Clean Up ¶
# Delete all Objects created
kubectl delete -f kube-manifests/
# Verify current Kubernetes Objects
kubectl get all