Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

header-navigation
keyboard_arrow_up
list Table of Contents
file_download PDF
{ "lLangCode": "en", "lName": "English", "lCountryCode": "us", "transcode": "en_US" }
English
keyboard_arrow_right

Install cRPD on Kubernetes

date_range 12-Dec-24
Kubernetes is a open-source platform for managing containerized workloads and services. Containers are a good way to bundle and run the applications.

In a production environment, you need to manage the containers that run the applications and ensure that there is no downtime. For example, if a container goes down, another container needs to start. Kubernetes provides you with a framework to run distributed systems resiliently. Kubernetes provides a platform for deployment automation, scaling, and operations of application containers across clusters of host containers.

Prerequisite

Install Kubernetes on Linux system and to deploy Kubernetes on a two-node Linux cluster, see Kubernetes Installation.

When you deploy Kubernetes, you get a cluster. A Kubernetes cluster consists of a set of worker machines, called nodes, that run containerized applications. Every cluster has at least one worker node. The worker node(s) host the pods that are the components of the application.

This section outlines the steps to create the cRPD Docker image on Kubernetes.

Install Kubernetes

To install Kubernetes:

  1. Log in as root user.
  2. Download and install the software.
    content_copy zoom_out_map
    curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
    echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
    
    content_copy zoom_out_map
    apt-get update
    content_copy zoom_out_map
    apt-get install -y kubectl
    content_copy zoom_out_map
    wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
    content_copy zoom_out_map
    
    cp minikube-linux-amd64 /usr/local/bin/minikube 
    content_copy zoom_out_map
    chmod 755 /usr/local/bin/minikube
  3. Start Kubernetes.
    content_copy zoom_out_map
    apt install conntrack
    content_copy zoom_out_map
    root@crpd-01:~# minikube start --driver=none
    content_copy zoom_out_map
    * minikube v1.15.1 on Ubuntu 18.04
    * Automatically selected the docker driver
    ...
    

Kubernetes Cluster

Kubernetes coordinates a cluster of computers that are connected to work as a single unit. Kubernetes automates the deployment and scheduling of cRPD across a cluster in an efficient way.

A Kubernetes cluster consists of two types of resources:

  • The Primary coordinates the cluster

  • Nodes are the workers that run applications

The Primary is responsible for managing the cluster. The primary coordinates all activities in your cluster, such as scheduling applications, maintaining applications' desired state, scaling applications, and rolling out new updates.

A node is a VM or a physical computer that serves as a worker machine in a Kubernetes cluster. Each node has a Kubelet, which is an agent for managing the node and communicating with the Kubernetes master. The node should also have tools for handling container operations, such as Docker or rkt. A Kubernetes cluster that handles production traffic should have a minimum of three nodes.

When you deploy cRPD on Kubernetes, the primary starts the application containers. The primary schedules the containers to run on the cluster's nodes. The nodes communicate with the primary using the Kubernetes API, which the primary exposes. End users can also use the Kubernetes API directly to interact with the cluster.

A Pod always runs on a Node. A Node is a worker machine in Kubernetes and may be either a virtual or a physical machine, depending on the cluster. Each Node is managed by the Primary. A Node can have multiple pods, and the Kubernetes master automatically handles scheduling the pods across the Nodes in the cluster.

Every Kubernetes Node runs at least:

  • Kubelet, a process responsible for communication between the Kubernetes Master and the Node; it manages the Pods and the containers running on a machine.

  • A container runtime (like Docker, rkt) responsible for pulling the container image from a registry, unpacking the container, and running the application.

To create minikube cluster:

  1. Run the following command to verify the minikube version:
    content_copy zoom_out_map
    minikube version
    
  2. Run the following command to start the cluster:
    content_copy zoom_out_map
    minikube start
    
  3. Run the following command to verify if kubectl is installed:
    content_copy zoom_out_map
    kubectl version
    
  4. Run the following command to view the cluster details:
    content_copy zoom_out_map
    kubectl cluster-info
    
  5. Run the following command to view the nodes in the cluster:
    content_copy zoom_out_map
    kubectl get nodes
    

Download cRPD Docker Image

Prerequisites
  • Before you import the cRPD software, ensure that Docker is installed on the Linux host and that the Docker Engine is running.

  • Ensure to register with Juniper Support before you download the cRPD software.

To download the docker image:

  1. Log in to the Juniper Docker registry using the log in name and password that you received as part of the sales fulfillment process when ordering cRPD.
    1. Create the file -passwd.txt and copy the access token excluding the quotes provided by Juniper customer care team.
    2. Log in to enterprise hub using the following command:
      root@ubuntu-vm18$ cat passwd.txt | docker login -u"<registered-email-id>" --password-stdin enterprise-hub.juniper.net:443

      For example, root@ubuntu-vm18$ cat passwd.txt | docker login -u user@domain.com --password-stdin enterprise-hub.juniper.net:443

  2. Pull the docker image from the download site using the following command:

    root@dc-rpd-01# docker pull enterprise-hub.juniper.net:443/crpd-docker-prod/crpd:<release tag>

    For example,

    root@ubuntu-vm18:~# docker pull enterprise-hub.juniper.net:443/crpd-docker-prod/crpd:22.3R1

  3. Verify images in docker image repository.

    root@dc-rpd-01# docker images

    content_copy zoom_out_map
    REPOSITORY                                                                           TAG                             IMAGE ID       CREATED         SIZE   
    enterprise-hub.juniper.net:443/crpd-docker-prod/crpd                                 latest                          5d3c29ee4521   3 months ago    550MB
    enterprise-hub.juniper.net:443/crpd-docker-prod/crpd                                 22.3R1                          5dfdda6ea2de   5 months ago    461MB
    
    

