Monday, December 20, 2021

Node + Typescript : Typescript + Node

https://stackoverflow.com/questions/36999461/how-to-install-only-devdependencies-using-npm


npm init -y

npm i -D typescript

npx tsc example.ts

node example.js



https://www.youtube.com/watch?v=1UcLoOD1lRM


https://www.youtube.com/watch?v=WBPrJSw7yQA

Terraform : terraform commands

  1. terraform init
  2. terraform plan
  3. terraform apply
  4. terraform destroy

https://www.youtube.com/watch?v=JHiSGnh5Two&list=PLwbWIFE49l8kxe3PLftHFrwIYSfhNxaVZ&index=2

  • .terraform
  • .terraform.lock.hcl
  • terraform.tfstate 
  •  terraform.tfstate.backup


Terraform : TF2

https://registry.terraform.io/providers/hashicorp/aws/latest/docs

https://www.youtube.com/watch?v=JHiSGnh5Two&list=PLwbWIFE49l8kxe3PLftHFrwIYSfhNxaVZ&index=2

https://www.youtube.com/watch?v=SLB_c_ayRMo 

https://www.youtube.com/watch?v=JHiSGnh5Two&list=PLwbWIFE49l8kxe3PLftHFrwIYSfhNxaVZ&index=3

https://www.youtube.com/watch?v=esGezkpzpRo&list=PLwbWIFE49l8kxe3PLftHFrwIYSfhNxaVZ&index=4


resource "aws_instance" "tcw" {

  ami = "ami-0ed9277fb7eb570c9"
  instance_type = "t2.micro"
  tags = {
    Author = "KK"
    ProjectManager = "PM"
    Name = "TCW EC2Instance"
  }
}

resource "aws_ec2_tag" "tcw_nameTag" {
  resource_id = aws_instance.tcw.id
  key = "Name"
  value = "TCW EC2Instance"
}

#Configure the AWS Provider
provider "aws" {
    region = "us-east-1"
}

Terraform : Terraform 1

 


Monday, December 13, 2021

Kubectl: Load Balancer : Internal LB : Does not change , even if you restart POD

 em-ui                             LoadBalancer   172.20.221.225   internal-a54ec7ad6f02c49899f5bbd68ce6da3f-74411592.us-east-1.elb.amazonaws.com

em-ui                             LoadBalancer   172.20.221.225   internal-a54ec7ad6f02c49899f5bbd68ce6da3f-74411592.us-east-1.elb.amazonaws.com

Azure : How to whitelist IP Address Azure : Azure South India Region

https://docs.microsoft.com/en-us/azure/devops/organizations/security/allow-list-ip-url?view=azure-devops&tabs=IP-V4

Kubectl : NodePort : TargetPort : Port

https://medium.com/@deepeshtripathi/all-about-kubernetes-port-types-nodeport-targetport-port-containerport-e9f447330b19

https://stackoverflow.com/questions/41509439/whats-the-difference-between-clusterip-nodeport-and-loadbalancer-service-types/52241241#52241241


TargetPort  is port at which Docker Container Listens

NodePort is port at which NodePort - public ip of node listens 

Port is port at which PODS listens 

Linux : OLD PWD : cd DASH : cd -

 cd -

Kubectl : Debugging : How to : Debug Kubernetes : Debugging Kubernetes : kubernetes debugging : Kubernetes debug

https://linuxhint.com/sort-kubectl-events-by-time/

kubectl get events --sort-by='.lastTimestamp' -n amex-poc

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

kubectl describe pod foobar-1h6yyy -n namespace

kubectl describe svc foobarservice   -n namespace

kubectl describe deployment foobardeploy   -n namespace

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

kubectl logs mongodb-2 -n amex-poc mongodb --tail=200

kubectl logs mongodb-2 -n amex-poc mongodb --follow

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

kubectl get pods -n namespace1 -w -l app=io.dev.service

-w  is watch

-l "key=value"  Labels

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

kubectl create -f rabbitmq-deployment.yml -f rabbitmq-service.yml

kubectl delete -f rabbitmq-service.yml -f rabbitmq-deployment.yml

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

kubectl delete deployment foodeploy -n namespace1

kubectl delete deployments foodeploy -n namespace1

kubectl delete service foobarservice -n namespace1

kubectl delete svc foobarservice -n namespace1

deployments ==== deployment

svc ====service ==== services

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

https://stackoverflow.com/questions/41509439/whats-the-difference-between-clusterip-nodeport-and-loadbalancer-service-types












AWS : Secrets : Code Snippet : Nodejs

 // Use this code snippet in your app.

// If you need more information about configurations or implementing the sample code, visit the AWS docs:

https://aws.amazon.com/developers/getting-started/nodejs/


// Load the AWS SDK

var AWS = require('aws-sdk'),

    region = "us-east-1",

    secretName = "qa/cca-product/mongodb",

    secret,

    decodedBinarySecret;


// Create a Secrets Manager client

var client = new AWS.SecretsManager({

    region: region

});


// In this sample we only handle the specific exceptions for the 'GetSecretValue' API.

// See https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_GetSecretValue.html

