Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

SETUP & CONFIGURATION

DOCKER-DESKTOP & KUBERNETES DASHBOARD UI:


STEP 1: In docker.com, download Docker-Desktop for windows, Install and wait for the docker to start. Then go to
settings, in the Kubernetes [Enable Kubernetes].

Step 2- Then, install WSL on windows and start with Docker commands.

To setup Kubernetes Dashboard UI – refer https://dev.to/devcrafter91/how-to-install-kubernetes-on-windows-10-55b6


NOTE: Sometimes, you may get the docker-desktop and Kubernetes status as stopped. So, please troubleshoot it with
the option “RESET TO FACTORY DEFAULT”.
It’ll start.
DOCKER COMMANDS:
STEP -1: Create a spring-boot application. Create the docker file for that spring application.
STEP-2: Create a docker hub login using the link- https://hub.docker.com/
STEP-3: Now to create Docker Image use command – {docker build -t [image name]}
STEP-4: After, the image has been created, you view whether the image has been successfully created using the
command line – {docker images}
STEP-5: Now you can tag the image to the repository using the command line – {docker tag [image name] [docker-
username/repository name]}
STEP-6: You can push the image to the repository using command line – {docker push [docker-
username/repository name]}
STEP-7: If you have too many images in the repository you can use the tag name to pull the particular image.
STEP-8: To run the docker image use, - {docker run -p 8080:8080(or the port you prefer) [docker-
username/repository name]}
If you do so, it’ll automatically run the project and you see the endpoint is running. These are the docker commands
you need to run.
Also refer: https://www.youtube.com/watch?v=SzbeDqBSRkc
KUBERNETES COMMANDS: [using kube-controller]
In here we’re going to use the many engines to deploy the application in Kubernetes like,
 You can enable Kubernetes using Docker-desktop
 You can use local workspaces such as minikube, kubemicro etc.,
 You can deploy an application in Kubernetes via cloud platforms such as google cloud[GKE compute
engines], AWS[EC2, Elastic Compute Cloud] and Azure[virtual machines].
In here, I have used Google cloud platform and the API is Google Kubernetes engine. Now let us go with the steps
and command to deploy an application in GKE.
GKE PLATFORM SETUP:
STEP-1: [HOW TO START WITH GOOGLE CLOUD ACCOUNT]

 To start with the Google cloud, we need a google free trial account. Make sure that you're logged into your
Google account and go to the website https://cloud.google.com
 Once you are there, you can click the button, Get started for free. On the next screen, you get to choose your
country and make sure that you read the Terms of Services and agree to them.
 This Google free trial account gives you $300 credit and also free access to a number of Google services for
about 12 months.
 One of the interesting things is, Google does not auto charge you after the free trial ends. Now, when you
click Continue on this page, you land up on the next page where you need to enter a lot of information.
 You need to choose your account type; you need to enter your tax information. After that, you'd be asked to
enter your address information, you'd need to choose how you'd want to pay your bills, and you can choose
your payment method;
 Now, you can enter your card details in here. While you are entering the card details, Google might want to
verify your card. So, they have different processes based on which country you are in.
 So, make sure that you go through the verification processes. In some of the countries, they might even do a
trial transaction to make sure that your credit card is valid.
 Once you go through all the payment details, you need to click this START MY FREE TRIAL button which
is present on the screen. It will take a while for everything to be done, probably about a minute.
 Your Google Cloud account comes with 12 months of free trial for some of the Google Cloud service and
also, it comes with $300 credit. So, let's make the best use of it to learn Kubernetes.
 In this step, we quickly created our Google Cloud account. Let's get started with using it in the next step.

STEP-2: [CREATE CUSTER ND USE COMMAND LINES]

 Now that we understood this, let us get down to creating a cluster.


 When we created our Google Cloud account, is the page where we ended up on. You can also get to the page
by going to cloud.google.com and over there, you can click Console.
 Sure, that you are choosing the “My First Project”. By default, this should be already chosen. Make sure that
you are inside the My First Project. And what we'd want to now start doing is to enable something called a
Kubernetes engine.
 Once you click the Kubernetes Engine icon, it would take a little while before the Kubernetes Engine is
activated. Until a little while, you will see that the create Cluster button is actually disabled and it might take a
minute and after that, you would see that the Create cluster button is enabled.
 You have Clusters where you can create clusters and manage them. You have Workloads where you can
manage the applications or the containers that you would want to deploy into the cluster.
 Other than that, you have Services & Ingress. Some of your workloads may actually be REST API or web
applications.
 You'd want to provide access to external world to these workloads and that's where services come into picture.
Services give external world access to applications which are deployed into Kubernetes clusters.
 Other than that, there are a few other things that your workloads need: configuration to store your application
configuration, storage to provide persistent data storage for your application.
 let's get started with creating a cluster. When you're creating a cluster, you would need to choose how
powerful your cluster is and where it should be located. You will need to choose the type of nodes you want,
the number of nodes you want, and their location.
 Let's take the defaults and get started. Let's click Create cluster. It would take a little while and this page