Create a cRPD Pod using Deployment

A Kubernetes Pod is a group of one or more Containers, tied together for the purposes of administration and networking. A Kubernetes Deployment checks on the health of your Pod and restarts the Pod’s Container if it terminates. Deployments are the recommended way to manage the creation and scaling of Pods.

When you describe a desired state in a Deployment, and the Deployment Controller changes the actual state to the desired state. You can define Deployments to create new ReplicaSets, or to remove existing Deployments and adopt all their resources with new Deployments.

  1. Create the crpd.yaml file on Kubernetes-master and add the following text content:
    content_copy zoom_out_map
    apiVersion: apps/v1
    kind: Deployment
    metadata:
       name: crpd
       namespace: default
       labels:
         app: crpd
    spec:
       selector:
         matchLabels:
           app: crpd
       template:
         metadata:
           labels:
             app: crpd
           annotations:
             deployment.kubernetes.io/revision: "1"
           generation: 2
         spec:
           containers:
           - name: crpd
             image: "enterprise-hub.juniper.net/crpd-docker-prod/crpd:20.1R1.11"
             imagePullPolicy: ""
           imagePullSecrets:
           - name: routing-registry
  2. Save the crpd.yaml file to create the cRPD Pod.

    root@kubernetes-master:~# kubectl create -f crpd.yaml

    content_copy zoom_out_map
    deployment.apps/crpd created
  3. Run the following command to view the list of existing Pods:

    root@kubernetes-master:~# kubectl get pods

    content_copy zoom_out_map
    NAME                    READY   STATUS    RESTARTS   AGE
    crpd-5fc4fd79df-579cn   1/1     Running   0          71s
  4. Run the following command to view what containers are inside that Pod and what images are used to build the containers:

    root@kubernetes-master:~# kubectl describe pod crpd

    content_copy zoom_out_map
    Name:         crpd-5fc4fd79df-579cn
    Namespace:    default
    Priority:     0
    Node:         ix-crpd-01/10.102.70.153
    Start Time:   Mon, 28 Dec 2020 19:12:33 +0000
    Labels:       app=crpd
                  pod-template-hash=5fc4fd79df
    Annotations:  deployment.kubernetes.io/revision: 1
    Status:       Running
    IP:           172.17.0.3
    IPs:
      IP:           172.17.0.3
    Controlled By:  ReplicaSet/crpd-5fc4fd79df
    Containers:
      crpd:
        Container ID:   docker://a211f6993f9ab5793c3de5aaef2c97ba600b991bebd801f947f179e8e915a323
        Image:          enterprise-hub.juniper.net/crpd-docker-prod/crpd:20.1R1.11
        Image ID:       docker-pullable://enterprise-hub.juniper.net/crpd-docker-prod/crpd@sha256:1e82c06654caf47aa22e4a020b8bea02562fa25ba7abe80affab998199ae69ab
        Port:           <none>
        Host Port:      <none>
        State:          Running
          Started:      Mon, 28 Dec 2020 19:12:55 +0000
        Ready:          True
        Restart Count:  0
        Environment:    <none>
    Mounts:
          /var/run/secrets/kubernetes.io/serviceaccount from default-token-xcpf7 (ro)
    Conditions:
      Type              Status
      Initialized       True 
      Ready             True 
      ContainersReady   True 
      PodScheduled      True 
    Volumes:
      default-token-xcpf7:
        Type:        Secret (a volume populated by a Secret)
        SecretName:  default-token-xcpf7
        Optional:    false
    QoS Class:       BestEffort
     Node-Selectors:  <none>
     Tolerations:     node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                     node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
    Events:
      Type    Reason     Age   From               Message
      ----    ------     ----  ----               -------
      Normal  Scheduled  97s   default-scheduler  Successfully assigned default/crpd-5fc4fd79df-579cn to ix-crpd-01
      Normal  Pulled     79s   kubelet            Container image "enterprise-hub.juniper.net/crpd-docker-prod/crpd:20.1R1.11" already present on machine
      Normal  Created    74s   kubelet            Created container crpd
      Normal  Started    72s   kubelet            Started container crpd

Create a cRPD Pod using YAML

A Pod is the basic execution unit of a Kubernetes application–the smallest and simplest unit in the Kubernetes object model that you create or deploy. A Pod represents a unit of deployment: a single instance of an application in Kubernetes, which might consist of either a single container or a small number of containers that are tightly coupled and that share resources. Docker is the most common container runtime used in a Kubernetes Pod.

You can directly create a Pod or indirectly use a Controller in Kubernetes. A Controller can create and manage multiple Pods. Controllers use a Pod template that you provide to create the Pods. Pod templates are pod specifications which are included in other objects, such as Replication Controllers, Jobs, and DaemonSets.

