#00-namespace-LimitRange-default.ymlapiVersion:v1kind:Namespacemetadata:name:dev3---apiVersion:v1kind:LimitRangemetadata:name:default-cpu-mem-limit-rangenamespace:dev3spec:limits:-default:cpu:"500m"# If not specified default limit is 1 vCPU per container memory:"512Mi"# If not specified the Container's memory limit is set to 512Mi, which is the default memory limit for the namespace.defaultRequest:cpu:"300m"# If not specified default it will take from whatever specified in limits.default.cpu memory:"256Mi"# If not specified default it will take from whatever specified in limits.default.memorytype:Container
#03-UserManagement-ConfigMap.ymlapiVersion:v1kind:ConfigMapmetadata:name:usermanagement-dbcreation-scriptnamespace:dev3data:mysql_usermgmt.sql:|-DROP DATABASE IF EXISTS usermgmt;CREATE DATABASE usermgmt;
#04-mysql-deployment.ymlapiVersion:apps/v1kind:Deploymentmetadata:name:mysqlnamespace:dev3spec:replicas:1selector:matchLabels:app:mysqlstrategy:type:Recreatetemplate:metadata:labels:app:mysqlspec:containers:-name:mysqlimage:mysql:5.6env:-name:MYSQL_ROOT_PASSWORDvalueFrom:secretKeyRef:name:mysql-db-passwordkey:db-passwordports:-containerPort:3306name:mysqlvolumeMounts:-name:mysql-persistent-storagemountPath:/var/lib/mysql-name:usermanagement-dbcreation-scriptmountPath:/docker-entrypoint-initdb.d#https://hub.docker.com/_/mysql Refer Initializing a fresh instance volumes:-name:mysql-persistent-storagepersistentVolumeClaim:claimName:ebs-mysql-pv-claim-name:usermanagement-dbcreation-scriptconfigMap:name:usermanagement-dbcreation-script
#05-mysql-clusterip-service.ymlapiVersion:v1kind:Servicemetadata:name:mysqlnamespace:dev3spec:selector:app:mysqlports:-port:3306clusterIP:None# This means we are going to use Pod IP
Instead of specifying resources like cpu and memory in every container spec of a pod defintion, we can provide the default CPU & Memory for all containers in a namespace using LimitRange
apiVersion:v1kind:ResourceQuotametadata:name:ns-resource-quotanamespace:dev3spec:limits:-default:memory:"512Mi"# If not specified the Container's memory limit is set to 512Mi, which is the default memory limit for the namespace.cpu:"500m"# If not specified default limit is 1 vCPU per container defaultRequest:memory:"256Mi"# If not specified default it will take from whatever specified in limits.default.memorycpu:"300m"# If not specified default it will take from whatever specified in limits.default.cputype:Container
# Create All Objects
kubectl apply -f kube-manifests/
# List Pods
kubectl get pods -n dev3 -w
# View Pod Specification (CPU & Memory)
kubectl get pod <pod-name> -o yaml -n dev3
# Get & Describe Limits
kubectl get limits -n dev3
kubectl describe limits default-cpu-mem-limit-range -n dev3
# Get NodePort
kubectl get svc -n dev3
# Get Public IP of a Worker Node
kubectl get nodes -o wide
# Access Application Health Status Page
http://<WorkerNode-Public-IP>:<NodePort>/usermgmt/health-status