Deploy to Kubernetes
using kubectl
Create ConfigMap from config files¶
A ConfigMap stores K8s-specific configuration that can be mounted as volume or used in env variables. It is often used to provide production configuration: application configuration, log settings, etc...
kubectl create configmap app-conf --from-file=<path to config files> # create a ConfigMap from multiple files in the same directory.
- Check the ConfigMap
Create a Kubernetes secret¶
You may need a Secret to store database passwords and secret keys.
For applications using the Play Framework, generate a secret using:
secretText = $(sbt playGenerateSecret)
regex = "Generated new secret: (.+)$"
f [[ $secretText =~ $regex ]]
then
secret = "${BASH_REMATCH[1]}"
echo $secret
kubectl create secret generic application-secret --from-literal=application_secret=$secret
kubectl get secrets
else
echo "$secretText doesn't match" >&2
fi
done
Create Resources (Deployment, Service, Ingress, etc...)¶
- Verify proper resource creation
- To delete a resource later, in this case a Deployment:
Install an Ingress Controller¶
- An ingress controller is necessary to make Ingresses work. See the Ingress doc
Minikube¶
minikube
provides its own ingress controller via the Ingress add-on:
Enabling the add-on provisions the following:
- a configMap for the Nginx loadbalancer
- the Nginx ingress controller
- a service that exposes a default Nginx backend pod for handling unmapped requests.
Install the nginx ingress controller (non-minikube Kubernetes)¶
- Install via this helm chart
or with stat collection enabled for Prometheus
helm install --name nginx-ingress-release stable/nginx-ingress \
--set controller.stats.enabled=true \
--set controller.metrics.enabled=true
- Verify that the Ingress exists
See explanations and documentation
The nginx ingress controller requires a 404-server like this
Alternative ingress controllers¶
- Install https://traefik.io/