To create the cRPD pod using the YAML file

  1. Create the crpd.yaml file on Kubernetes-master add the following text content:
    content_copy zoom_out_map
    ------------------
    apiVersion: v1
    kind: Pod
    metadata:
      name: crpd
      labels:
        app: crpd
    spec:
      containers:
      - name: crpd
        image: "enterprise-hub.juniper.net/crpd-docker-prod/crpd:20.1R1.11"
        imagePullPolicy: ""
        ports:
        - containerPort: 179
        securityContext:
          privileged: true
    
    ------------------
  2. Save the crpd.yaml file to create the crpd Pod.

    root@kubernetes-master:~# kubectl create -f crpd.yaml

    content_copy zoom_out_map
    pod/crpd created
  3. Run the following command to view the list of existing Pods:

    root@kubernetes-master:~# kubectl get pods

    content_copy zoom_out_map
    NAME                    READY   STATUS      RESTARTS   AGE
    crpd                    1/1     Running     0          18h
    crpd-5fc4fd79df-xr8f5   1/1     Running     0          19h
  4. Run the following command to view what containers are inside that Pod and what images are used to build the containers:

    root@kubernetes-master:~# kubectl describe pod crpd

    content_copy zoom_out_map
    Name:               crpd
    Namespace:          default
    Priority:           0
    PriorityClassName:  <none>
    Node:               kubernetes-slave/10.102.183.130
    Start Time:         Thu, 09 May 2019 13:38:33 -0700
    Labels:             app=crpd
    Annotations:        <none>
    Status:             Running
    IP:                 10.244.1.9
    Containers:
      crpd:
        Container ID:   docker://cc7e9187ad2d482420b3afc90843443a318abb3f354da6bf2da5d4c5f7b791cc
        Image:          crpd
        Image ID:       docker://sha256:1bc4b1c99f81f7d88b73a04f9426e360ae2cc9ea0330442e633a6ebdfec00af0
        Ports:          179/TCP
        Host Ports:     0/TCP, 0/TCP
        State:          Running
          Started:      Thu, 09 May 2019 13:38:36 -0700
        Ready:          True
        Restart Count:  0
    		Environment:    <none>
    		Mounts:
          /var/run/secrets/kubernetes.io/serviceaccount from default-token-ncktj (ro)
    Conditions:
      Type              Status
      Initialized       True
      Ready             True
      ContainersReady   True
      PodScheduled      True
    Volumes:
      default-token-ncktj:
        Type:        Secret (a volume populated by a Secret)
        SecretName:  default-token-ncktj
        Optional:    false
    QoS Class:       BestEffort
    Node-Selectors:   <none>
    Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                     node.kubernetes.io/unreachable:NoExecute for 300s
    Events:
      Type    Reason     Age   From                       Message
      ----    ------     ----  ----                       -------
      Normal  Pulled     60s   kubelet, kubernetes-slave  Container image "crpd-ui32" already present on machine
      Normal  Created    60s   kubelet, kubernetes-slave  Created container crpd
      Normal  Started    59s   kubelet, kubernetes-slave  Started container crpd
      Normal  Scheduled  54s   default-scheduler          Successfully assigned default/crpd to kubernetes-slave
  5. Run the following command to provide an interactive CLI inside the running container:

    root@kubernetes-master:~# kubectl exec -it crpd cli

    Here you are running a pod with the name crpd and connect to the command line mode.

    content_copy zoom_out_map
    ===>
               Containerized Routing Protocols Daemon (CRPD)
     Copyright (C) 2018-19, Juniper Networks, Inc. All rights reserved.
                                                                        <===
  6. Run the following command to view the routes:

    root@crpd:/> show route

    content_copy zoom_out_map
    inet.0: 2 destinations, 2 routes (2 active, 0 holddown, 0 hidden)
    + = Active Route, - = Last Active, * = Both
    
    172.17.0.0/16      *[Direct/0] 00:04:31
                        >  via eth0
    172.17.0.3/32      *[Local/0] 00:04:31
                           Local via eth0
    
    inet6.0: 3 destinations, 3 routes (3 active, 0 holddown, 0 hidden)
    + = Active Route, - = Last Active, * = Both
    
    fe80::42:acff:fe11:3/128
                       *[Local/0] 00:04:31
                           Local via eth0
    fe80::5873:acff:feee:fc29/128
                       *[Local/0] 00:04:31
                           Local via lsi
    ff02::2/128        *[INET6/0] 00:04:31
                           MultiRecv
    

Each Pod is meant to run a single instance of a given application. If you want to scale your application horizontally (e.g., run multiple instances), you should use multiple Pods, one for each instance. In Kubernetes, this is generally referred to as replication.

Create a cRPD Pod using Job Resource