// We rethrow the exception by default.


client.getSecretValue({SecretId: secretName}, function(err, data) {

    if (err) {

        if (err.code === 'DecryptionFailureException')

            // Secrets Manager can't decrypt the protected secret text using the provided KMS key.

            // Deal with the exception here, and/or rethrow at your discretion.

            throw err;

        else if (err.code === 'InternalServiceErrorException')

            // An error occurred on the server side.

            // Deal with the exception here, and/or rethrow at your discretion.

            throw err;

        else if (err.code === 'InvalidParameterException')

            // You provided an invalid value for a parameter.

            // Deal with the exception here, and/or rethrow at your discretion.

            throw err;

        else if (err.code === 'InvalidRequestException')

            // You provided a parameter value that is not valid for the current state of the resource.

            // Deal with the exception here, and/or rethrow at your discretion.

            throw err;

        else if (err.code === 'ResourceNotFoundException')

            // We can't find the resource that you asked for.

            // Deal with the exception here, and/or rethrow at your discretion.

            throw err;

    }

    else {

        // Decrypts secret using the associated KMS CMK.

        // Depending on whether the secret is a string or binary, one of these fields will be populated.

        if ('SecretString' in data) {

            secret = data.SecretString;

        } else {

            let buff = new Buffer(data.SecretBinary, 'base64');

            decodedBinarySecret = buff.toString('ascii');

        }

    }

    

    // Your code goes here. 

});

Kubectl : Copy from POD or Copy to POD

[Copy something to Pod]

 kubectl cp  /DBScript/Extraction.tar    mongodb-0:/tmp  -n  namespace1

 

 [Copy something from Pod]

 kubectl cp mongodb-0:/tmp/   .  -n  namespace1

Maven : -DskipTests

mvn clean install

mvn clean install -DskipTests

Linux : VIM : Delete Lines below particular line : Goto Top : Goto Bottom : VIM : VI editor

https://stackoverflow.com/questions/3624345/how-to-delete-lines-below-current-line-in-vim


https://askubuntu.com/questions/903281/how-do-i-delete-bash-history-for-current-day-only


https://www.cyberciti.biz/faq/howto-unix-linux-vi-vim-jump-to-end-of-file/

Alpine Command : apk

https://www.cyberciti.biz/faq/10-alpine-linux-apk-command-examples/


Thursday, December 9, 2021

Kubectl Logs : Tail : Follow

kubectl logs vea-cc -n amex-poc --tail=20 nginx

kubectl logs vea-cc -n amex-poc --follow

Wednesday, December 8, 2021

kubectl : Edit Deployment and Delete Deployment

kubectl get deployments-n amex-poc

kubectl edit deployment eaas

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

kubectl delete deployment eaas

Mongo : Kubectl replace Selector and Label - Service : Install ps : Vim Jump to 1st Line : Vim Search : JVM Info in Linux


mongorestore -d IDS_Extraction_Application_Form -c DataPrepConfig collections/DataPrepConfig.bson
mongorestore -d IDS_Extraction_Application_Form -c ExperimentConfig collections/ExperimentConfig.bson
mongorestore -d IDS_Extraction_Application_Form -c ExperimentModel collections/ExperimentModel.bson
mongorestore -d IDS_Extraction_Application_Form -c Project collections/Project.bson
mongorestore -d IDS_Extraction_Application_Form -c Tag collections/Tag.bson
mongorestore -d IDS_Extraction_Application_Form -c TagGroup collections/TagGroup.bson
mongorestore -d IDS_Extraction_Application_Form -c TemplateStructureConfig collections/TemplateStructureConfig.bson
mongorestore -d IDS_Extraction_Application_Form -c hibernate_sequences collections/hibernate_sequences.bson


- apiVersion: v1
  kind: Service
  metadata:
    labels:
      io.qa.service: ids-page-classification-runtime
    name: ids-page-classification-runtime
    namespace: amex-poc
  spec:
    ports:
    - port: 8096
      targetPort: 8096
      protocol: TCP
    selector:
      io.qa.service: ids-page-classification-runtime
    type: ClusterIP

kubectl cp mongodb-2:/tmp/10Aug2021/  .  -n fda
kubectl cp collections mongodb-0:/tmp/
kubectl cp pdf vea-cc-5c6d5fd4dd-nrp9w:/tmp
kubectl cp  vea-cc-6b8469fd57-m99g7:/tmp/Dump  .  -n cs

npm install
npm run build_dev


https://stackoverflow.com/questions/26982274/ps-command-doesnt-work-in-docker-container
apt-get update && apt-get install -y procps

stackoverflow.com/questions/5317152/getting-the-parameters-of-a-running-jvm/17400304#17400304
jinfo -flags <vmid> 
jinfo -sysprops <vmid>

ENTRYPOINT java -Xms4884M -Xmx6144M -XX:+HeapDumpOnOutOfMemoryError -jar -Dserver.port=8081 target/vea-command-center.jar --spring.config.location=/usr/bin/vea/vea-command-center/src/main/resources/application.yml

