- 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 pushthe 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
appand 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
applabel that was given to the deployment.
kubectl apply -f your-app.deployment.yml
kubectl apply -f your-app.service.ymlkubectl get svcYour 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 yourservicenameNote: If you are unsure of the service name, you can use
kubectl get svcto find it.
You can delete the deployment by doing:
kubectl delete deployment yourdeploymentnameNote: If you are unsure of the deployment name, you can use
kubectl get deploymentsto 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=joeVerify it!
kubectl config view | grep namespacekubectl config get-contextskubectl config use-context docker-desktopkubectl run -i --tty --rm debug --image=ubuntu --restart=Never -- bashRestart your computer.