A Job creates one or more Pods and will continue to retry execution of the Pods until a specified number of them successfully terminate. When a specified number of successful completions is reached, the task is complete. You can also use a Job to run multiple Pods in parallel. Deleting a Job will clean up the Pods it created. Suspending a Job will delete its active Pods until the Job is resumed. To create the cRPD Pod using the crpd_job.yaml file:

  1. Create the crpd_job.yaml file on work nodes and add the following text content:
    content_copy zoom_out_map
    ------------------
    apiVersion: batch/v1
    kind: Job
    metadata:
      name: crpdjob
    spec:
      template:
        spec:
          containers:
          - name: crpdjob
            image: "enterprise-hub.juniper.net/crpd-docker-prod/crpd:20.1R1.11"
            imagePullPolicy: ""
            command: ["/bin/bash"]
          restartPolicy: Never
      backoffLimit: 4------------------
  2. Save the crpd_job.yaml file to create the crpd Pod.

    root@kubernetes-master:~# kubectl create -f crpd_job.yaml

    content_copy zoom_out_map
    job.batch/crpdjob created
  3. Run the following command to view the list of existing Pods:

    root@kubernetes-master:~# kubectl get pods

    content_copy zoom_out_map
    NAME                    READY   STATUS      RESTARTS   AGE
    crpd                    1/1     Running     0          18h
    crpd-5fc4fd79df-xr8f5   1/1     Running     0          19h
    crpdjob-kdgg4           0/1     Completed   0          19h
  4. Run the following command to view what containers are inside that Pod and what images are used to build the containers:

    root@kubernetes-master:~# kubectl describe job/crpdjob

    content_copy zoom_out_map
    Name:           crpdjob
    Namespace:      default
    Selector:       controller-uid=5997b1fe-d899-4c59-bffb-4cd9a1d72d8b
    Labels:         controller-uid=5997b1fe-d899-4c59-bffb-4cd9a1d72d8b
                    job-name=crpdjob
    Annotations:    <none>
    Parallelism:    1
    Completions:    1
    Start Time:     Tue, 22 Oct 2019 02:34:25 -0700
    Completed At:   Tue, 22 Oct 2019 02:34:27 -0700
    Duration:       2s
    Pods Statuses:  0 Running / 1 Succeeded / 0 Failed
    Pod Template:
      Labels:  controller-uid=5997b1fe-d899-4c59-bffb-4cd9a1d72d8b
               job-name=crpdjob
      Containers:
       crpdjob:
        Image:      crpd:19.2R1.8
        Port:       <none>
        Host Port:  <none>
        Command:
          /bin/bash
        Environment:  <none>
        Mounts:       <none>
      Volumes:        <none>
    Events:
      Type    Reason            Age    From            Message
      ----    ------            ----   ----            -------
      Normal  SuccessfulCreate  4m36s  job-controller  Created pod: crpdjob-9lspk

Create a cRPD Pod using DaemonSet

DaemonSet ensures that all (or some) nodes run a copy of a Pod. As nodes are added to the cluster, Pods are added to them. As nodes are removed from the cluster, those Pods are garbage collected. If the DaemonSet is deleted, the Pods created are deleted.

