29 Mart 2021 Pazartesi

inode Nedir

Her Dosya Sisteminde inode Yoktur
Açıklaması şöyle
For virtual, volatile, or inode-agnostic filesystems, inode numbers are usually generated from a monotonically incrementing, 32-bit counter when the inode is created. The rest of the inode (eg. permissions) is built from the equivalent data in the underlying filesystem, or is replaced with values set at mount time (eg. {uid,gid}=) if no such concept exists.
Örnek - VFAT
Elimizde bir VFAT dosya sistemi olsun. Şöyle yaparız. Burada inode değerlerinin üretildiği görülebilir.
% ls -li
合計 736
1207 drwxr-xr-x 3 root root  16384  3月 10 10:42 efi
1208 -rwxr-xr-x 1 root root 721720  3月 22 14:15 kernel.bin

5 Mart 2021 Cuma

google-chrome komutu

--dump-dom seçeneği
Sayfanın görüntüsünü HTML olarak alabilmeyi sağlar. Böylece sayfadaki JavaScript kodları kaydedilmez.
Örnek
Şöyle yaparız
google-chrome --headless --dump-dom 'URL' > ~/file.html

24 Şubat 2021 Çarşamba

~/.bashrc Dosyası - Her Yeni Kabuk İçin Çalışır

Giriş
Açıklaması şöyle. Her etkileşimli kabuk (interactive shell) açıldığında bu dosya okunur
~/.bashrc is appropriate for aliases. ~/.bash_profile is run only for login shells, ~/.bashrc is run for every interactive shell. And, yes, you need to re-source ~/.bashrc after editing it to take immediate effect.
Açıklaması şöyle. ssh ile bağlanınca bu dosya normalde çalışır.
(man bash) Bash attempts to determine when it is being run with its standard input connected to a network connection, as when executed by the remote shell daemon, usually rshd, or the secure shell daemon sshd. If bash determines it is being run in this fashion, it reads and executes commands from ~/.bashrc, if that file exists and is readable. It will not do this if invoked as sh. The --norc option may be used to inhibit this behavior, and the --rcfile option may be used to force another file to be read, but neither rshd nor sshd generally invoke the shell with those options or allow them to be specified.
Dosyanın içinde şöyle bir satır var. Yani ".bash_aliases" dosyasını da okur
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi
Bu Dosyanın Değişmesini Engelleme
Bazı kurulumlardan sonra bu dosyaya bir şeyler eklenebiliyor. Bunu engellemek için şöyle yaparız
If you end your .bashrc with
return 0
Bash will ignore any lines added after that, since .bashrc is handled like a sourced script:

hexdump komutu

-C seçeneği
Şöyle yaparız
$ hexdump -C demo
00000000  51 cc b4 cc 91 cc 8d cc  89 cc 86 cc 89 cd 9d cd  |Q...............|
00000010  9b cc 91 cc 95 cc 82 cc  aa cc 98 cc b3 cc a3 cc  |................|
00000020  a2 cc 9e cc a9 cc aa 0a                           |........|
00000028

23 Şubat 2021 Salı

Kubernetes Autoscaler

Giriş
Kubernetes için 3 tane autoscaler var. Bunlar şöyle
1. Horizontal Pod Autoscaler : Pod sayınını ölçeklendirir
2. Vertical Pod Autoscaler : İşlemci ve belleği ölçeklendirir
3. Cluster Autoscaler : Cluster'a node eklemeyi ölçeklendirir
Cluster Autoscaler
Eğer cluster'da yeni pod için kaynak yoksa, horizontal autocaler zaten işe yaramaz.

Horizontal Pod Autoscaler
Kaç tane POD'un çalışması gerektiğine karar veren bileşenin ismi "Horizontal Pod Autoscaler". CPU ve bellek kullanımına bakarak bir formül çalıştırır. Açıklaması şöyle.
Kubernetes’ Horizontal Pod Autoscaler (HPA) automatically scales the application workload by scaling the number of Pods in deployment (or replication controller, replica set, stateful set), based on observed metrics like CPU utilization, memory consumption, or with custom metrics provided by the application. 

HPA uses the following simple algorithms to determine the scaling decision, and it can scale the deployment within the defined minimum and the maximum number of replicas. 

desiredReplicas = ceil[currentReplicas * ( currentMetricValue / desiredMetricValue )]
Örnek - CPU
Şöyle yaparız
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: hello-world
  namespace: default
spec:
  maxReplicas: 10
  minReplicas: 1
  scaleTargetRef:
    apiVersion: extensions/v1beta1
    kind: Deployment
    name: hello-world
  targetCPUUtilizationPercentage: 50

Scale To Zero
Şu anda sıfır POD'a indirmek desteklenmiyor. Açıklaması şöyle.
Kubernetes’ default HPA is based on CPU utilization and desiredReplicas never go lower than 1, where CPU utilization cannot be zero for a running Pod. This is the same behavior for memory consumption-based autoscaling, where you cannot achieve scale to zero. However, it is possible to scale into zero replicas if you ignore CPU and memory utilization and consider other metrics to determine whether the application is idle. For example, a workload that only consumes and processes a queue can scale to zero if we can take queue length as a metric and the queue is empty for a given period of time. Of course, there should be other factors to consider like lower latency sensitivity and fast bootup time (warm-up time) of the workload to have a smooth user experience. 

But, the current Kubernetes current stable release (v1.19) does not support scale to zero, and you can find discussions to support this in the Kubernetes enhancements gitrepo.

15 Şubat 2021 Pazartesi

8 Şubat 2021 Pazartesi

kubectl scale seçeneği

--replicas seçeneği
pos sayısını artırmak için şöyle yaparız
kubectl scale --replicas=5 deployment/backend
5 tane pod olduğunu görmek için şöyle yaparız
kubectl get pods
pod sayısını düşürmek için şöyle yaparız
kubectl scale --replicas=1 deployment/backend
statefulsets seçeneği
Örnek
Şöyle yaparız
kubectl scale statefulsets <stateful-set-name> --replicas=<new-replicas>