- Have Docker Desktop installed
First things first, startup your own local Docker Registry on localhost:5000 by doing:
docker-compose up
- Click the Docker Desktop icon in the tray and select "preferences"
- Click Kubernetes
- Check "Enable Kubernetes"
- Click "Apply & Restart"
If you use VS Code, download the Kubernetes extension. It provides you with documentation on hover for each of the fields in a Kubernetes manifest.
- Write a Dockerfile for your app.
- Build and tag your image and remember to:
- Prefix it with the domain name/port if you want to deploy to a registry that isn't docker.io.
- Version it with a git tag or the commit hash.
docker push
the built image to a container registry.
- Copy the frontend.deployment.yml for now since it is pretty basic and has comments describing it.
- In the deployment.yml, make sure the container image name is set to the same name of the image
that was sent to the container registry via
docker push
. - Ensure that there is a label called
app
and it has a name representing this deployment.
Note: VS Code users who've installed the Kubernetes extension have access to snippets for generating Kubernetes yaml manifests.
- Copy the frontend.service.yml.
- Ensure that the selector has the
app
label that was given to the deployment.
kubectl apply -f your-app.deployment.yml
kubectl apply -f your-app.service.yml
kubectl get svc
Your application is deployed! You may now access it on your own host.
Let's delete the Kubernetes objects that were created in the above steps.
The service can be deleted by doing:
kubectl delete service yourservicename
Note: If you are unsure of the service name, you can use
kubectl get svc
to find it.
You can delete the deployment by doing:
kubectl delete deployment yourdeploymentname
Note: If you are unsure of the deployment name, you can use
kubectl get deployments
to find it.
This is useful when you have a shared cluster in the cloud, and you have an assigned namespace that you wish to use.
kubectl config set-context --current --namespace=joe
Verify it!
kubectl config view | grep namespace
kubectl config get-contexts
kubectl config use-context docker-desktop
kubectl run -i --tty --rm debug --image=ubuntu --restart=Never -- bash
Restart your computer.