Creating the cRPD pod using the crpd_daemonset.yaml file

  1. Create the crpd_daemonset.yaml file on work nodes and add the following text content:
    content_copy zoom_out_map
    ------------------
    apiVersion: apps/v1
    kind: DaemonSet
    metadata:
      name: crpdda1
      labels:
        app: crpdda
    spec:
      selector:
        matchLabels:
          app: crpdda
      template:
        metadata:
          labels:
            app: crpdda
        spec:
          hostNetwork: true
          nodeSelector:
            disktype: ssd
          containers:
            - name: crpd
              image: crpd:19.2R1.8
              imagePullPolicy: Never
              ports:
              - containerPort: 179
              - containerPort: 40051
    
    ------------------
  2. Save the da1.yaml file to create the crpd Pod.

    root@kubernetes-master:~# kubectl create -f crpd_daemonset.yaml

    content_copy zoom_out_map
    daemonset.apps/crpdda1 created
  3. Run the following command to view the list of existing Pods:

    root@kubernetes-master:~# kubectl get pods

    content_copy zoom_out_map
    NAME                    READY   STATUS      RESTARTS   AGE
    crpd                    1/1     Running     0          18h
    crpd-5fc4fd79df-xr8f5   1/1     Running     0          19h
    crpdjob-kdgg4           0/1     Completed   0          19h
  4. Run the following command to view what containers are inside that Pod and what images are used to build the containers:

    root@kubernetes-master:~# kubectl describe pod crpd

    content_copy zoom_out_map
    Name:               crpd
    Namespace:          default
    Priority:           0
    PriorityClassName:  <none>
    Node:               kubernetes-slave1/10.49.107.224
    Start Time:         Wed, 16 Oct 2019 23:20:49 -0700
    Labels:             app=crpdda
                        controller-revision-hash=5d88785f7c
                        pod-template-generation=1
    Annotations:        <none>
    Status:             Running
    IP:                 10.244.1.19
    Controlled By:      DaemonSet/crpdda1
    Containers:
      crpd:
        Container ID:   docker://0e13bdaa97c4a6da46c2fe3008939652031633d44440699ce71f094763a40244
        Image:          crpd:19.2R1.8
        Image ID:       docker://sha256:8e00d0d60309cd0d0bee63fea865b1e389f803a57b1239386e03b31a01146dbf
        Ports:          179/TCP, 40051/TCP
        Host Ports:     0/TCP, 0/TCP
        State:          Running
          Started:      Wed, 16 Oct 2019 23:20:51 -0700
        Ready:          True
        Restart Count:  0
        Environment:    <none>
        Mounts:
          /var/run/secrets/kubernetes.io/serviceaccount from default-token-5chxw (ro)
    Conditions:
      Type              Status
      Initialized       True
      Ready             True
      ContainersReady   True
      PodScheduled      True
    Volumes:
      default-token-5chxw:
        Type:        Secret (a volume populated by a Secret)
        SecretName:  default-token-5chxw
        Optional:    false
    QoS Class:       BestEffort
    Node-Selectors:  <none>
    Tolerations:     node.kubernetes.io/disk-pressure:NoSchedule
                     node.kubernetes.io/memory-pressure:NoSchedule
                     node.kubernetes.io/not-ready:NoExecute
                     node.kubernetes.io/pid-pressure:NoSchedule
                     node.kubernetes.io/unreachable:NoExecute
                     node.kubernetes.io/unschedulable:NoSchedule
    Events:
      Type    Reason     Age        From                        Message
      ----    ------     ----       ----                        -------
      Normal  Scheduled  <unknown>  default-scheduler           Successfully assigned default/crpdda1-tr85h to kubernetes-slave1
      Normal  Pulled     25s        kubelet, kubernetes-slave1  Container image "crpd:19.2R1.8" already present on machine
      Normal  Created    24s        kubelet, kubernetes-slave1  Created container crpd
      Normal  Started    24s        kubelet, kubernetes-slave1  Started container crpd

    root@kubernetes-master:~# kubectl describe pod crpd-5fc4fd79df-xr8f5

    content_copy zoom_out_map
    Name:               crpd-5fc4fd79df-xr8f5
    Namespace:          default
    Priority:           0
    PriorityClassName:  <none>
    Node:               kubernetes-slave2/10.49.107.220
    Start Time:         Wed, 16 Oct 2019 23:20:53 -0700
    Labels:             app=crpdda
                        controller-revision-hash=5d88785f7c
                        pod-template-generation=1
    Annotations:        <none>
    Status:             Running
    IP:                 10.244.2.19
    Controlled By:      DaemonSet/crpdda1
    Containers:
      crpd:
        Container ID:   docker://296e68358a6b85a92216954b1f703315eebd2b21f3ffacf91d0f197ab7da21ee
        Image:          crpd:19.2R1.8
        Image ID:       docker://sha256:82d848c70c24b225fc2ebfa6c39c123153ddde7e3bd5ed40876f537c02693047
        Ports:          179/TCP, 40051/TCP
        Host Ports:     0/TCP, 0/TCP
        State:          Running
          Started:      Wed, 16 Oct 2019 23:20:56 -0700
        Ready:          True
        Restart Count:  0
        Environment:    <none>
        Mounts:
          /var/run/secrets/kubernetes.io/serviceaccount from default-token-5chxw (ro)
    Conditions:
      Type              Status
      Initialized       True
      Ready             True
      ContainersReady   True
      PodScheduled      True
    Volumes:
      default-token-5chxw:
        Type:        Secret (a volume populated by a Secret)
        SecretName:  default-token-5chxw
        Optional:    false
    QoS Class:       BestEffort
    Node-Selectors:  <none>
    Tolerations:     node.kubernetes.io/disk-pressure:NoSchedule
                     node.kubernetes.io/memory-pressure:NoSchedule
                     node.kubernetes.io/not-ready:NoExecute
                     node.kubernetes.io/pid-pressure:NoSchedule
                     node.kubernetes.io/unreachable:NoExecute
                     node.kubernetes.io/unschedulable:NoSchedule
    Events:
      Type    Reason     Age        From                        Message
      ----    ------     ----       ----                        -------
      Normal  Scheduled  <unknown>  default-scheduler           Successfully assigned default/crpdda1-v48lc to kubernetes-slave2
      Normal  Pulled     30s        kubelet, kubernetes-slave2  Container image "crpd:19.2R1.8" already present on machine
      Normal  Created    30s        kubelet, kubernetes-slave2  Created container crpd
      Normal  Started    29s        kubelet, kubernetes-slave2  Started container crpd

Each Pod is meant to run a single instance of a given application. If you want to scale your application horizontally (e.g., run multiple instances), you should use multiple Pods, one for each instance. In Kubernetes, this is generally referred to as replication.

Scale cRPD

You can create multiple instances of cRPD based on the demand using the –replicas parameter for the kubectl run command. Deployment is an object which can own and manage their ReplicaSets.

We should have one pod before scaling.

