Friday, January 22, 2021

kubernetes - Deployment - Day 7

 Kubernetes - 1/22/2021

PoD/RC

Replication controller
- helps you to manage the replicas
- Replicas gurantee the number of desired replica.

This concept is obsulated and replaced by replicaset (RS)

They are very similar


Deployment
-----------
How we deploy POD in real world

Normally we don't deploy pod directly. We use through replication controller but we use deployment.

Its one type of keywork avialable in kubernetes.

> kc get deployment

Repo (HUB)
- You store your Image
- You can download (pull) and install

Image (Bundle together)
- App (php-code)
- Webserver
- OS





LAB
[root@master ~]# kc get deployment
NAME    READY   UP-TO-DATE   AVAILABLE   AGE
nginx   0/1     1            0           69d
[root@master ~]# kc get pods
NAME                    READY   STATUS    RESTARTS   AGE
al-pod                  0/1     Pending   0          44d
hello                   0/1     Pending   0          44d
mp-hellp                0/3     Pending   0          44d
myapp-pod               0/1     Pending   0          83d
mydb                    0/1     Pending   0          44d
nginx-f89759699-hxfnp   0/1     Pending   0          69d
p2-pod                  0/1     Pending   0          44d
secure-pod              0/1     Pending   0          44d
yo-namaste              0/1     Pending   0          44d
[root@master ~]# kc delete all --all
pod "al-pod" deleted
pod "hello" deleted
pod "mp-hellp" deleted
pod "myapp-pod" deleted
pod "mydb" deleted
pod "nginx-f89759699-hxfnp" deleted
pod "p2-pod" deleted
pod "secure-pod" deleted
pod "yo-namaste" deleted
service "kubernetes" deleted
deployment.apps "nginx" deleted
replicaset.apps "nginx-f89759699" deleted
[root@master ~]# kc get all
NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
service/kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP   2s
[root@master ~]#


========================

[root@master ~]# kc create deployment mydep --image=vimal13/apache-webserver-php
deployment.apps/mydep created
[root@master ~]# kc get deployment
NAME    READY   UP-TO-DATE   AVAILABLE   AGE
mydep   0/1     1            0           16s
[root@master ~]# kc get rc
No resources found in default namespace.
[root@master ~]# kc get rs
NAME               DESIRED   CURRENT   READY   AGE
mydep-6d7898999b   1         1         0       49s
[root@master ~]#


[root@master ~]# kc describe deployment mydep
Name:                   mydep
Namespace:              default
CreationTimestamp:      Fri, 22 Jan 2021 11:38:12 -0500
Labels:                 app=mydep
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               app=mydep
Replicas:               1 desired | 1 updated | 1 total | 0 available | 1 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:
  Labels:  app=mydep
  Containers:
   apache-webserver-php:
    Image:        vimal13/apache-webserver-php
    Port:         <none>
    Host Port:    <none>
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      False   MinimumReplicasUnavailable
  Progressing    True    ReplicaSetUpdated
OldReplicaSets:  <none>
NewReplicaSet:   mydep-6d7898999b (1/1 replicas created)
Events:
  Type    Reason             Age   From                   Message
  ----    ------             ----  ----                   -------
  Normal  ScalingReplicaSet  111s  deployment-controller  Scaled up replica set mydep-6d7898999b to 1
[root@master ~]#


Review the strategy: rolling upgrade

You can change it if you like


scale your pod

[root@master ~]# kc get rs
NAME               DESIRED   CURRENT   READY   AGE
mydep-6d7898999b   1         1         0       2m41s
[root@master ~]# kc scale deployment mydep --replicas=3
deployment.apps/mydep scaled
[root@master ~]# kc get deployment
NAME    READY   UP-TO-DATE   AVAILABLE   AGE
mydep   0/3     3            0           3m20s
[root@master ~]#
[root@master ~]# kc describe deployment mydep



[root@master ~]# kc delete deployment mydep
deployment.apps "mydep" deleted
[root@master ~]# kc get deploy
No resources found in default namespace.
[root@master ~]# kc get deployments
No resources found in default namespace.
[root@master ~]# kc get pods
No resources found in default namespace.
[root@master ~]# kc get rs
No resources found in default namespace.
[root@master ~]# kc get rc
No resources found in default namespace.
[root@master ~]#



mkdir lab
cd /lab
vi index.php
version1


hub.docker/com
search vimal12



vi Dockerfile
From vimal13/apache-webserver-php

COPY index.php /var/www/html/index.html

wq

# docker build -t vimal13/apache-webserver-php:lwv1 /dws2

# docket images | grep lwv1


Create on docker.hub
# docket login
enter your username:pw

# docket push vimal13/apache-webserver-php

It will uploaded to dockethub


No comments:

Post a Comment

Git branch show detached HEAD

  Git branch show detached HEAD 1. List your branch $ git branch * (HEAD detached at f219e03)   00 2. Run re-set hard $ git reset --hard 3. ...