ENTRYPOINT java -jar -Dserver.port=8081 target/vea-command-center.jar --spring.config.location=/usr/bin/vea/vea-command-center/src/main/resources/application.yml

https://akobor.me/posts/heap-size-and-resource-limits-in-kubernetes-for-jvm-applications




2021-12-08 05:54:12 [cluster-ClusterId{value='61aee955e1ffbc66232fb4f3', description='null'}-mongodb-1.mongodb:27017] INFO  - Server mongodb-1.mongodb:27017 does not appear to be a member of an initiated replica set.
2021-12-08 05:54:12 [cluster-ClusterId{value='61aee955e1ffbc66232fb4f3', description='null'}-mongodb-2.mongodb:27017] INFO  - Server mongodb-2.mongodb:27017 does not appear to be a member of an initiated replica set.
2021-12-08 05:54:20 [cluster-ClusterId{value='61aee955e1ffbc66232fb4f3', description='null'}-mongodb-0.mongodb:27017] INFO  - Server mongodb-0.mongodb:27017 does not appear to be a member of an initiated replica set.
2021-12-08 05:54:22 [cluster-ClusterId{value='61aee955e1ffbc66232fb4f3', description='null'}-mongodb-1.mongodb:27017] INFO  - Server mongodb-1.mongodb:27017 does not appear to be a member of an initiated replica set.
2021-12-08 05:54:22 [cluster-ClusterId{value='61aee955e1ffbc66232fb4f3', description='null'}-mongodb-2.mongodb:27017] INFO  - Server mongodb-2.mongodb:27017 does not appear to be a member of an initiated replica set.
2021-12-08 05:54:30 [cluster-ClusterId{value='61aee955e1ffbc66232fb4f3', description='null'}-mongodb-0.mongodb:27017] INFO  - Monitor thread successfully connected to server with description ServerDescription{address=mongodb-0.mongodb:27017, type=REPLICA_SET_PRIMARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 0, 27]}, minWireVersion=0, maxWireVersion=7, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=699137, setName='rs0', canonicalAddress=mongodb-0:27017, hosts=[mongodb-0:27017], passives=[], arbiters=[], primary='mongodb-0:27017', tagSet=TagSet{[]}, electionId=7fffffff0000000000000001, setVersion=1, lastWriteDate=Wed Dec 08 05:54:27 UTC 2021, lastUpdateTimeNanos=9982679452786567}
2021-12-08 05:54:30 [cluster-ClusterId{value='61aee955e1ffbc66232fb4f3', description='null'}-mongodb-0.mongodb:27017] INFO  - Adding discovered server mongodb-0:27017 to client view of cluster
2021-12-08 05:54:30 [cluster-ClusterId{value='61aee955e1ffbc66232fb4f3', description='null'}-mongodb-0.mongodb:27017] INFO  - Server mongodb-0.mongodb:27017 is no longer a member of the replica set.  Removing from client view of cluster.
2021-12-08 05:54:30 [cluster-ClusterId{value='61aee955e1ffbc66232fb4f3', description='null'}-mongodb-0.mongodb:27017] INFO  - Closed connection [connectionId{localValue:4, serverValue:206862320}] to mongodb-0.mongodb:27017 because there was a socket exception raised on another connection from this pool.
2021-12-08 05:54:30 [cluster-ClusterId{value='61aee955e1ffbc66232fb4f3', description='null'}-mongodb-0.mongodb:27017] INFO  - Server mongodb-1.mongodb:27017 is no longer a member of the replica set.  Removing from client view of cluster.
2021-12-08 05:54:30 [cluster-ClusterId{value='61aee955e1ffbc66232fb4f3', description='null'}-mongodb-0.mongodb:27017] INFO  - Server mongodb-2.mongodb:27017 is no longer a member of the replica set.  Removing from client view of cluster.
2021-12-08 05:54:30 [cluster-ClusterId{value='61aee955e1ffbc66232fb4f3', description='null'}-mongodb-0.mongodb:27017] INFO  - Canonical address mongodb-0:27017 does not match server address.  Removing mongodb-0.mongodb:27017 from client view of cluster
2021-12-08 05:54:30 [cluster-ClusterId{value='61aee955e1ffbc66232fb4f3', description='null'}-mongodb-0:27017] INFO  - Exception in monitor thread while connecting to server mongodb-0:27017


https://stackoverflow.com/questions/50259015/connection-refused-to-kubernetes-service
Connection Refused to Kubernetes Service
You should map the service to the right ports.



https://linuxize.com/post/vim-search/
Press /.
Type the search pattern.
Press Enter to perform the search.
Press n to find the next occurrence or N to find the previous occurrence.




https://cyberciti.biz/faq/howto-unix-linux-vi-vim-jump-to-end-of-file/
1G

Tuesday, December 7, 2021

npm : Script : npm run build_dev

 npm install 

npm run  build_dev          

Kubenetes : Labels -l

 kubectl get pods -l app=rabbitmq -n cs


kubectl get pod -w -l app=rabbitmq -n cs


kubectl delete pod -l app=rabbitmq -n cs

Azure - Pipeline - Add Approver for Stage

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/approvals?view=azure-devops&tabs=check-pass