To scale up:

  1. Create the Pod.

    root@kubernetes-master:~# kubectl create -f crpd_replicatset.yaml

    content_copy zoom_out_map
    deployment.apps/crpdref created
  2. Create the crpd_replicaSet.yaml file on Kubernetes-master add the following text content:
    content_copy zoom_out_map
    ------------------
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      annotations:
        deployment.kubernetes.io/revision: "1"
      generation: 2
      labels:
        run: reflector
      name: crpdref
      namespace: default
    spec:
      replicas: 2
      selector:
        matchLabels:
          run: reflector
      template:
        metadata:
          labels:
            run: reflector
        spec:
          containers:
          - name: reflector
            image: "enterprise-hub.juniper.net/crpd-docker-prod/crpd:20.1R1.11"
            imagePullPolicy: ""
    ------------------
  3. Run the following command to view the Pods:

    root@kubernetes-master:~# kubectl get pods

    content_copy zoom_out_map
    NAME                       READY   STATUS    RESTARTS   AGE
    crpdref-76c5c7b884-hxbtr   1/1     Running   0          10s
    crpdref-76c5c7b884-wp55c   1/1     Running   0          10s
  4. Run the following command to scale the Deployment to four replicas:

    root@kubernetes-master:~# kubectl scale deployments crpdref --replicas=4

    content_copy zoom_out_map
    deployment.apps/crpdref scaled
  5. Run the following command to list the deployments:

    root@kubernetes-master:~# kubectl get deployments

  6. Run the following command to check the number of pods changed:

    root@kubernetes-master:~# kubectl get pods -o wide

    content_copy zoom_out_map
    NAME                       READY   STATUS    RESTARTS   AGE     IP            NODE         NOMINATED NODE   READINESS GATES
    crpd                       1/1     Running   2          3h35m   172.17.0.2    ix-crpd-01   <none>           <none>
    crpd-5fc4fd79df-8vxtp      1/1     Running   0          5m43s   172.17.0.9    ix-crpd-01   <none>           <none>
    crpd-5fc4fd79df-cd5g8      1/1     Running   0          5m43s   172.17.0.8    ix-crpd-01   <none>           <none>
    crpd-5fc4fd79df-hmm5q      1/1     Running   0          5m43s   172.17.0.7    ix-crpd-01   <none>           <none>
    crpd-5fc4fd79df-xr8f5      1/1     Running   2          23h     172.17.0.3    ix-crpd-01   <none>           <none>
    crpdref-76c5c7b884-dbg5p   1/1     Running   0          5m12s   172.17.0.11   ix-crpd-01   <none>           <none>
    crpdref-76c5c7b884-h8xks   1/1     Running   0          5m12s   172.17.0.10   ix-crpd-01   <none>           <none>
    
  7. Run the following command to check the details of the Pods:

    root@kubernetes-master:~# kubectl describe pods

To scale down:

  1. Run the following command to scale down the Service to two replicas:

    root@kubernetes-master:~# kubectl scale deployments crpdref --replicas=2

    content_copy zoom_out_map
    deployment.apps/crpdref scaled
  2. Run the following command to list the deployments:

    root@kubernetes-master:~# kubectl get deployments

  3. Run the following command to list the number of Pods. You can view the two Pods were terminated:

    root@kubernetes-master:~# kubectl get pods -o wide

Roll Update of cRPD Deployment

You can update Pod instances with new versions. Rolling updates allow Deployments' update to take place with zero downtime by incrementally updating Pods instances with new ones. The new Pods are scheduled on Nodes with available resources. Rollback updates promote an application from one environment to another with continuous integration and continuous delivery of applications with zero downtime. In Kubernetes, updates are versioned, and any Deployment update can be reverted to previous stable version.

To update cRPD deployment with new image and preserve the configuration after update:

  1. Create the cRPD Pod.

    root@crpd-01:~# kubectl kubectl create -f crpd_deploy.yaml

    content_copy zoom_out_map
    deployment.apps/crpd-deploy created
    
  2. Create the crpd_deploy.yaml file on Kubernetes-master add the following text content:
    content_copy zoom_out_map
    -------------------
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: crpd-deploy
      labels:
        app: crpd
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: crpd
      template:
        metadata:
          labels:
            app: crpd
        spec:
          containers:
          - name: crpd
            image: "enterprise-hub.juniper.net/crpd-docker-prod/crpd:19.4R1.10"
            imagePullPolicy: ""
            ports:
            - containerPort: 179
            - containerPort: 40051------------------
  3. Run the following command to list the deployments:

    root@kubernetes-master:~# kubectl get deployments

  4. Run the following command to list the running pods:

    root@kubernetes-master:~# kubectl get pods

    content_copy zoom_out_map
    NAME                           READY   STATUS    RESTARTS   AGE
    ...
    crpd-deploy-6c489b5b8b-4tqgn   1/1     Running   0          9m20s
    crpd-deploy-6c489b5b8b-vp7df   1/1     Running   0          9m21s
    

    root@kubernetes-master:~# kubectl get pods -o wide

    content_copy zoom_out_map
    NAME                           READY   STATUS    RESTARTS   AGE     IP            NODE         NOMINATED NODE   READINESS GATES
    ...
    crpd-deploy-6c489b5b8b-4tqgn   1/1     Running   0          6m57s   172.17.0.10   ix-crpd-01   <none>           <none>
    crpd-deploy-6c489b5b8b-vp7df   1/1     Running   0          6m58s   172.17.0.11   ix-crpd-01   <none>           <none>
  5. Run the following command to view the current image version of the cRPD:

    root@kubernetes-master:~# kubectl exec -it crpd-deploy4-674b4fcfb5-8xc5d -- cli

    content_copy zoom_out_map
    ===>
               Containerized Routing Protocols Daemon (CRPD)
     Copyright (C) 2018-19, Juniper Networks, Inc. All rights reserved.
                                                                        <===
  6. Run the following command to view the current image version:

    root@crpd-deploy4-674b4fcfb5-8xc5d> show version

    content_copy zoom_out_map
    Hostname: crpd-deploy4-674b4fcfb5-8xc5d
    Model: cRPD
    Junos: 20.4R1.12
    cRPD package version : 20.4R1.12 built by builder on 2020-12-20 13:35:15 UTC
    
  7. Run the following command to update the image of the application to new version:

    root@crpd-deploy4-674b4fcfb5-8xc5d:~$ sudo kubectl edit deployment/crpd-deploy4

    content_copy zoom_out_map
    containers:
     - image: enterprise-hub.juniper.net/crpd-docker-prod/crpd:20.1R1.11
       imagePullPolicy: Never
  8. Run the following command to confirm if the image is updated:

    root@crpd-deploy4-674b4fcfb5-8xc5d:~$ sudo kubectl rollout status deployment/crpd-deploy4

    content_copy zoom_out_map
    deployment "crpd-deploy4" successfully rolled out
  9. Run the following command to view the Pods:

    root@crpd-deploy4-674b4fcfb5-8xc5d> kubectl get pods

    content_copy zoom_out_map
    NAME                            READY   STATUS    RESTARTS   AGE
    crpd-deploy4-6ff476994d-8z2kr   1/1     Running   0          38s
    crpd-deploy4-6ff476994d-qxwrz   1/1     Running   0          41s
  10. Run the following command to view the image version of the cRPD:

    root@kubernetes-master:~$ sudo kubectl exec -it crpd-deploy4-6ff476994d-8z2kr -- bash

    content_copy zoom_out_map
    ===>
               Containerized Routing Protocols Daemon (CRPD)
     Copyright (C) 2018-19, Juniper Networks, Inc. All rights reserved.
                                                                        <===
  11. Run the following command to view the current image version:

    root@crpd-deploy4-6ff476994d-8z2kr> show version

    content_copy zoom_out_map
    Hostname: crpd-deploy4-674b4fcfb5-8xc5d
    Model: cRPD
    Junos: 20.4R1.12
    cRPD package version : 20.4R1.12 built by builder on 2020-12-20 13:35:15 UTC
    

