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

Wednesday, November 24, 2021

Azure : How to get Client Secret for Azure Vault

https://docs.microsoft.com/en-gb/azure/active-directory/develop/quickstart-register-app#to-add-application-credentials-or-permissions-to-access-web-apis


https://jeanpaul.cloud/2020/06/06/how-to-do-app-registration-for-enterprise-application/

AWS : EC2 Instance Public IP : Could not connect to Internet : Windows EC2 Instance

https://intellipaat.com/community/42232/aws-ec2-instances-are-not-getting-to-internet-access



For Internet Access - 

A VM should be having Public IP address if its in Public Subnet and that Subnet should have Internet Gateway and Internet Gateway should have a route in Routetable

If a VM is in Private Subnet, It should have private IP and should have access to NAT Gateway in RouteTable of that Subnet

JDK Installation

https://adoptopenjdk.net/installation.html

AWS : EC2 Instances Pricing

https://aws.amazon.com/ec2/pricing/on-demand/

AWS : IGW vs NATGW

https://medium.com/awesome-cloud/aws-vpc-difference-between-internet-gateway-and-nat-gateway-c9177e710af6


Internet Gateway (IGW) allows instances with public IPs to access the internet.
NAT Gateway (NGW) allows instances with no public IPs to access the internet.


IGW allows Outside traffic to go in

NAT-GW does not allow Outside traffic to come in, It only allows from inside to Outside


Monday, November 22, 2021

Ansible : Ansible Playbook: Ansible Tower

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

https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html

Ansible :

  • Configuration Management 
  • YAML Based
  • Push Based Approach
  • Agentless Architecture - No agent on Target VMS - Simple SSH to Target VM
2 Parts on Local Machine/Server
1) Ansible Inventory : Client Manifest - Details of Group/Target Client VMs
2) Ansible Playbook : YAML - Job - Sections in Ansible - Yaml Configurations

The default location for inventory is a file called /etc/ansible/hosts
You can specify a different inventory file at the command line using the -i <path> option.

Michael DeHaan - Author of Ansible

Ansible was acquired by Redhat
Redhat was acquired by IBM

Ansible has a UI Centric version as well - Ansible Tower

Ansible Tower - Restful UI Web based 


Microservices: Spring Boot: Netflix : Components

https://www.optisolbusiness.com/insight/micro-services-architecture-spring-boot-and-netflix-infrastructure



Thursday, November 18, 2021

Convert Certificates into formats

https://knowledge.digicert.com/solution/SO26449.html

Best Certificate Viewer Tool : SSL Viewer : Keystore Explorer : keystore-explorer.org

 

https://keystore-explorer.org












AWS: Cloudformation : How to update Stack by a new resource

 LEARN  From Here  ->  https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/gettingstarted.templatebasics.html

https://aws.amazon.com/premiumsupport/knowledge-center/cloudformation-custom-name/

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks.html

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-whatis-howdoesitwork.html

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-targetgroup.html

Update requires: No interruption


docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-get-template.html#using-cfn-updating-stacks-get-stack.CON


When updating a stack, AWS CloudFormation might interrupt resources or replace updated resources, depending on which properties you update. For more information about resource update behaviors, see Update behaviors of stack resources.

Update methods


AWS CloudFormation provides two methods for updating stacks: direct update or creating and executing change sets. When you directly update a stack, you submit changes and AWS CloudFormation immediately deploys them. Use direct updates when you want to quickly deploy your updates.


With change sets, you can preview the changes AWS CloudFormation will make to your stack, and then decide whether to apply those changes. Change sets are JSON-formatted documents that summarize the changes AWS CloudFormation will make to a stack. Use change sets when you want to ensure that AWS CloudFormation doesn't make unintentional changes or when you want to consider several options. For example, you can use a change set to verify that AWS CloudFormation won't replace your stack's database instances during an update.


Drift detection operations



Monday, November 15, 2021

AWS : Cloudformation : Create LoadBalancer and Domains

docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-loadbalancer.html?icmpid=docs_cfn_console_designer

docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-recordset.html?icmpid=docs_cfn_console_designer

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-route53.html

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-targetgroup.html?icmpid=docs_cfn_console_designer

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-elb.html

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html

  • AWS Docs 
  • AWS User-Guide-Quick Reference

https://stackoverflow.com/questions/64794787/parameter-values-specified-for-a-template-which-does-not-require-them-when-tr

https://stackoverflow.com/questions/45749424/passing-multiple-parameters-from-external-file-to-cloudformation-template-and-us

