Join my course at Udemy (Python Programming Bible-From beginner to advanced )

Blogger templates

Tuesday, 7 January 2025

44/45. Env / ConfigMaps

44. Env variables

ENV variables can be defined under ENV 



Other ways to define ENV variables

  • config-map - Value is taken from outside
  • Secrets - Value is taken from outside.




ConfigMaps

When there are too many ENV files then it is better to define all variables in a seperate file in KEY/VALUE format.

How to create config-maps ( 2 ways ) 

- imperative and declarative.




Imperative way to create config-map






Declarative way for config-map




View Configmap




Config map in yaml file



Different ways of config-map






Share:

37/38/40. Container Images

37. Define, Build and Modify Container Images.

Why ?

Created one application and we want to dockerize the application.

What are the steps if we have to deploy our application manually ?

- Deploy OS
- Update apt repo
- Install dependency using apt
- Install python dependency using pip
- Copy source folder to /opt
- Run web server using flask command.

Docker file with file name = <file-name>

FROM Ubuntu   [FROM -> Instruction, Ubuntu->Argument] <---- Install OS

RUN apt-get update                                   <------------ Install Dependencies
RUN apt-get install python

RUN pip install flask
RUN pip install flask-mysql

COPY . /opt/source-code                         <--- Copy source Code.

ENTRYPOINT FLASK_APP=/opt/source-code/app.py flask run   <-- Specify Entry Point.


Build docker

docker build <docker-file> -t <TAG>

PUSH Docker

docker push <TAG>

38. Command and Arguments in Docker ( CMD, ENTRYPOINT )






40. Command and Argument in K8















Share:

Sunday, 15 December 2024

Registration Request ( PCAP ) & 5G Index link

Registration request


https://www.sharetechnote.com/html/5G/5G_Registration.html#Case_A_NormalRegistration

PDF : https://www.eventhelix.com/5G/standalone-access-registration/details/5g-standalone-access-registration.pdf

PDF : https://www.eventhelix.com/5G/standalone-access-registration/5g-standalone-access-registration.pdf

Spec Details : https://www.sharetechnote.com/html/5G/5G_RadioProtocolStackArchitecture.html


RedCap : https://www.sharetechnote.com/html/5G/Handbook_5G_Index.html

5G Index for Share Note : https://www.sharetechnote.com/html/5G/Handbook_5G_Index.html

NGAP Message