cRPD Pod Deployment with Allocated Resources

Pods provide two kinds of shared resources, namely networking and storage for the containers. When containers in a Pod communicate with entities outside the Pod, they must coordinate how they use the shared network resources (such as ports). Within a Pod, containers communicate through localhost using an IP address and port.

Containers within the Pod view the system hostname as same as the configured name for the Pod.

Any container in a Pod can enable privileged mode, using the privileged flag on the container spec. This is useful for containers that use operating system administrative capabilities such as manipulating the network stack or accessing hardware devices. Processes within a privileged container have almost the same privileges that are available to processes outside a container.

To view the Pod deployment with resources:

  1. Create the crpd_res.yaml file on Kubernetes-master add the following text content:
    content_copy zoom_out_map
    ------------------
    apiVersion: v1
    kind: Pod
    metadata:
      name: crpdres
      labels:
        app: crpd
    spec:
      containers:
      - name: crpd
        image: "enterprise-hub.juniper.net/crpd-docker-prod/crpd:20.1R1.11"
        imagePullPolicy: ""
        ports:
        - containerPort: 179
        - containerPort: 40051
        resources:
          limits:
            memory: "200Mi"
            cpu: "700m"
          requests:
            memory: "200Mi"
            cpu: "700m"
        securityContext:
          privileged: true
    
    ------------------
  2. Save the crpd_res.yaml file to create the crpd Pod.

    root@kubernetes-master:~# kubectl create -f crpd_res.yaml

    content_copy zoom_out_map
    pod/crpdres created
  3. Run the following command to view the list of existing Pods:

    root@kubernetes-master:~# kubectl get pods

    content_copy zoom_out_map
    NAME                             READY   STATUS    RESTARTS   AGE
    crpdres                         1/1     Running            0          7s
  4. Run the following command to view what containers are inside that Pod and what images are used to build the containers:

    root@kubernetes-master:~# kubectl describe pod crpres

    content_copy zoom_out_map
    Name:               crpdres
    Namespace:          default
    Priority:           0
    PriorityClassName:  <none>
    Node:               kubernetes-slave1/10.49.107.224
    Start Time:         Thu, 17 Oct 2019 00:28:44 -0700
    Labels:             app=crpd
    Annotations:        <none>
    Status:             Running
    IP:                 10.244.1.22
    Containers:
      crpd:
        Container ID:   docker://a1ae9791e593b7caea83907d841519bc47744db372b10d006d556308b2e03dbc
        Image:          crpd:19.2R1.8
        Image ID:       docker://sha256:8e00d0d60309cd0d0bee63fea865b1e389f803a57b1239386e03b31a01146dbf
        Ports:          179/TCP, 40051/TCP
        Host Ports:     0/TCP, 0/TCP
        State:          Running
          Started:      Thu, 17 Oct 2019 00:28:46 -0700
        Ready:          True
        Restart Count:  0
        Limits:
          cpu:     700m
          memory:  200Mi
        Requests:
          cpu:        700m
          memory:     200Mi
        Environment:  <none>
        Mounts:
          /var/run/secrets/kubernetes.io/serviceaccount from default-token-5chxw (ro)
    Conditions:
      Type              Status
      Initialized       True
      Ready             True
      ContainersReady   True
      PodScheduled      True
    Volumes:
      default-token-5chxw:
        Type:        Secret (a volume populated by a Secret)
        SecretName:  default-token-5chxw
        Optional:    false
    QoS Class:       Guaranteed
    Node-Selectors:  <none>
    Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                     node.kubernetes.io/unreachable:NoExecute for 300s
    Events:
      Type    Reason     Age        From                        Message
      ----    ------     ----       ----                        -------
      Normal  Scheduled  <unknown>  default-scheduler           Successfully assigned default/crpdres to kubernetes-slave1
      Normal  Pulled     13s        kubelet, kubernetes-slave1  Container image "crpd:19.2R1.8" already present on machine
      Normal  Created    13s        kubelet, kubernetes-slave1  Created container crpd
      Normal  Started    12s        kubelet, kubernetes-slave1  Started container crpd