aws cloudformation create-stack --stack-name cca-cloudformation-targetgroup --template-url s3://cca-cloudformation-template/CCA-CloudFormationTemplate-TargetGroup.json --parameters s3://cca-cloudformation-template/params.json

aws cloudformation create-stack --stack-name cca-cloudformation-targetgroup --template-body file://CCA-CloudFormationTemplate-TargetGroup.json --parameters file://params.json 

AWS : How to create Route53 Domains using Cloudformation Template

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-route53.html

Sunday, November 14, 2021

Azure : Mount Azure Storage Blob in Linux Folder : BlobFuse

https://docs.microsoft.com/en-us/azure/storage/blobs/storage-how-to-mount-container-linux

 Warning

Blobfuse doesn't guarantee 100% POSIX compliance as it simply translates requests into Blob REST APIs.

Install blobfuse

sudo apt-get install blobfuse

Configure your storage account credentials 

touch ~/fuse_connection.cfg

accountName myaccount
accountKey storageaccesskey
containerName mycontainer

Mount


sudo blobfuse ~/mycontainer --tmp-path=/mnt/resource/blobfusetmp  --config-file=/path/to/fuse_connection.cfg -o attr_timeout=240 -o entry_timeout=240 -o negative_timeout=120



Valid authentication setups:

  • Account Name & Key (authType Key)
    • Requires the accountName, accountKey and containerName specified in the config file or command line.
    • Alternatively accountName and accountKey can be specified by the following environment values instead: AZURE_STORAGE_ACCOUNT, AZURE_STORAGE_ACCESS_KEY.
  • Account Name & SAS (authType SAS)
    • Requires the accountName, containerName and sasToken specified in the config file or command line.
    • Alternatively accountName can be specified by the environment values AZURE_STORAGE_ACCOUNT
  • Managed Identity (authType MSI)
    • Single assigned identity:
      • No extra parameters needed.
    • Multiple assigned identities:
      • At least one of the following for the intended identity:
        • Client ID (Use this if you are using a custom Managed Identity endpoint)
        • Object ID
        • Resource ID
    • Add Storage Blob Data Contributor roles to this identity in the Storage account.
  • Service Principal Name (authType SPN)
    • Requires servicePrincipalClientId, servicePrincipalTenantId, servicePrincipalClientSecret specified in the config file.
    • Alternatively servicePrincipalClientSecret can be specified by the environment value AZURE_STORAGE_SPN_CLIENT_SECRET
    • AZURE_STORAGE_AAD_ENDPOINT`environment value can be used to specify a custom AAD endpoint to authenticate against
    • Add Storage Blob Data Contributor roles to this identity in the Storage account.

Linux: Delete Multiple Lines in VIM and Search for String in VIM

https://linuxize.com/post/vim-delete-line/

  • Press the Esc key to go to normal mode.
  • Place the cursor on the first line you want to delete.
  • Type 5dd and hit Enter to delete the next five lines.
----------------------------------------------------------------


The basic steps to perform a search in Vim are as follows:

  • 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.

Friday, November 12, 2021

Mount S3 Bucket onto Linux Folder : s3FS : FUSE - Filesystem in Userspace

https://levelup.gitconnected.com/how-to-mount-s3-bucket-on-an-ec2-linux-instance-df44c7885aae

https://medium.com/tensult/aws-how-to-mount-s3-bucket-using-iam-role-on-ec2-linux-instance-ad2afd4513ef

S3FS

An S3 bucket can be mounted in an AWS instance as a file system known as S3fs. S3fs is a FUSE file system that allows you to mount an Amazon S3 bucket as a local file system.

Filesystem in Userspace (FUSE) is a simple interface for userspace programs to export a virtual file system to the Linux kernel.


  • Install S3FS
  • vim /etc/passwd-s3fs [Enter AccessKey/Secret Key of AWS having full S3 Permissions]
  • Mount Bucket to a Linux Folder
          mkdir /mys3bucket
         s3fs your_bucketname -o use_cache=/tmp -o allow_other -o uid=1000 -o mp_umask=002 -o multireq_max=5 /mys3bucket

Friday, October 22, 2021

EKS : Kubernetes : AWS : Install Kubernetes on Control Plane and Configure EKS with kubectl

visudo
703250313 ALL=(ALL) NOPASSWD: ALL
eks                ALL=(ALL) NOPASSWD: ALL

export VISUAL=vim
export EDITOR="$VISUAL"


> Bootstrapping clusters with kubeadm
> Installing Kubernetes with kops
> Installing Kubernetes with Kubespray

Installing kubeadm, kubelet and kubectl
""""""""""You will install these packages on all of your machines:"""""""""
kubeadm: the command to bootstrap the cluster.
kubelet: the component that runs on all of the machines in your cluster and does things like starting pods and containers.
kubectl: the command line util to talk to your cluster.

apt-get install bash-completion
source /usr/share/bash-completion/bash_completion
type _init_completion
echo 'source <(kubectl completion bash)' >>~/.bashrc
kubectl completion bash >/etc/bash_completion.d/kubectl
kubectl completion bash


> sudo snap install kubectl --classic
> kubectl version --client

history | grep SEARCH_STRING


curl -o aws-iam-authenticator https://amazon-eks.s3.us-west-2.amazonaws.com/1.21.2/2021-07-05/bin/linux/amd64/aws-iam-authenticator
chmod +x ./aws-iam-authenticator
mkdir -p $HOME/bin && cp ./aws-iam-authenticator $HOME/bin/aws-iam-authenticator && export PATH=$PATH:$HOME/bin
echo 'export PATH=$PATH:$HOME/bin' >> ~/.bashrc
aws-iam-authenticator help


find ./path/subpath searchFileName
Syntax :
$ find [where to start searching from]
 [expression determines what to find] [-options] [what to find]
 
 
 Instead of manually making 1 node as Kubenetes Master and rest as worker using "kubeadm" manually
 We go for EKS approach
 
 kubectl cluster-info
 kubectl 
 kubectl get pods
 
 
 eks@GRDLUSAWSJS01:~$ kubectl get deployment  -n fda
NAME                 READY   UP-TO-DATE   AVAILABLE   AGE
analytics            1/1     1            1           378d
business-rules       1/1     1            1           330d
case-management      1/1     1            1           330d
classifiy-rule       1/1     1            1           378d
cora-mail            1/1     1            1           378d
data-processor       1/1     1            1           330d
doc-conversion-api   1/1     1            1           323d
eaas-service         1/1     1            1           378d
email-segmentator    1/1     1            1           378d
flowable             1/1     1            1           330d
genex-runtime        1/1     1            1           378d
ief-classification   1/1     1            1           377d
ief-extraction       1/1     1            1           377d
ief-tensorflow       1/1     1            1           377d
ml-webapp            1/1     1            1           332d
modelserver          1/1     1            1           378d
nlu-service          1/1     1            1           378d
ocr-nuance           1/1     1            1           378d
output-generation    1/1     1            1           330d
platform             1/1     1            1           330d
slot-modelserver     1/1     1            1           368d
slot-serving         1/1     1            1           368d
trainer              1/1     1            1           378d
usaaddress           1/1     1            1           330d
vea-cc               1/1     1            1           378d
vea-nlp              1/1     1            1           378d

eks@GRDLUSAWSJS01:~$ kubectl rollout history deployment vea-cc -n fda
deployment.apps/vea-cc
REVISION  CHANGE-CAUSE
1         <none>
2         <none>
3         <none>
4         <none>


eks@GRDLUSAWSJS01:~$ kubectl get nodes
NAME                            STATUS   ROLES    AGE    VERSION
ip-10-102-25-101.ec2.internal   Ready    <none>   151d   v1.17.9-eks-4c6976
ip-10-102-25-105.ec2.internal   Ready    <none>   274d   v1.17.9-eks-4c6976
ip-10-102-25-142.ec2.internal   Ready    <none>   69d    v1.17.9-eks-4c6976
ip-10-102-25-143.ec2.internal   Ready    <none>   179d   v1.17.9-eks-4c6976
ip-10-102-25-149.ec2.internal   Ready    <none>   330d   v1.17.9-eks-4c6976
ip-10-102-25-186.ec2.internal   Ready    <none>   260d   v1.17.9-eks-4c6976
ip-10-102-25-247.ec2.internal   Ready    <none>   260d   v1.17.9-eks-4c6976
ip-10-102-25-29.ec2.internal    Ready    <none>   302d   v1.17.9-eks-4c6976
ip-10-102-25-31.ec2.internal    Ready    <none>   326d   v1.17.9-eks-4c6976
ip-10-102-25-40.ec2.internal    Ready    <none>   260d   v1.17.9-eks-4c6976
ip-10-102-26-106.ec2.internal   Ready    <none>   330d   v1.17.9-eks-4c6976
ip-10-102-26-111.ec2.internal   Ready    <none>   330d   v1.17.9-eks-4c6976
ip-10-102-26-55.ec2.internal    Ready    <none>   179d   v1.17.9-eks-4c6976
ip-10-102-26-58.ec2.internal    Ready    <none>   233d   v1.17.9-eks-4c6976
ip-10-102-26-74.ec2.internal    Ready    <none>   179d   v1.17.9-eks-4c6976
ip-10-102-26-88.ec2.internal    Ready    <none>   164d   v1.17.9-eks-4c6976


eks@GRDLUSAWSJS01:~$ kubectl cluster-info
Kubernetes master is running at https://23BB04FB3E3508D16899825B2B3F38FA.yl4.us-east-1.eks.amazonaws.com
CoreDNS is running at https://23BB04FB3E3508D16899825B2B3F38FA.yl4.us-east-1.eks.amazonaws.com/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at https://23BB04FB3E3508D16899825B2B3F38FA.yl4.us-east-1.eks.amazonaws.com/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
eks@GRDLUSAWSJS01:~$


Linux : PING - Internet Speed Test : 8.8.8.8 - Google DNS

https://wisetut.com/best-ping-test-ip-addresses-google-dns-8-8-8-8-cloudflare-dns-1-1-1-1/


The network connection to the 8.8.8.8 Google DNS service can be tested with the ping command like below.

$ ping 8.8.8.8

The output is like below as we can see that the time or RTT is very low.

Linux : Ubuntu - APT vs SNAP

https://phoenixnap.com/kb/snap-vs-apt

Linux:/etc/shells or /etc/os-release

 eks@GRDLUSAWSAMUT01:~$ cat /etc/os-release

NAME="Ubuntu"

VERSION="18.04.6 LTS (Bionic Beaver)"

ID=ubuntu

ID_LIKE=debian

PRETTY_NAME="Ubuntu 18.04.6 LTS"

VERSION_ID="18.04"

HOME_URL="https://www.ubuntu.com/"

SUPPORT_URL="https://help.ubuntu.com/"

BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"

PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"

VERSION_CODENAME=bionic

UBUNTU_CODENAME=bionic

eks@GRDLUSAWSAMUT01:~$ cat /etc/shells

# /etc/shells: valid login shells

/bin/sh

/bin/bash

/bin/rbash

/bin/dash

/usr/bin/tmux

/usr/bin/screen

eks@GRDLUSAWSAMUT01:~$


Linux:Kubectl : Add New User: Add User to secondary group : Change default Shell of a user

https://linuxize.com/post/how-to-create-users-in-linux-using-the-useradd-command/ 

sudo useradd -m username

ls -la /home/username/

https://careerkarma.com/blog/linux-add-user-to-group/

sudo usermod -a -G group_to_add username


https://www.tecmint.com/change-a-users-default-shell-in-linux/

 usermod --shell /bin/bash tecmint



admin@MACHINEVM01:~$ hostname -I

10.102.25.95 172.17.0.1 172.19.0.1

admin@MACHINEVM01:~$ getent passwd|grep admin

admin:*:16777219:16777220:Kaw, Karan:/home/admin:/bin/bash

admin@MACHINEVM01:~$ getent group|grep docker

docker:x:118:

admin@MACHINEVM01:~$ groups admin

admin : domain users BUILTIN\users

admin@MACHINEVM01:~$ sudo useradd -m eks

[sudo] password for admin:

admin@MACHINEVM01:~$ groups eks

eks : eks

admin@MACHINEVM01:~$ id eks

uid=1006(eks) gid=1006(eks) groups=1006(eks)

admin@MACHINEVM01:~$ getent group|grep eks

eks:x:1006:

admin@MACHINEVM01:~$ getent passwd|grep eks

eks:x:1006:1006::/home/eks:/bin/sh

admin@MACHINEVM01:~$ sudo usermod -a -G docker eks

admin@MACHINEVM01:~$ getent passwd|grep eks

eks:x:1006:1006::/home/eks:/bin/sh

admin@MACHINEVM01:~$ groups eks

eks : eks docker

admin@MACHINEVM01:~$


Docker-Compose Comands


apt install docker.io

apt install docker-compose


docker-compose up

docker-compose up -d


docker image ls

docker container ls


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

docker ps

docker images

docker-compose -f docker-compose.yml down

docker-compose -f docker-compose.yml up -d


 netstat -tulpn|grep LISTEN

 

 tail -f nohup.out



 

Thursday, October 21, 2021

Linux : Bash-Completion :Kubernetes

kubernetes.io/docs/tasks/tools/included/optional-kubectl-configs-bash-linux/


apt-get install bash-completion or yum install bash-completion


o find out, reload your shell and run type _init_completion. If the command succeeds, you're already set, otherwise add the following to your ~/.bashrc file:

source /usr/share/bash-completion/bash_completion


The kubectl completion script for Bash can be generated with the command 

kubectl completion bash


 kubectl rollout history deployment vea-cc  -n fda



Azure - Pipeline - Add Approver for Stage

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