Latest Article

LearnITGuide.net really glad to help the beginners who are interested to learn the docker tool from basics to become an experienced level. So links are arranged in order to take you in a clear direction to follow. Go through the links one by one to understand the docker easily from beginning. Videos are also available for some topics. Make use of it, Share it with your friends and groups. We appreciate your feedback, Leave your comments if any.

What is Docker - Get Started from Basics - Docker Tutorial

1. What is Container, What is Docker on Container - Get Started
Document Link | Youtube Video Link

Topics Covered:
1. Why do we need containerization?
2. What is container?
3. Difference of conterization over virtualization
4. Advantages of container
5. What is docker on container?

2. What is Docker - Get Started from Basics - Docker Tutorial
Document Link | Youtube Video Link

Topics Covered:
1. What is Docker?
2. Why do we use Docker?
3. Docker Architecture?
4. Docker Components?

3. How to Install Docker on CentOS 7 / RHEL 7
Document Link | Youtube Video Link

Topics Covered:
1. How to enable repository for docker?
2. How to Install Docker using Yum command?
3. How to Start and Enable the Docker service?
4. How to Verify Docker information?

4. Working with Docker Images, Explained with Examples - Docker Tutorial
Document Link | Youtube Video Link

Topics Covered:
1. What is Docker Images?
2. How to Create or Customize a Docker Images?
3. How to get Docker Images?
4. How to pull / download docker images?
5. How to list available docker images?
6. How to know detailed information about a Docker Images?
7. How to get history of a Docker Images?
8. How to Save or Backup a Docker Images?
9. How to Restore a Docker Images from a Backup?
10. How to remove or delete Docker Images?

5. Dockerfile Instructions Explained with Examples
Document Link

[ads-post] Topics Covered:
1. What is Dockerfile?
2. Functions of Dockerfile
3. List of Dockerfile Instructions
4. Examples of Dockerfile Instructions

6. How to Write Dockerfile To Build Your Own Docker Images
Document Link | YouTube Video Link

Topics Covered:
1. What is Dockerfile?
2. Why Dockerfile is required?
3. How to write Dockerfile?

7. How to Run Docker Containers - Explained with Examples
Document Link | YouTube Video Link

Topics Covered:
1. How to run Docker Containers?
2. What are the different ways you can run Docker containers?
3. Different options to run Docker Containers?
4. What are the options to be used and when to use?

8. Create or Deploy your Own Private Docker Registry
Document Link | YouTube Video Link

Topics Covered:
1. How to generate a SSL/TLS certificate to secure our private docker registry?
2. How to run a docker registry container in docker host?
3. How to pull and push docker images from docker hub to our private docker registry?
4. How to configure all docker clients to use our private docker registry?

More topics will be added soon. stay connected with us on social networking sites and Subscribe our YouTube channel for more updates.

Support Us: Share with your friends and groups.

Stay connected with us on social networking sites, Thank you.
YouTube | Facebook | Twitter | Pinterest | Rss 
Relevant Incoming Searches : docker tutorial ppt, docker tutorial video, docker tutorial youtube, docker tutorial centos, docker tutorial linux, docker tutorial redhat, docker free training, docker, docker tutorial, docker Administration, docker training, docker Administration training, docker administration fundamentals, docker training, Professional docker training, docker training videos, docker training guides, docker tutorial for beginners, docker training videos, docker tutorials, docker online tutorials, docker training, docker components, docker wiki, docker download, docker architecture, docker free training, docker free tutorials, docker free online tutorial, docker free online training, docker best tutorial, docker, docker tutorial, best docker site, docker training, learning docker, docker explained, docker beginner tutorial, docker tutorial for beginners

As explained in the last tutorial, We can deploy the application in kubernetes by creating deployment, services and pods using kubectl commands or using YAML configuration files. Already we have explained how to create kubernetes deployment, service and pods using kubectl command. In this tutorial, we will explain you how to create Kubernetes Deployment, Pods and Service using yaml configuration files.

