Trying to make a Kubernetes deployment but can't seem to make sense on how to create the YAML?
Got the service running but can't seem to scale up on load?
Cookie cutter is here for the rescue.
Just install the cookiecutter package and generate a YAML ready for kubectl apply
.
All you need is a running Kubernetes cluster with metrics-server for this to work!
This repository is a cookiecutter template for creating Kubernetes deployment with CPU based Autoscaling. Default values deploy a simple flask based IMDB clone.
$ pip3 install cookiecutter --user
$ cookiecutter https://github.com/arjun921/cookiecutter-kubernetes-deployment.git
release_name [fmdb]: my-release-name
release_version [1.0.0]:
release_namespace [default]:
docker_image [arjun921/fmdb:latest]:
container_port [5000]:
expose_endpoint [example.com]: mycustomdomain.com
expose_path [/]:
expose_port [80]:
min_replicas [1]:
max_replicas [5]:
max_cpu_percentage [70]:
max_cpu [1024m]:
max_memory [512Mi]:
min_cpu [100m]:
min_memory [128Mi]:
$ kubectl cluster-info # ensure you are connected to your kubernetes cluster
$ kubectl apply -f my-release-name/
The above mentioned steps can deploy any containerized app with AutoScaling enabled.
The default paramters deploy an IMDB clone written with a flask backend.
release_name
- What the deployment should be named?release_version
- Deployment app versionrelease_namespace
- Kubernetes Namespace for deploymentdocker_image
- Docker image to deploy with tagcontainer_port
- The port at which your container exposes the serviceexpose_endpoint
-domainname.com
expose_path
- Path to the app. Could be something like/v1/api/open/
or default/
expose_port
- Which port to expose the endpoint at. Will correspond tomydomain.com:20415
min_replicas
- Minimum number of pods to deploy. Should be more than 1 for the service to be upmax_replicas
- Maximum number of pods that the autoscaler can spin upmax_cpu_percentage
- CPU Percentage in Integer, Min: 0 - Max: 100. The HPA kicks in if CPU utilization crosses the threshold.max_cpu
- Maximum allowed CPU in Millicores a pod is allowed to consumemax_memory
- Maximum allowed Memory in megabytes a pod is allowed to consumemin_cpu
- Minimum CPU in Millicores required by the pod without which the pod will not runmin_memory
- Minimum Memory in megabytes required by the pod