cRPD Pod Deployment using Mounted Volume

An emptyDir is one among the several types of volumes supported on K8s and is first created when a Pod is assigned to a node and exists as long as that Pod is running on that node. As the name says, the emptyDir volume is initially empty. All containers in the Pod can read and write the same files in the emptyDir volume, though that volume can be mounted at the same or different paths in each container. When a Pod is removed from a node for any reason, the data in the emptyDir is deleted permanently.

To view cRPD Pod deployment by mounting the storage path on Kubernetes:

  1. Create the crpd_volume.yaml file on Kubernetes-master add the following text content:
    content_copy zoom_out_map
    ------------------
    apiVersion: v1
    kind: Pod
    metadata:
      name: crpd-volume
      labels:
        app: crpd
    spec:
      containers:
      - name: crpd
        image: crpd:19.2R1.8
        imagePullPolicy: Never
        ports:
        - containerPort: 179
        - containerPort: 40051
        volumeMounts:
        - name: crpd-storage
          mountPath: /var/log/crpd-storage
      volumes:
      - name: crpd-storage
        emptyDir: {}
    -----------------
  2. Save the crpd_volume.yaml file to create the crpd Pod.

    root@kubernetes-master:~# kubectl create -f crpd_volume.yaml

    content_copy zoom_out_map
    pod/crpd-volume created
  3. Run the following command to view the list of existing Pods:

    root@kubernetes-master:~# kubectl get pods

    content_copy zoom_out_map
    NAME                            READY   STATUS             RESTARTS   AGE
    crpd-volume                     1/1     Running            0          5s
  4. Run the following command to view what containers are inside that Pod and what images are used to build the containers:

    root@kubernetes-master:~# kubectl describe pod crpd-volume

    content_copy zoom_out_map
    Name:               crpd-volume
    Namespace:          default
    Priority:           0
    PriorityClassName:  <none>
    Node:               kubernetes-slave2/10.49.107.220
    Start Time:         Thu, 17 Oct 2019 00:39:59 -0700
    Labels:             app=crpd
    Annotations:        <none>
    Status:             Running
    IP:                 10.244.2.20
    Containers:
      crpd:
        Container ID:   docker://593aa6f279132cc2e0a0832cff07ad74db2696472c2d72596a177f1e5f912377
        Image:          crpd:19.2R1.8
        Image ID:       docker://sha256:82d848c70c24b225fc2ebfa6c39c123153ddde7e3bd5ed40876f537c02693047
        Ports:          179/TCP, 40051/TCP
        Host Ports:     0/TCP, 0/TCP
        State:          Running
          Started:      Thu, 17 Oct 2019 00:40:02 -0700
        Ready:          True
        Restart Count:  0
        Environment:    <none>
        Mounts:
          /var/log/crpd-storage from crpd-storage (rw)
          /var/run/secrets/kubernetes.io/serviceaccount from default-token-5chxw (ro)
    Conditions:
      Type              Status
      Initialized       True
      Ready             True
      ContainersReady   True
      PodScheduled      True
    Volumes:
      crpd-storage:
        Type:    EmptyDir (a temporary directory that shares a pod's lifetime)
        Medium:
      default-token-5chxw:
        Type:        Secret (a volume populated by a Secret)
        SecretName:  default-token-5chxw
        Optional:    false
    QoS Class:       BestEffort
    Node-Selectors:  <none>
    Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                     node.kubernetes.io/unreachable:NoExecute for 300s
    Events:
      Type    Reason     Age        From                        Message
      ----    ------     ----       ----                        -------
      Normal  Scheduled  <unknown>  default-scheduler           Successfully assigned default/crpd-volume to kubernetes-slave2
      Normal  Pulled     10s        kubelet, kubernetes-slave2  Container image "crpd:19.2R1.8" already present on machine
      Normal  Created    9s         kubelet, kubernetes-slave2  Created container crpd
      Normal  Started    9s         kubelet, kubernetes-slave2  Started container crpd
  5. Run the following command to execute the cRPD instance:

    root@kubernetes-master:~# kubectl exec -it crpd-volume bash

    content_copy zoom_out_map
    ===>
               Containerized Routing Protocols Daemon (CRPD)
     Copyright (C) 2018-19, Juniper Networks, Inc. All rights reserved.
                                                                        <===
  6. Run the following command to view the files in the path:

    root@crpd-volume:/# ls

    content_copy zoom_out_map
    bin  boot  config  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
  7. Run the following command to navigate to the storage path:

    root@crpd-volume:/# cd var/log/crpd-storage/

    root@crpd-volume:/var/log/crpd-storage/#

footer-navigation