In the previous posts, already we have explained the below topics. Refer those links to understand this topic from basics.

What is Kubernetes - Learn Kubernetes from Basics
How to Install Kubernetes Cluster with Docker on Linux
Create Kubernetes Deployment, Services & Pods Using Kubectl
What is Docker - Get Started from Basics - Docker Tutorial
What is Container, What is Docker on Container - Get Started
How to Install Docker on CentOS 7 / RHEL 7
Docker Images Explained with Examples - Docker Tutorial
How to Run Docker Containers - Explained with Examples

Using YAML helps us to create more complex structures and apply it immediately on the fly. YAML files can be added to version control system to track the file changes. You can create number of yaml files for each application deployments, services, pods and so on.

Create Kubernetes YAML for Deployment, Service & Pods

Let's use the same example what we have used in the earlier tutorial i.e., to create a deployment for httpd web server, It should run a single container within a pod using a docker image "httpd" and it should listen on port 80. Then finally create a service yaml file to expose the port externally so that users will be able to access it.

Kubernetes - Create Deployment YAML file
Create a normal file with yaml extension and add some properties as below. Already, I have created a basic deployment file with below objects to create a pod with single apache webserver container using httpd image.
[root@kubernetes-master ~]# cat httpd-basic-deployment.yaml
kind: Deployment
apiVersion: apps/v1beta1
metadata:
  name: my-httpd
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: webservers
    spec:
      containers:
      - name: my-httpd-container1
        image: httpd
        ports:
        - containerPort: 80
We must start with,
kind - It specfies that, what are you going to achieve with this file (deployment, pod, service, secret, jobs, replication controller, replicaset).
apiVersion - It specifies the api version for the kind. "apps/v1beta1" is the apiVersion for "Deployment" kind. To know more about these apiVersion and kind details, refer this link here.
metadata - Information about the kind specified. Here, we defined only "name" key and its value, so your deployment name will be created as "my-httpd".
spec - Actual specification starts from here with number of replicas, template to be used for entire pods and so on.
replicas - Number of replicas will be created and distributed across the available worker nodes.
template - Template to be used for entire pods. Templates are simply definitions of objects to be replicated
metadata - This metadata only for pods. It can be used to filter or identify by the name given within labels when you have lot of pods.
spec - This specification used for containers including the name of the container, name of the image, ports to be exposed, storage volumes and etc,.

Apply the YAML for kubernetes deployment.
Use "kubectl apply" command to apply the yaml configuration file.
[root@kubernetes-master ~]# kubectl apply -f httpd-basic-deployment.yml
deployment.apps/my-httpd created
[root@kubernetes-master ~]#
Check the status of the deployment and pods to ensure the pod is created using yaml file.
[root@kubernetes-master ~]# kubectl get deploy -o wide
NAME       DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE       CONTAINERS            IMAGES    SELECTOR
my-httpd   1         1         1            1           2m        my-httpd-container1   httpd     app=webservers
Above command "kubectl get deploy" output shows some information about our deployment that, it is created with name "my-httpd", name of the containers (my-httpd-container1), name of the images (httpd) and selector which was used with labels (app=webservers).

Let's check the pod status,
[root@kubernetes-master ~]# kubectl get pod -o wide
NAME                        READY     STATUS    RESTARTS   AGE       IP            NODE                                  NOMINATED NODE
my-httpd-7bb768779c-m4k56   1/1       Running   0          3m        172.16.1.18   kubernetes-client1.learnitguide.net   <none>
[root@kubernetes-master ~]#
Above command "kubectl get pod" output shows that, one pod is running in worker node "kubernetes-client1.learnitguide.net" with IP address "172.16.1.18".