would load up. You make sure that you are inside first project. A project actually makes it very easy to
manage your resources in the cloud.
STEP-3: [MAKE USE OF THE CREATED CLUSTER]
In this step, we’ll start make sure of the cluster that we’ve created. After creating a “Standard Cluster”, now you have
to connect it with the Cloud Console, for that press those vertical 3 dots, click on Connect.
Copy the “gcloud” command and paste it in the cloud shell. Now your cluster has been connected to the Cloud Shell.
So that you can use “kubectl” to make changes to the cluster
Also refer Youtube video link: https://www.youtube.com/watch?v=rTNR7vDQDD8&t=675s
If you want to dig deeper, you can also go through the Udemy courses: https://tm.udemy.com/course/kubernetes-
crash-course-for-java-developers/learn/lecture/16905428#overview
Some of the basic commands that you can use in Cloud Shell:
Commands:
1. To know the kubectl version that has been installed in your system, you can use

kubectl version
2. To create a deployment of an application, inside the cluster by passing an image via public docker Hub you
can use,

kubectl create deployment cluster-name - -image=image path:tag-name


3. After the deployment has been created you have to expose it to the target port, to do so you can use,
Note: You use type Load Balancer, to give the external world access to your application;

kubectl expose deployment cluster-name - -type=LoadBalancer - -port=port-number


4. After the application has been deployed, In the Service and Ingress section you’ll get an end point, hit that end
point, once you hit the end point your application will be live.
5. If you want more than one instances, you could use the command to scale the deployment.

kubectl scale deployment cluster-name - -replicas=no of instances


6. To see whether the instances has been created, you can use

kubectl get pods


7. To see the events that has been taken placed in your cluster till now, you can use the commands

kubectl get events


(or)
kubectl get events - -sort-by.metadata.creationTimestamp
8. If you need to know more about pods, replica-sets you can use the commands,

kubectl explain pods (for pods)


kubectl explain rs (for replica-sets)
9. To get the pods, replica-sets, services and deployments you have created, you can use these commands

kubectl get rs (replica-sets)


kubectl get deployment (for deployment)
kubectl get services (for services)
10. To know what the pod is made of, if you want the description you can use,

kubectl describe (pods, services, replica-sets)


11. If you want to get more details on the pods, replica-sets, services deployments that you’ve create you can use,

kubectl get (pods, services, replica-sets, deployments) -o wide


12. If you want to delete any of the instances that you have created you can use,

kubectl delete pod [pod-name]


13. If you want to fluctuate the no. of instances to your application based on the load coming, you can auto scale
your deployment using the command.

kubectl autoscale deployment cluster-name - -max=no of instances - -cpu-percent=70


14. If you want to check, what happens if you set a wrong image to your container, you can try this command and
see the rs and check the events.

kubectl set image deployment cluster-name container-


name=DUMMY_IMAGE:TEST(wrong image)
15. If you want to set a new image to the already deployed container, you can use this command.

kubectl set image deployment cluster-name container-name=image path: tag-name


16. If you try to get the deployment of the particular container (or) cluster, you ca use

kubectl get deployment cluster/container-name


17. To get more details on the particular deployment you can use the command line,

kubectl get deployment cluster/container-name -o wide


18. To see the deployment file of the cluster deployed, you can use

kubectl get deployment container-name -o yaml


19. To copy the deployment yaml file to the spring-boot microservice, you can use this command line

kubectl get deployment container-name -o yaml> deplyment.yaml


20. To copy the service yaml file to the spring-boot microservices, you can use this command line

kubectl get service container-name -o yaml> service.yaml


21. If you want to delete all the details that has been created for the particular container, you can use

kubectl delete all -l app=container-name


22. If you want to get all the details of the container you can use,

kubectl get all


23. To record the operation of the deployment, you can use the command –
- -record=true
24. To view the rollout history of a deployment you can use this command line

kubectl rollout history deployment/container-name


25. To check the rollout status of the deployment of the particular container/cluster, you can use this command
line

kubectl rollout status deployment container-name


26. To undo the rollout that has been done to the deployment, you can use this command line

kubectl rollout undo deployment container-name - -to-revision=no you want to rollback


27. If you want to change the version of the application you have already deployed, you should first edit the
deployment using

kubectl edit deployment cluster-name


28. The deployment.yaml file will be displayed, in the spec section(specification section), you have to add a line
of code {minReadyseconds=15} , after writing the code save it using {-wq}, this solution works with
90% of the scenarios. Now we can go ahead and execute the last command that points to the another version,
but note you have create an image for that new release and tag it to the repository already.

kubectl set image deployment cluster-name container-name=image path: tag-name


Likewise, you can perform various operations and modification via Kubernetes to your microservice application. If
you want to know more about Kubernetes, you can go through this Udemy courses:

https://tm.udemy.com/course/kubernetes-crash-course-for-java-
developers/learn/lecture/16905428#overview
If you guys have any doubts you can go through the above references and please feel free to contact us.

THANK YOU!!!

You might also like