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¶
minikubeprovides 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.
Alternative ingress controllers¶
- Install https://traefik.io/
Declarative Deployments (Kustomize)¶
Kustomize is built into kubectl and allows for template-free customization of YAML manifests.
To deploy a directory containing a kustomization.yaml file:
To view the generated native manifests without applying them: