Skip to content

Deploying application to Kubernetes cluster

Berat Postalcioglu edited this page Jan 7, 2023 · 2 revisions

Dependencies

Before starting you need to install 'minikube' 'kubectl' and 'docker' tools to your operating system.

Starting a Kubernetes cluster

minikube start --vm-driver=hyperkit --cpus=4 --memory=16384

Create a namespace

kubectl create namespace swe599-demo

Switch to minikube's docker environment

eval $(minikube docker-env)

Build docker images of each service

docker build -f html-operations/Dockerfile -t html-operations .
docker build -f html-syntax-checker/Dockerfile -t html-syntax-checker .
docker build -f html-beautifier/Dockerfile -t html-beautifier .

Validate images are successfully created

docker images

Applying ConfigMap and Secret file to Kubernetes

kubectl apply -f html-operations-configmap.yaml
kubectl apply -f html-operations-secret.yaml

Deploying services to Kubernetes

kubectl apply -f html-operations/deploy.yaml
kubectl apply -f html-syntax-checker/deploy.yaml
kubectl apply -f html-beautifier/deploy.yaml

Watch status of pods

kubectl get pod --namespace=swe599-demo --watch

Open application in the browser

minikube service -n swe599-demo html-operations-service

Inspect logs of pods

kubectl logs <podname> --namespace=swe599-demo -f

Delete deployments

kubectl delete deployments --namespace=swe599-demo html-operations
kubectl delete deployments --namespace=swe599-demo html-syntax-checker
kubectl delete deployments --namespace=swe599-demo html-beautifier

Delete services

kubectl delete services --namespace=swe599-demo html-operations
kubectl delete services --namespace=swe599-demo html-syntax-checker
kubectl delete services --namespace=swe599-demo html-beautifier

Delete Kubernetes cluster

minikube delete