Now Login into worker node "kubernetes-client1.learnitguide.net" and use the command "curl" to check the webserver is working locally.
[root@kubernetes-master ~]# ssh kubernetes-client1.learnitguide.net
root@kubernetes-client1.learnitguide.net's password:
Last login: Wed Aug 15 13:16:16 2018 from 192.168.2.99
[root@kubernetes-client1 ~]# curl 172.16.1.18:80
<html><body><h1>It works!</h1></body></html>
[root@kubernetes-client1 ~]# exit
logout
Connection to kubernetes-client1.learnitguide.net closed.
[root@kubernetes-master ~]#
As expected, we are able to access the webserver locally. Let's create a service yaml file, so that it will expose the port "80" to the outside world and mapped the port to the container port (target port).

Kubernetes - Create Service YAML file
[ads-post]
Service is an endpoint that exposes the ports to the outside world and mapped the port to the container port (target port). Already, I have created a basic service yaml file with below objects to expose the port.
[root@kubernetes-master ~]# cat httpd-basic-service.yaml
kind: Service
apiVersion: v1
metadata:
  name: my-httpd-service
spec:
  selector:
    app: webservers
  type: LoadBalancer
  ports:
    - name: my-apache-port
      port: 8080
      targetPort: 80

We must start with,
kind - It specfies that, what are you going to achieve with this file (deployment, pod, service, secret, jobs, replication controller, replicaset).
apiVersion - It specifies the api version for the kind. "v1" is the apiVersion for "Service" kind. To know more about these apiVersion and kind details, refer this link here.
metadata - Information about the kind specified. Here, we defined only "name" key and its value, so your service name will be created as "my-httpd-service".
spec - Actual specification starts from here with selector name, type of the service and ports to be exposed with name, port and target port.
selector - We must specify the correct label name here what we have used while creating the deployment. else, it wont work properly.
type - Type of the service (ClusterIP, NodePort, LoadBalancer) - To know more about these type of service, refer this link here.
ports - Specify the name of the service port, port number and target port.

Apply the YAML file for kubernetes service.
Use "kubectl apply" command to apply the yaml configuration file.
[root@kubernetes-master ~]# kubectl apply -f httpd-basic-service.yml
service/my-httpd-service created
Check the status of service to ensure the service is created correctly as per the yaml file.
[root@kubernetes-master ~]# kubectl get svc -o wide
NAME               TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE       SELECTOR
kubernetes         ClusterIP      10.96.0.1        <none>        443/TCP          2d        <none>
my-httpd-service   LoadBalancer   10.105.115.116   <pending>     8080:30374/TCP   1m        app=webservers
Above command "kubectl get svc" output shows that, service "my-httpd-service" is created with LoadBalancer type, random port number (30374) and assigned to given selector. We know already that, the pod is running on worker node "kubernetes-client1.learnitguide.net". So we we will be able to access this using the URL "http://kubernetes-client1.learnitguide.net:30374" from other system if you are in the same network.
[root@kubernetes-master ~]# curl http://kubernetes-client1.learnitguide.net:30374
<html><body><h1>It works!</h1></body></html>
[root@kubernetes-master ~]#
That's it, Hope you have got an idea how to create deployments, services and pods in kubernetes cluster using yaml files. Going forward we will play more with kubernetes tool. Keep practicing and have fun. Leave your comments if any.

Also refer other articles,

What is Kubernetes - Learn Kubernetes from Basics
How to Install Kubernetes Cluster with Docker on Linux
Create Kubernetes Deployment, Services & Pods Using Kubectl
What is Docker - Get Started from Basics - Docker Tutorial
What is Container, What is Docker on Container - Get Started
How to Install Docker on CentOS 7 / RHEL 7
Docker Images Explained with Examples - Docker Tutorial
How to Run Docker Containers - Explained with Examples

Support Us: Share with your friends and groups.

