Wednesday 19 June 2019

Kubernetes Commands

Enter into the Deployment machine :
==> ssh -A core@<ipaddress> -i <name>.pem

Enter into api deployment machine
==> ssh core@<ipaddress>

To deploy the helm use below command
==> helm upgrade --recreate-pods <project-name>  <project-name> -f  <project-name>/values.yaml

To know the ip
==> helm status  <project-name>

To Find any command
==> Ctrl + r

To Install the helm in machine :
==> helm install  <project-name> -n  <project-name> -f  <project-name>/values.yaml


To Check the logs :
==>  kubectl logs -f <pod-name>

To check the latest 500 Logs :
==>  kubectl logs --tail 500 -f pod name

To find the names or folders :
==>  ls |grep <pod-name>

To get the pod name :
==> kubectl get pods | grep saas

To enter into the pod tomcat:
==> kubectl exec -it <pod-name> sh
==> kubectl exec -it <pod-name> bash

To Delete the pods
=============
To find the perticular logs in POD
==> kubectl logs -f <pod-name> | grep "any logger message "

To Delete/Stop the Pod :
==> helm del --purge  <project-name>

To Copy the logs from the remote pod machine
==> kubectl cp <pod-name>:usr/local/tomcat/logs .




## Helm
helm create saas-api                                                                    - Create helm folder structure 
helm lint saas-api                                                                        - Verify Yaml file from template
helm install saas-api --dry-run --debug        - Perform dry run which will replace value from values.yaml file to template yaml file

helm status saas-api                                                                    - Check the status of component
helm list                                                                                      - Get the list of deployed component

helm install saas-api -n seas-api -f saas-api/value.yaml             - Install component basically it will create new pods. Here first folder name is “Release name” second name is component folder name

helm upgrade --recreate-pods saas-api seas-api -f saas-api/values.yaml       - First give release name then folder name
helm upgrade --recreate-pods saas-api saas-api -f saas-api/values.yaml -f saas-api/values-harman-dev.yaml                                                                               - To replace values other than default

## K8S - Basic Commands:
kubectl get pods                                                                            - List all the pods
kubectl get pods |grep mess                                                          - This will list device message component pods
kubectl describe pods <pod-name>                                              - Shows the description of pods like which image is runnung stuff like that
kubectl get svc                                                                              - List all the service names
kubectl get svc|grep mess                                                             - Shows the service name with ip
kubectl apply -f <yaml file name>                                               - Start component
kubectl exec <pod-name> -it sh                                                   - Get into pod container
kubectl describe services device-message-api-int-svc              - Describes the given service

## Internal Service Name:
kubectl exec -it busybox -- nslookup 10.233.7.69
kubectl get svc -o wide | grep vault


## Log:
kubectl logs -f <pod-name>                                                            - Show component logs
kubectl logs --tail 10 -f <pod-name>                                              - Show component logs last 10 lines
kubectl logs --since 5m -f <pod-name>                                          - Show component logs since 5 mins


Run Command in Pods:
kubectl exec my-pod -- ls /


Delete:
kubectl delete pods <pod-name>
kubectl delete configmaps <configmap-name>


Mongo:
~~~~~~
kubectl exec -it mongo-qr-mjrcz bash
mongo --port 27017 admin -u admin -p 5D0c72dz4bxl

Postgres:
~~~~~~~~~
kubectl exec postgres-0 -it bash psql -U postgres

## Connect To Postgres in Kubernetes Env
kubectl exec postgres-0 -it bash psql -U postgres

See ELB:
kubectl get svc|grep comp
kubectl describe services vehicle-compatibility-api-ext-svc


Note: saas-api is the component name in this list.


Thursday 23 May 2019

GIT Commands


Step 1: Clone the project into local folder :
$ git clone <reviewbd url>
Step 2: Copy the project folder into the Local Folder
Step 3: To check the status use below command :
$ git status
Step 4: Add the Project Folder into repository.
$ git add <ProjectName>/
Step 5: Commit the Project/Files
$ git commit -m "initial commit for git and review"
Step 6: To check the repositories use below command
$ git remote -v
Step 7: To add the project into Remote location
$ git remote add origin git@<remoteServerip>:user1/user-project.git
Step 8: To Push the code
git push origin master
(OR)
git push origin HEAD:refs/for/master
Step 9: At any point you can view the history of your changes using
$ git log
Step 10: Create a new Branch
$ git branch <branch-name>
Step 11: To Check-out the branch
$ git checkout <branch-name>
Step 12: To Merge the code into master
$ git merge <branch-name>
Step 13: To Pull the code
$ git pull /home/lputta/ProjectName master
ex : git pull origin HEAD:refs/for/master
Step 14: To Tag the code
$ git tag v1.0 <Commit_Id>
Step 15: To check the difference
$ git diff
Step 16: To checkout files
$ git checkout <file-name-with-full-path>
ex : git checkout src/deploy/kubernetes/test.yaml
Step 17 : To reset the code changes
$ git reset --hard <change-Id>
ex : git reset --hard adsfadsf3434343da123dsfda11
Step 18 : To reset all the code changes
$ git reset .
ex : git reset . 
Step 19 : To Resolve the Merge Conflicts
i) git pull ==> if you get Merge Conflicts in your files.
ii) Take a back up of your files.
iii) Use git stash command to stash your changes
$ git stash
iv) Now again do pull you will get latest code.
$ git pull
v) Use pop command for merge with your changes in latest code.
$ git stash pop
vi) You will see some conflicts in your fles, please merge your changes in your workspace and commit your changes.

BitBucket Migration from GIT :

Process of Bitbucket migration

1. create repo “service-name” under https://bitbucket.elife.com/projects/lks

2. git clone ssh://lputta@reviewbd.harman.com:29440/services/service-name temp-dir

3. cd temp-dir

4. git remote set-url origin ssh://git@bitbucket.elife.com:7999/lks/service-name.git

5. git push -u origin --all 

6. git push origin —tags (Move all tags into the bitbucket)

Moving the sub-folder from Gerrit to bitbucket.
https://docs.github.com/en/get-started/using-git/splitting-a-subfolder-out-into-a-new-repository
https://ao.ms/how-to-split-a-subdirectory-to-a-new-git-repository-and-keep-the-history/

        1. git clone ssh://lokesh@reviewbd.elife.com:29440/service-name

        2. cd service-name

        3. git checkout master

        4. git filter-branch --prune-empty --subdirectory-filter service-name master

        5. create repo “service-name” under https://bitbucket.elife.com/projects/plk

        6. git remote set-url origin ssh://git@bitbucket.elife.com:7999/plk/service-name.git

        7. git push -u origin --all

        8. git push origin --tags


SpringBoot

SpringBoot SpringBoot Application :  Pros & Cons :  SpringBoot Application creation using spring.io :  SpringBoot Application Annotation...