NG Application Protocol (InitialUEMessage)
    NGAP-PDU: initiatingMessage (0)
        initiatingMessage
            procedureCode: id-InitialUEMessage (15)
            criticality: ignore (1)
            value
                InitialUEMessage
                    protocolIEs: 5 items
                        Item 0: id-RAN-UE-NGAP-ID
                            ProtocolIE-Field
                                id: id-RAN-UE-NGAP-ID (85)
                                criticality: reject (0)
                                value
                                    RAN-UE-NGAP-ID: 2768240640
                        Item 1: id-NAS-PDU
                            ProtocolIE-Field
                                id: id-NAS-PDU (38)
                                criticality: reject (0)
                                value
                                    NAS-PDU: 7e004179000d0164f0110fff000000000000102e04f0f0e0e02b0100
                                        Non-Access-Stratum 5GS (NAS)PDU
                                            Plain NAS 5GS Message
                                                Extended protocol discriminator: 5G mobility management messages (126)
                                                0000 .... = Spare Half Octet: 0
                                                .... 0000 = Security header type: Plain NAS message, not security protected (0)
                                                Message type: Registration request (0x41)  <-- Type of message ( If NAS_5GS_MSG_REGISTRATION_REQ then TMSI allocation is done
                                                5GS registration type
                                                    .... 1... = Follow-On Request bit (FOR): Follow-on request pending
                                                    .... .001 = 5GS registration type: initial registration (1)
                                                NAS key set identifier
                                                    0... .... = Type of security context flag (TSC): Native security context (for KSIAMF)
                                                    .111 .... = NAS key set identifier: 7
                                                5GS mobile identity
                                                    Length: 13
                                                    0... .... = Spare: 0
                                                    .000 .... = SUPI format: IMSI (0)
                                                    .... 0... = Spare: 0
                                                    .... .001 = Type of identity: SUCI (1)
                                                    Mobile Country Code (MCC): China (460)
                                                    Mobile Network Code (MNC): Unknown (11)
                                                    Routing indicator: ?0
                                                    .... 0000 = Protection scheme Id: NULL scheme (0)
                                                    Home network public key identifier: 0
                                                    MSIN: 0000000001
                                                UE security capability
                                                    Element ID: 0x2e
                                                    Length: 4
                                                    1... .... = 5G-EA0: Supported
                                                    .1.. .... = 128-5G-EA1: Supported
                                                    ..1. .... = 128-5G-EA2: Supported
                                                    ...1 .... = 128-5G-EA3: Supported
                                                    .... 0... = 5G-EA4: Not supported
                                                    .... .0.. = 5G-EA5: Not supported
                                                    .... ..0. = 5G-EA6: Not supported
                                                    .... ...0 = 5G-EA7: Not supported
                                                    1... .... = 5G-IA0: Supported
                                                    .1.. .... = 128-5G-IA1: Supported
                                                    ..1. .... = 128-5G-IA2: Supported
                                                    ...1 .... = 128-5G-IA3: Supported
                                                    .... 0... = 5G-IA4: Not supported
                                                    .... .0.. = 5G-IA5: Not supported
                                                    .... ..0. = 5G-IA6: Not supported
                                                    .... ...0 = 5G-IA7: Not supported
                                                    1... .... = EEA0: Supported
                                                    .1.. .... = 128-EEA1: Supported
                                                    ..1. .... = 128-EEA2: Supported
                                                    ...0 .... = 128-EEA3: Not supported
                                                    .... 0... = EEA4: Not supported
                                                    .... .0.. = EEA5: Not supported
                                                    .... ..0. = EEA6: Not supported
                                                    .... ...0 = EEA7: Not supported
                                                    1... .... = EIA0: Supported
                                                    .1.. .... = 128-EIA1: Supported
                                                    ..1. .... = 128-EIA2: Supported
                                                    ...0 .... = 128-EIA3: Not supported
                                                    .... 0... = EIA4: Not supported
                                                    .... .0.. = EIA5: Not supported
                                                    .... ..0. = EIA6: Not supported
                                                    .... ...0 = EIA7: Not supported
                                                UE status
                                                    Element ID: 0x2b
                                                    Length: 1
                                                    0... .... = Spare: 0
                                                    .0.. .... = Spare: 0
                                                    ..0. .... = Spare: 0
                                                    ...0 .... = Spare: 0
                                                    .... 0... = Spare: 0
                                                    .... .0.. = Spare: 0
                                                    .... ..0. = N1 mode reg: UE is not in 5GMM-REGISTERED state
                                                    .... ...0 = S1 mode reg: UE is not in EMM-REGISTERED state
                        Item 2: id-UserLocationInformation
                            ProtocolIE-Field
                                id: id-UserLocationInformation (121)
                                criticality: reject (0)
                                value
                                    UserLocationInformation: userLocationInformationNR (1)
                                        userLocationInformationNR
                                            nR-CGI
                                                pLMNIdentity: 64f011
                                                    Mobile Country Code (MCC): China (460)
                                                    Mobile Network Code (MNC): Unknown (11)
                                                0000 0000 0000 0000 0000 0000 0000 0000 0001 .... = nRCellIdentity: 0x000000001
                                            tAI
                                                pLMNIdentity: 64f011
                                                    Mobile Country Code (MCC): China (460)
                                                    Mobile Network Code (MNC): Unknown (11)
                                                tAC: 136 (0x000088)
                        Item 3: id-RRCEstablishmentCause
                            ProtocolIE-Field
                                id: id-RRCEstablishmentCause (90)
                                criticality: ignore (1)
                                value
                                    RRCEstablishmentCause: mo-Signalling (3)
                        Item 4: id-UEContextRequest
                            ProtocolIE-Field
                                id: id-UEContextRequest (112)
                                criticality: ignore (1)
                                value
                                    UEContextRequest: requested (0)

Details

- Registration is first procedure that UE executes after being switched on.

When is it performed?

Initial registration 

UE to connect to network after Power ON

Periodic Registration

Used by UEs in CM-IDLE mode

Mobility registration

When UE moves out of registration area


Emergency Registration

Used by UE when it wants to register only for emergency services.


Sequence Diagram

Allocate TMSI-AmfUeNgapId

InputMessage type: Registration request (0x41)
If Message type: Registration request (0x41)  then allocate TMSI for NGAP -id 

PCAP:

297 47.530339 HTTP2 10.233.102.158 43564 10.233.102.134 8082 Magic, SETTINGS[0], WINDOW_UPDATE[0], HEADERS[1]: POST /amf-ueidgen/v1/allocate/tmsi-amfuengapid, DATA[1]

Response :
amf_ue_ngap_id
newly_allocated_tmsi

Insert Stickiness

Discover AUSF

- requester-nf-type
- target-nf-type
- requester-plmn-list
- target-plmn-list

337 47.556192 HTTP2 10.233.102.158 47684 10.233.102.136 8082 Magic, SETTINGS[0], WINDOW_UPDATE[0], HEADERS[1]: GET /nnrf-disc/v1/nf-instances?requester-nf-type=AMF&service-names=nausf-auth&target-nf-type=AUSF&target-plmn-list=%5B%7B%22mcc%22:%22460%22,%22mnc%22:%2211%22%7D%5D&requester-plmn-list=%5B%7B%22mcc%22:%22460%22,%22mnc%22:%2211%22%7D%5D&routing-indicator=0, DATA[1]

AUSF Interaction

1. AMF -> AUSF
379 47.577265 HTTP2/JSON 10.233.102.158 39124 10.233.102.151 8082 Magic, SETTINGS[0], WINDOW_UPDATE[0], HEADERS[1]: POST /nausf-auth/v1/ue-authentications, DATA[1], JSON (application/json)

{

"servingNetworkName": "5G:mnc011.mcc460.3gppnetwork.org",

"supiOrSuci": "suci-0-460-11-0-0-0-0000000001"

}


2. AUSF -> NRF to search UDM
395 47.582120 HTTP2 10.233.102.151 50558 10.233.102.136 8082 Magic, SETTINGS[0], WINDOW_UPDATE[0], HEADERS[1]: GET /nnrf-disc/v1/nf-instances?requester-nf-type=AUSF&service-names=nudm-ueau&target-nf-type=UDM&target-plmn-list=%5B%7B%22mcc%22:%22460%22,%22mnc%22:%2211%22%7D%5D&routing-indicator=0, DATA[1]

3. Generate Auth Data
423 47.596608 HTTP2/JSON 10.233.102.151 41954 10.233.102.186 8082 Magic, SETTINGS[0], WINDOW_UPDATE[0], HEADERS[1]: POST /nudm-ueau/v1/suci-0-460-11-0-0-0-0000000001/security-information/generate-auth-data, DATA[1], JSON (application/json)

4. Response ( UDM  -> AUSF )

439 47.607821 HTTP2/JSON 10.233.102.186 8082 10.233.102.151 41954 HEADERS[1]: 200 OK, DATA[1], JSON (application/json)

{

"authType": "5G_AKA",

"authenticationVector": {

"autn": "1eef1979cf8880000b1213b397c4fa6e",

"avType": "5G_HE_AKA",

"kausf": "8b18d5cc67cab8dacb6d9508e7c55a5ff9534851c2b672241fed0222d1b8a91f",

"rand": "48422b0173dac70601a7639e8fa3f021",

"xresStar": "407e46fc8df09518a2047ed2073f2745"

},

"supi": "imsi-460110000000001"

}



5. ( AUSF -> AMF )

447 47.620055 HTTP2/JSON 10.233.102.151 8082 10.233.102.158 39124 HEADERS[1]: 201 Created, DATA[1], JSON (application/3gpphal+json)

{

"5gAuthData": {

"autn": "1eef1979cf8880000b1213b397c4fa6e",

"hxresStar": "6cd18a485e84c7dbecb85fdeb1e40d4f",

"rand": "48422b0173dac70601a7639e8fa3f021"

},

"_links": {

"5g-aka": {

"href": "http://ausf-auth.radisys-ausf1:8082/nausf-auth/v1/ue_authentications/suci-0-460-11-0-0-0-0000000001"

}

},

"authType": "5G_AKA",

"servingNetworkName": "5G:mnc011.mcc460.3gppnetwork.org"

}



AMF -> UE  ( Authentication Request )

451 47.626693 NGAP/NAS-5GS 10.233.102.150 172.27.29.125 SACK (Ack=1, Arwnd=212992) , DownlinkNASTransport, Authentication request

NGAP-PDU: initiatingMessage (0)
    initiatingMessage
        procedureCode: id-DownlinkNASTransport (4)
        criticality: ignore (1)
        value
            DownlinkNASTransport
                protocolIEs: 3 items
                    Item 0: id-AMF-UE-NGAP-ID
                        ProtocolIE-Field
                            id: id-AMF-UE-NGAP-ID (10)
                            criticality: reject (0)
                            value
                                AMF-UE-NGAP-ID: 2021
                    Item 1: id-RAN-UE-NGAP-ID
                        ProtocolIE-Field
                            id: id-RAN-UE-NGAP-ID (85)
                            criticality: reject (0)
                            value
                                RAN-UE-NGAP-ID: 2768240640
                    Item 2: id-NAS-PDU
                        ProtocolIE-Field
                            id: id-NAS-PDU (38)
                            criticality: reject (0)
                            value
                                NAS-PDU: 7e0056000200002148422b0173dac70601a7639e8fa3f02120101eef1979cf8880000b1213b397c4fa6e
                                    Non-Access-Stratum 5GS (NAS)PDU
                                        Plain NAS 5GS Message
                                            Extended protocol discriminator: 5G mobility management messages (126)
                                            0000 .... = Spare Half Octet: 0
                                            .... 0000 = Security header type: Plain NAS message, not security protected (0)
                                            Message type: Authentication request (0x56)
                                            0000 .... = Spare Half Octet: 0
                                            NAS key set identifier - ngKSI
                                                .... 0... = Type of security context flag (TSC): Native security context (for KSIAMF)
                                                .... .000 = NAS key set identifier: 0
                                            ABBA
                                                Length: 2
                                                ABBA Contents: 0000
                                            Authentication Parameter RAND - 5G authentication challenge
                                                Element ID: 0x21
                                                RAND value: 48422b0173dac70601a7639e8fa3f021
                                            Authentication Parameter AUTN (UMTS and EPS authentication challenge) - 5G authentication challenge
                                                Element ID: 0x20
                                                Length: 16
                                                AUTN value: 1eef1979cf8880000b1213b397c4fa6e
                                                    SQN xor AK: 1eef1979cf88
                                                    AMF: 8000
                                                    MAC: 0b1213b397c4fa6e

UE -> AMF (Authentication Response)


NGAP-PDU: initiatingMessage (0)
    initiatingMessage
        procedureCode: id-UplinkNASTransport (46)
        criticality: ignore (1)
        value
            UplinkNASTransport
                protocolIEs: 4 items
                    Item 0: id-AMF-UE-NGAP-ID
                        ProtocolIE-Field
                            id: id-AMF-UE-NGAP-ID (10)
                            criticality: reject (0)
                            value
                                AMF-UE-NGAP-ID: 2021
                    Item 1: id-RAN-UE-NGAP-ID
                        ProtocolIE-Field
                            id: id-RAN-UE-NGAP-ID (85)
                            criticality: reject (0)
                            value
                                RAN-UE-NGAP-ID: 2768240640
                    Item 2: id-NAS-PDU
                        ProtocolIE-Field
                            id: id-NAS-PDU (38)
                            criticality: reject (0)
                            value
                                NAS-PDU: 7e00572d10407e46fc8df09518a2047ed2073f2745
                                    Non-Access-Stratum 5GS (NAS)PDU
                                        Plain NAS 5GS Message
                                            Extended protocol discriminator: 5G mobility management messages (126)
                                            0000 .... = Spare Half Octet: 0
                                            .... 0000 = Security header type: Plain NAS message, not security protected (0)
                                            Message type: Authentication response (0x57)
                                            Authentication response parameter
                                                Element ID: 0x2d
                                                Length: 16
                                                RES: 407e46fc8df09518a2047ed2073f2745  << Should match with  "xresStar": "407e46fc8df09518a2047ed2073f2745"

                    Item 3: id-UserLocationInformation
                        ProtocolIE-Field
                            id: id-UserLocationInformation (121)
                            criticality: ignore (1)
                            value
                                UserLocationInformation: userLocationInformationNR (1)
                                    userLocationInformationNR
                                        nR-CGI
                                            pLMNIdentity: 64f011
                                                Mobile Country Code (MCC): China (460)
                                                Mobile Network Code (MNC): Unknown (11)
                                            0000 0000 0000 0000 0000 0000 0000 0000 0001 .... = nRCellIdentity: 0x000000001
                                        tAI
                                            pLMNIdentity: 64f011
                                                Mobile Country Code (MCC): China (460)
                                                Mobile Network Code (MNC): Unknown (11)
                                            tAC: 136 (0x000088)

Share:

Tuesday, 19 November 2024

RedCap

3Gpp

Find document based on document number : 3GPP document search by file name | Netovate

RedCap

PPT Slide + Links : Beginners: Introduction to 5G Reduced Capability (RedCap) Devices

3GPP CRs : How to find RedCap in 3GPP

In Spec

23.501

Section 5.41 NR RedCap UEs differentiation


Section 5.3.2.3

The AMF may also determine more precise RAT Type information based on further information received from NGRAN:
- The AMF may determine the RAT Type to be LTE-M as defined in clause 5.31.20; or
- The AMF may determine the RAT Type to be NR using unlicensed bands, as defined in clause 5.4.8.
- The AMF may determine the RAT Type to be one of the RAT types for satellite access, as defined in
clause 5.4.10.
- The AMF may determine the RAT Type to be NR RedCap as defined in clause 5.41.

Section 5.41

5.41 NR RedCap UEs differentiation

This functionality is used by the network to identify traffic to/from UEs accessing over NR RedCap, e.g. for charging
differentiation.
An NR RedCap UE using NR shall provide an NR RedCap indication to the NG-RAN during RRC Connection
Establishment procedure as defined in TS 38.300 [27].
When the UE has provided an NR RedCap indication to the NG-RAN during RRC Connection Establishment, the NGRAN
shall provide an NR RedCap Indication to the AMF in the Initial UE Message (see clause 4.2.2.2.1 of
TS 23.502 [3] and TS 38.413 [34]).
When the AMF receives an NR RedCap Indication from NG-RAN in an Initial UE Message, the AMF shall store the
NR RedCap Indication in the UE context, consider that the RAT type is NR RedCap and signal it accordingly to the
SMSF during registration procedure for SMS over NAS, to the SMF during PDU Session Establishment or PDU
Session Modification procedure. The PCF will also receive the NR RedCap RAT type indication when applicable, from
the SMF during SM Policy Association Establishment or SM Policy Association Modification procedure.
During handover from E-UTRA to NR, the target NG-RAN (i.e. gNB) provides the NR RedCap indication to AMF in
NGAP Path Switch Request message during Xn handover, or NGAP Handover Request Acknowledge message during
N2 handover (including intra 5GS N2 handover and EPS to 5GS handover) based on the UE capability information
provided by the source RAN to the target RAN as specified in TS 38.300 [27].
The NFs interacting with CHF shall include the NR RedCap as RAT type.
Upon AMF change, the source AMF shall provide the "NR RedCap Indication" to the target AMF.












Share:

Tuesday, 17 September 2024

Kubernetes - Namespace

Kubernetes - Namespace

Default namespace created by Kubernetes 

  • kube-system
  • kube-public
  • default

How it is helpful ?

  • These different namespace 
    • can be used by same cluster for DEV and PROD environment.
    • they will have isolated resources between them so that DEV will have their own resource and PROD will have their own resource.
    • they will have their own policies that define who can do what
      • Each namespace has a max limit of resources and are not allowed to use more than its allowed limit. 
      • We can define policy such that for example, while working in DEV environment, we can't modify a resource of PRODUCTION.

Example usage of custom namespace. 

  • Dev
  • Test
  • Prod

How to name resources of a namespace?

  • Same namespace 
    • Resources in same namespace ca access via db-service
  • Different namespace
    • Resources in other namespace can access resources in other namespace via ( say DEV resources via - db-service.dev.svc.cluster.local 

Name details

db-service.dev.svc.cluster.local 
  • db-service - Name of the service
  • dev - namespace
  • svc - service
  • cluster.local - domain.
How to create Namspace Or Pod Inside Namespace
  • Create in default namespace
    • kubectl create -f pod-definition.yml -f
  • Create a particular namespace
    • kubectl create -f pod-definition --namespace dev
    • kubectl create -f pod-definition -n dev
  • Create a Namespace
    • kubectl create -f namespace-dev.yaml
    • kubectl create namespace dev
    • Sample Yaml file for Namespace
      • apiVersion: v1
      • kind: Namespace
      • metadata:
        • name: dev
  • Create POD under a namespace through Yaml file
    • apiVersion: v1
    • kind: Pod
    • metadata
      • name: myapp-pod
      • namespace: dev
      • label
        • app: myapp
        • type: front-end
      • spec
        • container:
          • name: nginx-container
          • image: nbinx
  • Accessing Namespace
    • Scenario -1 : Access default namespace
      • kubectl get pods 
      • kubectl get pods --namespace dev
      • kubectl get pods --namespace prod
  • Change the default namespace to namespace = dev
    • kubectl config set-context  $(kubectl config current-context) --namespace dev
    • kubectl get pods  <<<< This will show Pods from namespace = DEV.
    • kubectl get pods --namespace default << To access default namespace
    • kubectl get pods --namespace prod << To access PROD namespace
  • Resource Quota
    • Resources can be limited in a namespace.
      • apiVersion: v1
      • kind: ResourceQuota
      • metadata:
        • name: compute-quota
        • namespace: dev
      • spec:
        • hard:
          • pods: "10",
          • requests-cpu: "4"
          • requests-memory: 5Gi
          • limts-cpu: "10"
          • limits-memory: 10Gi









Share:

Thursday, 12 September 2024

Kubernetes- Deployment

Kubernetes- Deployment

- Defines how to deploy application in production environment.

Scenarios
  • Old instance running - Multiple Pod having applications are running in production environment.
  • New version of application is available - need to upgrade seamlessly- without any downtime.
    • Rolling update
      • For this we don't want to upgrade all of them at once as this may impact accessibility. 
      • One by one upgrade - And we might want to upgrade one after other.
    • In case of failure - we should be able to rollback the upgrade.
    • Multiple change to environment
      • Ex - Scaling the environment, Modifying resource allocation etc.
      • And this change should be done for all PODS together and then activated for all Pods as the same time.

Kubernetes Deployment

  • Comes at the top of the hierarchy.
    • Comes at top of Pod and Replica Set.
  • Available with
    • Rolling update
    • Undo changes
    • Pause changes
    • Resume changes

How to create deployment

Yaml file 

  • same as ReplicaSet except for change in KIND.


apiVersionapps/v1   
kind: Deployment      << Only change done for Deployment

metadata:
  name: myapp-replicaset
  labels:
    app: myapp
    type: front-end

spec:
  template:   <<< Here need to provide template for POD. We just to insert metadata + spec section of POD.
    metadata:
      name: myapp-pod
      labels:
        app: myapp
        type: front-end
    
    spec:   
      containers: 
        name: nginx-container
        image: nginx
  replicas: 3   <<< This is sibling of template
  selector:        
    matchLabels:
      type: front-end

Commands
















Share:

Tuesday, 27 August 2024

Kubernetes Architecture, POD, ReplicaSet & Replica Controller

 Kubernetes Architecture, POD, ReplicaSet & Replica Controller


1. Introduction

What is Node ? 

  •  Node is a machine - Physical or Virtual on which Kubernetes is installed,
  • Node is where containers will be launched by Kubernetes.
What will happen to Nodes in which application is running fails.
  • Application goes down -- Means Kubernetes goes down.
Why do we need to have more than one node OR Why do we need CLUSTER?
  • Because of one node on which Kuberneres is installed goes down then application will also go down. So for redundancy, we need to have more than one node.
  • So we have more than one node grouped together.
    • So even if one node goes down, application is still accessible from other nodes.
Now we have CLUSTER ? 
- So who is managing cluster ? 
- Where is the information about members of clusters stored ?
- How are nodes monitored ?
- When a node failed, how do u move workload of one node to other worked node ?

  • This is the work of Master node. ( M, S, M, F )
    • Manage, Store, Monitor, Failure Handling
When u install Kubernetes, what components are installed?
  •  Api server
    • Acts as Front end for kubernetes
    • User, Management Devices, Command Line interfaces
      • talk to API server to interact with Kubernetes cluster.
  • etcd
    • distributed, reliable key-value storage to store
      • all data used to manage cluster.
      • Also implements locks in the cluster, so that there is no conflict

  • kubelet
    • agent that runs on each node of the cluster.
    • makes sure that conatiners are running on nodes as expected.
  • container runtime
    • Underlying software that run containers.
      • For example - docker.
  • controller
    • Brain behind orchestration.
    • Responds when nodes, containers or end points goes down.
    • Take decision to bringup new containers in case of failure.
  • schedular
    • For distributing work across containers on various nodes.

Master & Worker Nodes


How some node became master and some node became worker nodes ?
- Master node that has 
  •     Kube-API server, becomes master node.
    • All information is stored in KEY-VALUE ( etcd ) store in master.
  • Master also has
    • controller and 
    • schedular
- Worked node has 
  •     kubelet agent, so it becomes worker node.
    • Through kubelet-agent worker node can interact with MASTER.
      • TO provide health information of worker node.
      • And CARRY out instruction from MASTER.

What is kubectl

- This is KUBE command line control
  • kubectl run
    • to install cluster
  • kubectl cluster-info
    • View information about cluster
  • kubectl get nodes 
    • To list all nodes of the cluster

Docker Vs Container




Docker 

- container solution.

Kubernetes 

  • kubernetes came to orchestrate docker. and they were tightly coupled.
  • But later Kubernetes provided a layer Container Runtime Interface ( CRI ) that can take into any container solution ex - docker, rkt, as long as they adhere to OCI standard (Open Container standard)
  • CRTICTL 
    • This is command line interface (CLI command) for CRI
    • This will work for any container intarface.

POD

Steps - 
- Application is built
- Has been put in docker image
- And Kubernetes can pull the image.

Aim 
- Deploy APplication
- In the form of containers
- On a set of machines
- That are configured as worker nodes.
- In a cluster

But
- Kubernetes does not deploy container directly, it has to be put in POD.

Scale up/down
- We can't add new container inside POD
  • We need to create new POD in same node.
  • We can create new POD and new Node.

Concept of multi-container pod
  • POD can have multiple container.
  • But generally they dont have multiple container of same kind
    • We can have hlper container
      • Ex - Processing file, 

YAML with Kubernetes

Creating POD using YAML based configuration file


Command to create a POD

kubectl create -f pod.yml

Mandatory Values in K8 yaml file

- apiVersion
    - Not a KEY/VALUE, we just pass a string
    - API version that we are using to create Kubernetes
        - Example value - v1 , app/v1

- kind 
    - Not a KEY/VALUE, we just pass a string
    - type of objext we are trying to create 
        - Example - POD, Service, ReplicaSet, Deployment

- Metadata
   - This is dictionary.
   - This is data of the object.
       -- Example - Name, Label etc
       -- Here 'name' and labels are dictionary. (have KEY/Value)
    - NAME and IMAGE are sibling
    - Under "MetaData" we can have only "name" and "label"
        - But under "label" we can define any "key". "value" pair.

- Spec
   -  'Spec' is a dictionary, So Add property under it.
   - Below 'spec', there is 'container'. 'container' is also a list/array 
         - because there can be multiple containers in a pod.
         - So first element in a list indicate that it is first item in the list ( - name )
   - Here name & spec is element inside 'container'


Replica Sets / Replica Controllers.

Replica Controllers

- Are the brain behind Kubernetes
- Have processes that
    - Monitor Kubernetes objects
    - And manage accordingly.

Question  - What is a replica and why do we need replication-controller ?

  •     Suppose we have a node + POD + Container running our application
  •     What will happen if our application crashes ?
  •     So users will no longer to access our application.

Solution

 - If we don't want any disruption, we will need to have multiple POD so that there will not disruption. Even if one fails, other POD will still be accessible.

    Replication Controller 

  •   helps running multiple instance of same POD in a Kubernetes cluster.
Two reasons for Replication Controller
  • High Availability
    •   And so it provides high availability.
    •   So if one pod goes down, replication controller quickly instantiates another pod.

  • Load Balancing
    • If demand increases, replication controller creates Pods
      • On same Node
      • Or No multiple Nodes.

Two terms - Replication Controller vs Replica Set

There is minor difference between both but more or less they are same.
  • Replication Controller - older way
  • Replica Set - newer way.

How to create Replication Controller - using Yaml file.

apiVersion: v1
kind: Replication Controller

metadata:
  name: myapp-rc
  labels:
    app: myapp
    type: fromt-end

spec spec defines what in inside the KIND. As POD is inside Replication Controller. So provide template of the Pod.
  template:   <<< Here need to provide template for POD. We just to insert metadata + spec section of POD.
    metadata:
      name: myapp-pod
      labels:
        app: myapp
        type: front-end
    
    spec:   
      containers: 
        name: nginx-container
        image: nginx

But we have something still missing. 

  • We have not specified how many PODs to be created? 
  • Or how many replicas of POD to be available all the time?
  • Solution : Add 'replicas: 3
apiVersion: v1
kind: Replication Controller

metadata:
  name: myapp-rc
  labels:
    app: myapp
    type: fromt-end

spec:   spec defines what in inside the KIND. As POD is inside Replication Controller. So provide template of the Pod.
  template:   <<< Here need to provide template for POD. We just to insert metadata + spec section of POD.
    metadata:
      name: myapp-pod
      labels:
        app: myapp
        type: front-end
    
    spec:   
      containers: 
        name: nginx-container
        image: nginx
replicas: 3   <<< This is sibling of template

How to create ReplicaSet - using Yaml file.

apiVersion: apps/v1    << Note for ReplicationController this is - v1
kind: ReplicaSet

metadata:
  name: myapp-replicaset
  labels:
    app: myapp
    type: front-end

spec:
  template:   <<< Here need to provide template for POD. We just to insert metadata + spec section of POD.
    metadata:
      name: myapp-pod
      labels:
        app: myapp
        type: front-end
    
    spec:   
      containers: 
        name: nginx-container
        image: nginx
replicas: 3   <<< This is sibling of template
selector:           << Only got replicaSet
  matchLabels:
    type: front-end

selector

Defines which POD fall in it.We can define multiple labels.

  • Can have labels of PODS define in the same definition
  • Can have labels defined somewhere else.

Labels & Selectors

  • Monitor POD of specified LABEL specified as part of matchLabels
  • Always keep the 3 replicas of the POD instance.
  • ReplicaSet is 'process' that monitors the PODS and if any POD fails, it creates new POD.

How ReplicaSet knows which POD to monitor ?

  • This is done by labels provided as part of matchLabels.





How to change replicas ?

Two commands
  • replace
  • scale


Share:

Feature Top (Full Width)

Pageviews

Search This Blog