Stay connected with us on social networking sites, Thank you.
YouTube | Facebook | Twitter | Pinterest | Rss
Incoming searches: Incoming searches: create kubernetes yaml, kubernetes create deployment yaml, kubernetes create service yaml, kubernetes create pods yaml, create kubernetes deployments, kubernetes deployments, create kubernetes services, kubernetes service, create kubernetes pods, kubernetes pod, kubernetes deployment tutorial, kubernetes deployment yaml, kubernetes deployment vs service, kubernetes deployment service, kubernetes deployment pods, kubernetes deployment examples, how to create kubernetes deployment, create kubernetes deployment yaml, kubernetes create service for deployment, kubernetes service yaml, kubernetes service expose, kubernetes pods example, deployment kubernetes, best kubernetes tutorial, best kubernetes course

We can deploy the application in kubernetes by creating deployment, services and pods using kubectl command or using yaml configuration files. In this tutorial, I will explain you how to create Kubernetes Deployment, Pods and Service using Kubectl.

In the previous posts, already we have explained the below topics. Refer those links to understand this topic from basics.

What is Kubernetes - Learn Kubernetes from Basics
How to Install Kubernetes Cluster with Docker on Linux
Create Kubernetes YAML for Deployment, Service & Pods
What is Docker - Get Started from Basics - Docker Tutorial
What is Container, What is Docker on Container - Get Started
How to Install Docker on CentOS 7 / RHEL 7
Docker Images Explained with Examples - Docker Tutorial
How to Run Docker Containers - Explained with Examples

Let's get started.

Create Kubernetes Deployment, Services & Pods Using Kubectl

What is Deployment in Kubernetes?
Deployment is a controller which manages the pods and It ensures the desired number of pods are always running.

What is Pod in Kubernetes?
Pod is a group of one or more containers for an application which runs on worker (minion) nodes.

For example, Let's create a deployment controller for httpd web server, It would run a single container within a pod using a docker image "httpd" and it will listen on port 80.

Our Lab Setup:
kubernetes cluster configuration
How to Create Deployment and Pods?
Once you have Working Kubernetes Cluster environment, Use "kubectl" command to create a Kubernetes Deployment. Else, Refer this article how to install kubernetes cluster on Linux.
[root@kubernetes-master ~]# kubectl run my-httpd --image=httpd --replicas=1 --port=80
deployment.apps/my-httpd created
Where, "kubectl run" is the command to run the deployment.
"my-httpd" - Used to define the name of the deployment controller
"--image=httpd" - Used to specify which image to be used for the container.
"--replicas=1" - Used to specify number of pods(replication) to be running.
"--port=80" - Used to specify the pods to listen on port 80 locally.

Check the status of deployment
Use "kubectl get deployment" command to display the status of deployments created.
[root@kubernetes-master ~]# kubectl get deployment
NAME       DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
my-httpd   1         1         1            1           30m

Above command gives us the status of deployment with,
NAME - Name of the deployment,
DESIRED - Number of Desired Pods,
CURRENT - Number of Current Pods,
UP-TO-DATE - Number of Pods are up-to-date,
AVAILABLE - Number of Pods are available
AGE - How long the pods are running.
[ads-post]
Also you can use above command with "-o wide" option to get additional details,
CONTAINERS - List of containers associated to this pods
IMAGES - List of Images used in this pods
SELECTOR - Name of the selectors.
[root@kubernetes-master ~]# kubectl get deployment -o wide
NAME           DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE       CONTAINERS     IMAGES            SELECTOR
my-httpd       1         1         1            1           32m       my-httpd       httpd             run=my-httpd
Check the status of Pods
Use "kubectl get pod" command to display the status of pods.
[root@kubernetes-master ~]# kubectl get pod
NAME                            READY     STATUS    RESTARTS   AGE
my-httpd-85fc77d457-cr8jl       1/1       Running   0          37m
Above command gives us the status of pods with,
NAME - Name of the pod,
READY - How many pods are ready out of total pods.
STATUS - Status of pods
RESTARTS - How many times it has restarted
AGE - How long the pods are running.

