Skip to content

rounakraj8/kubernetes-101

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Demo project to Dockerize a Java(Spring Boot) application & run it on a Kubernetes(K8) cluster

Prerequisites:

This article assumes that you have:

Steps:

2. Write a Dockerfile

3. Build the Docker image locally with some tag.

    docker build -t rounakraj8/demo:latest .

4. Push the Docker image to any container registry(eg. DockerHub, AWS ECR, GCR).

    docker push rounakraj8/demo:latest

5. Create the deployment

    kubectl create deployment demo --image=rounakraj8/demo:latest

Alternatively, you can create deployment.yaml file and achieve the same results using kubectl apply -f deployment.yaml command.

6. Create the service

    kubectl expose deployment demo --name=demo --port=80 --target-port=8080 --type=LoadBalancer

Alternatively, you can create service.yaml file and achieve the same results using kubectl apply -f service.yaml command.

7. Scale the deployment

    kubectl scale deployment demo --replicas=2      

8. Test the service

    To test this setup/demo, you will have to hit the hello API.
    After creating the service, this service will get an external/public API(This may take couple of minutes).
    Once you get the IP, you can hit `http://xxx.xxx.xxx.xxx/hello/someName`.
    If you get `Hello! SomeName` as response, then you have successfully completed the demo.

9. Delete the created service

    kubectl delete svc demo

10. Delete the created deployment

    kubectl delete deployment demo

Presentation

Basic Kubernetes commands
Basic Docker commands

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •