Posts

Showing posts from 2023

Nginx-How to config proxy_pass to https

  proxy_pass https://ltv-timesheet-sync.line-apps-beta.com/ ; proxy_ssl_server_name on; proxy_http_version 1.1;

Ingress Nginx in Kubernetes

1. Install Ingress Nginx  https://kubernetes.github.io/ingress-nginx/deploy/ helm install ingress-nginx-controller ingress-nginx --set controller.service.nodePorts.http=31845 --set controller.service.type=NodePort --set controller.replicaCount=5 --set controller.service.externalTrafficPolicy=Local --repo https://kubernetes.github.io/ingress-nginx --namespace ingress-nginx --create-namespace If you want to upgrade the deployment as DaemonSet helm upgrade   ingress-nginx-controller ingress-nginx/ingress-nginx -n ingress-nginx --set controller.kind=DaemonSet --set controller.service.nodePorts.http=31845 --set controller.service.type=NodePort --set controller.service.externalTrafficPolicy=Local helm upgrade ingress-nginx-controller ingress-nginx/ingress-nginx \ -n ingress-nginx \ --version="4.8.2" \ --set controller.kind=DaemonSet \ --set controller.service.nodePorts.http=31845 \ --set controller.service.type=NodePort \ --set controller.service.externalTrafficPolicy=L...

How to enable a service automaticlly restart after reboot VM

  sudo systemctl enable docker.service

How to create ISM policy and rotate logs in opensearch

  { "id" : "k8s_ingress-nginx" , "policy" : { "policy_id" : "k8s_ingress-nginx" , "description" : "Move indices into a cold state after 30 days and delete them after a year." , "default_state" : "hot" , "states" : [ { "name" : "hot" , "actions" : [ { "replica_count" : { "number_of_replicas" : 1 } } ] , "transitions" : [ { "state_name" : "cold" , "conditions" : { "min_index_age" : "3d" } ...

topology Spread Constraints

  apiVersion : apps/v1 kind : Deployment metadata : name : {{ .Values.deployment.name }} annotations : configmap.reloader.stakater.com/reload : {{ .Values.configMap.name }} spec : selector : matchLabels : app : cms replicas : {{ .Values.replicaCount }} template : metadata : name : cms labels : app : cms annotations : firth/job.0 : "cms" firth/port.0 : "30080" firth/path.0 : "/actuator/prometheus" spec : topologySpreadConstraints : - maxSkew : 1 topologyKey : kubernetes.io/hostname whenUnsatisfiable : ScheduleAnyway labelSelector : matchLabels : app : cms containers : - name : cms image : " {{ .Values.image.repository }} : {{ .Values.image.tag }} " imagePullPolicy : Always readinessProbe : httpGet : path : /health/liveness ...

How to assign pods to the specified node with label in kubernetes

 https://kubernetes.io/docs/tasks/configure-pod-container/assign-pods-nodes/

How does UTF-8 encoding know a character is one byte or two bytes

  That’s not how UTF-8 works. Characters U+0000 through U+007F (aka ASCII) are stored as single bytes. They are the only characters whose codepoints numerically match their UTF-8 presentation. For example, U+0041 becomes  0x41  which is  01000001  in binary. All other characters are represented with multiple bytes. U+0080 through U+07FF use two bytes each, U+0800 through U+FFFF use three bytes each, and U+10000 through U+10FFFF use four bytes each. Computers know where one character ends and the next one starts because UTF-8 was designed so that the single-byte values used for ASCII do not overlap with those used in multi-byte sequences. The bytes  0x00  through  0x7F  are only used for ASCII and nothing else; the bytes above  0x7F  are only used for multi-byte sequences and nothing else. Furthermore, the bytes that are used at the beginning of the multi-byte sequences also cannot occur in any other position in those sequences. Beca...

How to automatically run a shell script on startup or reboot in Linux

https://sysadminxpert.com/how-to-execute-script-or-command-on-reboot-or-startup-in-linux/   $ crontab –e ##Add your script here…. @reboot /your-script-location/script-name.sh

How to check pid in linux

    /var/run or /var/run/<name> directory  

Config nginx to read local index.html and return to clients

  http {     include       mime.types;     default_type   application/octet-stream;     #access_log   logs/access.log   main;     sendfile         on;     #tcp_nopush     on;     #keepalive_timeout   0;     keepalive_timeout   65;     #gzip   on;     server {         listen       80 default_server;         server_name   _;         #charset koi8-r;         #access_log   logs/host.access.log   main;         location   ~ \.(html|css|js)(.*)$ {             root /home/www/html;             index   index.html index.htm;         }      } }

Removing unused docker images and untaged docker image layers

docker system prune --all -f docker image prune -f --all --filter "until=1h"  

The following useful commands will help you find the root cause of "No left space" in your linux servers

sudo df -h sudo find . -type f -size +100M -exec ls -lh {} \; sudo du -h -d 1 -t 1G /home/www/.cache/

Github actions workflow

Work flow with trigger events name : BETA - Deploy Timesheet XXX service to K8S cluster on : push : branches : - beta paths-ignore : - 'api/**' - 'deployment/XXX-api/**' - '.github/workflows/api-**' jobs : BATCH-deployment-pipeline : name : Run batch deployment pipeline with the beta env uses : ./.github/workflows/xxx-deployment-pipeline.yml with : env : beta module-name : xxx namespace : XXX-batch-beta service-name : XXX-batch chart-path : deployment/XXX-batch/chart cluster-url : https://vks.com/v1/qwrehdfagsfhgbx branch : ${{github.ref}} secrets : harbor-pass : ${{ secrets.HARBOR_PASS }} vks-sa-token : ${{ secrets.VKS_SA_TOKEN }} redis-pass : ${{ secrets.XXX_REDIS_PASS }}             mysql-pass : ${{ secrets.XXX_MYSQL_PASS }}   ...