Again use "-o wide" option to get additional details,
IP - IP address of the pod assigned from the CIDR range been set already during the kubernetes setup, this IP address can be used to access the pod.
NODE - Name of the node on which pod is running.
NOMINATED - Name of the Reserved node.
[root@kubernetes-master ~]# kubectl get pod -o wide
NAME                            READY     STATUS    RESTARTS   AGE       IP           NODE                                  NOMINATED NODE
my-httpd-85fc77d457-cr8jl       1/1       Running   0          51m       172.16.1.2   kubernetes-client1.learnitguide.net   <none>
From above output, our "my-httpd" pod is running on worker node "kubernetes-client1.learnitguide.net" and it has got IP Address "172.16.1.2". So we would be able to access the httpd web server through this IP Address "172.16.1.2" only from the worker node "kubernetes-client1.learnitguide.net".

Let's Login into the Worker node "kubernetes-client1.learnitguide.net" and use "curl" command to check the pods are working fine and accessible.
[root@kubernetes-client1 ~]# curl 172.16.1.5:80
<html><body><h1>It works!</h1></body></html>
[root@kubernetes-client1 ~]#
As expected, it's working from the worker node. Lets create a service to expose the ports externally. so that, any users can access the pods from other systems.

What is Service in Kubernetes?
Service is an endpoint that exposes the ports to the outside world and mapped the port to the container port (target port).

Creating Kubernetes Service
Let's Create a Service to expose the deployment "my-httpd" to port 8080 and connects to the containers on port 80, this would assign a random port number. Using that port, we can access this pods externally.
[root@kubernetes-master ~]# kubectl expose deployment my-httpd --port=8080 --target-port=80 --type=LoadBalancer
Check the status of Service to find the random port number.
[root@kubernetes-master ~]# kubectl get svc
NAME         TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
kubernetes   ClusterIP      10.96.0.1        <none>        443/TCP          5h
my-httpd     LoadBalancer   10.110.252.204   <pending>     8080:31255/TCP   1m
Newly created service has got port number "31255" for "my-httpd" deployment and we know this pod is running on worker node "kubernetes-client1.learnitguide.net". Now we we will be able to access this using the URL "http://kubernetes-client1.learnitguide.net:31255". from other system if you are in the same network.
[root@lab-server ~]# curl http://kubernetes-client1.learnitguide.net:31255
<html><body><h1>It works!</h1></body></html>
[root@lab-server ~]# 
Confused with lot of ports? Simple!

kubernetes-client1.learnitguide.net:31255 --> kubernetes-client1.learnitguide.net:8080 --> 172.16.1.5:80.

This is what the purpose of service, It exposes the ports to the outside world with some random port and mapped the port to the target port, finally it redirects to the actual container port...

That's it, Hope you have got an idea how to create deployments, services and pods in kubernetes cluster.  Going forward we will play more with kubernetes tool. Keep practicing and have fun. Leave your comments if any.

Also refer other articles,

What is Kubernetes - Learn Kubernetes from Basics
How to Install Kubernetes Cluster with Docker on Linux
Create Kubernetes YAML for Deployment, Service & Pods
What is Docker - Get Started from Basics - Docker Tutorial
What is Container, What is Docker on Container - Get Started
How to Install Docker on CentOS 7 / RHEL 7
Docker Images Explained with Examples - Docker Tutorial
How to Run Docker Containers - Explained with Examples

Support Us: Share with your friends and groups.

Stay connected with us on social networking sites, Thank you.
YouTube | Facebook | Twitter | Pinterest | Rss
Incoming searches: create kubernetes deployments, kubernetes deployments, create kubernetes services, kubernetes service, create kubernetes pods, kubernetes pod, kubernetes deployment tutorial, kubernetes deployment yaml, kubernetes deployment vs service, kubernetes deployment service, kubernetes deployment pods, kubernetes deployment examples, how to create kubernetes deployment, create kubernetes deployment yaml, kubernetes create service for deployment, kubernetes service yaml, kubernetes service expose, kubernetes pods example, deployment kubernetes, best kubernetes tutorial, best kubernetes course

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget