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.


SpringBoot

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