Wednesday, August 7, 2024

Kubernetes Deploymentconfig vs Deployment

 

DeploymentConfig objects involve one or more replication controllers, which contain a point-in-time record of the state of a deployment as a pod template.

To create deploymentconfig using image:

oc create deploymentconfig apache-dc --image=httpd

To view ReplicaController

oc get rc

deploymentconfig → replicationcontroller → pod

A replication controller ensures that a specified number of replicas of a pod are running at all times. If pods exit or are deleted, the replication controller acts to instantiate more up to the defined number.

The replication controller does not perform auto-scaling based on load or traffic, as it does not track either.

 

Deployment objects involve one or more replica sets, a successor of replication controllers.

oc create deployment d1 --image=httpd

oc get deploy

Deployment also create replicaset

oc get rs

deployment → replicaset → pod

ReplicaSet is a native Kubernetes API object that ensures a specified number of pod replicas are running at any given time

 

Deployment and DeploymentConfig objects is the properties of the CAP theorem that each design has chosen for the rollout process. DeploymentConfig objects prefer consistency, whereas Deployments objects take availability over consistency.

 

deployments do not support automatically rolling back to the last successfully deployed replica set in case of a failure.

Deployments do not support user-specified custom deployment strategies yet

Friday, July 28, 2023

Upload and download artifact from Nexus using curl

 Upload and download artifact from Nexus using curl

 

  To upload:
  curl -X POST "http://localhost:8081/service/rest/v1/components?repository=devopsrepo1" -H "accept: application/json" -H "Content-Type: multipart/form-data" -H "Authorization: Basic YWRtaW46QmFhS3VtYmk1Iw==" -F "raw.directory=devops" -F "raw.asset1=@C:\Users\Devyan\Downloads\commons-lang3-3.12.0-bin.zip;type=application/x-zip-compressed" -F "raw.asset1.filename=commons-lang3-3.12.0-bin.zip"
 
   curl -X POST "http://localhost:8081/service/rest/v1/components?repository=devopsrepo1" -H "accept: application/json" -H "Content-Type: multipart/form-data" -H "Authorization: Basic YWRtaW46QmFhS3VtYmk1Iw==" -F "raw.directory=devops" -F "raw.asset1=@C:\Users\Devyan\Downloads\commons-lang3-3.12.0-bin.zip;type=application/x-zip-compressed" -F "raw.asset1.filename=reportium-java-2.2.9.jar"
 
  To Download:
 
  curl -O --output-dir C:\Users\Devyan\Downloads http://localhost:8081/repository/devopsrepo1/devops/commons-lang3-3.12.0-bin.zip
  curl -O --output-dir C:\Users\Devyan\Downloads http://localhost:8081/repository/devopsrepo1/devops/reportium-java-2.2.9.jar
  

Tuesday, May 23, 2023

pyscript program to display csv data to html table

 

 To install httpserver: pip install httpserver

 

To Run  web server:  python3 -m http.server

 

Open http://0.0.0.0:8000/

 

python3 -m webbrowser http://0.0.0.0:8000/

 

It will open default index html page.

 

 <html>
    <head>
      <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
      <script defer src="https://pyscript.net/alpha/pyscript.js"></script>
      <style>
        table {
          border-collapse: collapse;
          width: 100%;
        }
       
        th, td {
          text-align: left;
          padding: 8px;
        }
       
        tr:nth-child(even) {background-color: #f2f2f2;}
      </style>
    <py-env>
        - pandas
        - paths:
          - ./reportint.csv
          - ./reporttest.csv
      </py-env>
   
    </head>
  <body>
    <h1><b>Application overview TEST:</b></h1><br><br>
    <py-script>
      import pandas as pd
      column_names=["DATE","USER",'

COMMENT']
      a = pd.read_csv("reportint.csv",names=column_names)
      a.to_html("Table.htm")
      html_file = a.to_html()
      print(a.to_html())
     
    </py-script>
    <br><h2><b>Application overview INT:</b></h2><br>
    <py-script>
      import pandas as pd
      column_names=["DATE","USER",'COMMENT']
      a = pd.read_csv("reporttest.csv",names=column_names)
      a.to_html("Table.htm")
      html_file = a.to_html()
      print(a.to_html())
           
    </py-script>
  </body>
</html>
 

Wednesday, April 12, 2023

Find absolute path using java

 <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="java.io.*" %>    
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/app/util/ContextMenuCheck.js"></script>
<meta charset="ISO-8859-1">
<title>Absolute Path</title>
</head>
<body>
Absolute Path is:<%= getServletContext().getRealPath("/js/app/util/ContextMenuCheck.js") %>
</body>
</html>

Wednesday, August 17, 2022

Autoscaling in Kubernetes

Kubernetes pod autoscaler using custom metrics – Sysdig 

Autoscaling in Kubernetes:

ReplicaSet works with a set number of pods.

Horizontal Pod Autoscaler(HPA) enables scaling up and down as needed

Can configure based on desired state of CPU, memory etc.

 

Horizontal Pod Autoscaler, or HPA, enables the application to increase the number of  pods based           on traffic.

 

The master node will periodically check pod metrics and scale to meet the desired state by updating   the replicas field of the scaled resource, such as ReplicaSets or deployment. 

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-deployment
labels:
name: nginx-deployment
annotations:
kubernetes.io/change-cause: "custom message"
spec:
replicas: 5
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80

$ kubectl apply -f deployment.yaml

$ kubectl get all



$ kubectl get hpa  

$ kubectl autoscale deploy nginx-deployment  --min=2  --max=5 --cpu-percent=10

"cpu-percent" is the trigger to create new pods.  This tells the system, “If the CPU usage hits 10% across the cluster, create a new  pod.”


 


 

A Horizontal Pod Autoscaler is created behind the scenes to manage the  autoscaling feature of the deployment.