Bu komut sadece Rhel RedHat Enterprise Linux'ta var. Kurulu paketleri listeler
27 Eylül 2021 Pazartesi
Proxmox
Giriş
Proxmox sanal makineler (virtual machine) çalıştırabilmek içindir. Proxmox bir Kernel-based Virtual Machine. Açıklaması şöyle. Yani Linux çekirdeğine değişiklik yapılarak hypervisor haline geliyor ve sanal makineler çalıştırabilmesi sağlanıyor. KVM Linux'un bir parçası
Proxmox runs on the Debian GNU operating system (OS) for Linux with a customized Linux kernel. It runs kernel-based virtual machines (KVM) for virtualization and Linux containers (LXC) for containerization.
Google Cloud Platform (GCP) üzerinde koşan sanal makineler yerine Proxmox kullanılabilir.
VmWare
VMWare ESXi üzerinde koşar. Bu type 1 bir hypervisor. Yani bare metal. Kendisi bir işletim sistemi gibi düşünülebilir. Açıklaması şöyle
As a type-1 hypervisor, ESXi is not a software application that is installed on an operating system (OS); instead, it includes and integrates vital OS components, such as a kernel.
20 Eylül 2021 Pazartesi
fstat metodu
Giriş
stat metodu ile kardeştir.
Örnek
Şöyle yaparız.
stat metodu ile kardeştir.
Örnek
Şöyle yaparız.
int fileSize = 0;
int fd = ...;
struct stat buf;
fstat(fd, &buf);
fileSize = buf.st_size;stat metodu
Giriş
Şu satırı dahil ederiz.
stat yapısı
İçi şöyledir. Bu yapı işletim sistemine göre değişiklik gösterebilir. Alanların isimleri biraz farklılaşıyor ancak temel olarak aynı işi görüyor.
Şöyle kullanırız.
stat() çağrısının döndürdüğü sonuç 0'an faklı ise errno değişkenine ENOENT, ENOTDIR, EACCESS gibi değerler atanır.
ENOTDIR için açıklama şöyle
dizin olup olmadığını kontrol için şöyle yaparız.
Şöyle yaparız.
Şöyle buluruz.
Şu satırı dahil ederiz.
#include <sys/stat.h>stat() sistem çağrısı Linux'ta çok kullanılır. fstat metodu ile kardeştir.stat yapısı
İçi şöyledir. Bu yapı işletim sistemine göre değişiklik gösterebilir. Alanların isimleri biraz farklılaşıyor ancak temel olarak aynı işi görüyor.
struct stat {
dev_t st_dev; /* ID of device containing file */
ino_t st_ino; /* inode number */
mode_t st_mode; /* protection */
nlink_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of owner */
gid_t st_gid; /* group ID of owner */
dev_t st_rdev; /* device ID (if special file) */
off_t st_size; /* total size, in bytes */
blksize_t st_blksize; /* blocksize for filesystem I/O */
blkcnt_t st_blocks; /* number of 512B blocks allocated */
time_t st_atime; /* time of last access */
time_t st_mtime; /* time of last modification */
time_t st_ctime; /* time of last status change */
};st_blksize Alanı
Açıklaması şöyle
st_blksize is called "the optimum I/O size" and unrelated to the units used for st_blocks. The optimum I/O size of course is filesystem specific. This is a result from the fast filesystem development from Berlekey in 1981/1982. Before, there was no optimum block size in the available filesystem
st_blocks Alanı
Bu alanın değier HP-UX'te biraz farklı. Açıklaması şöyle
stat metodust_blocks is expressed in units of DEV_BSIZE that indeed is 1024 on HP-UX. DEV_BSIZE is a platform specific constant. Later, when FFS was renamed to UFS, there was a second filesystem in BSD UNIX with different behavior related to indirect blocks and that required this new stat() field.
Şöyle kullanırız.
struct stat info;
stat("test.txt", &info);Döndürdüğü Sonuçstat() çağrısının döndürdüğü sonuç 0'an faklı ise errno değişkenine ENOENT, ENOTDIR, EACCESS gibi değerler atanır.
ENOTDIR için açıklama şöyle
If it is ENOTDIR then part of the path you provided is not a directory,EACCES için açıklama şöyle
If it's EACCESS then you didn't have read permission on one of the directories in the path and so stat can't give you an answer.ENOENT için açıklama şöyle
ENOENT means "No such file and directory", and is for path operations.stat ve macrolar
dizin olup olmadığını kontrol için şöyle yaparız.
//Test for directory
if(S_ISDIR(info.st_mode))
{
..
}Normal bir dosya (sembolik link olmayan) olup olmadığını kontrol için şöyle yaparız.//Test for a regular file.
if(S_ISREG(info.st_mode))
{
..
}Character Device olup olmadığını kontrol için şöyle yaparız.if (S_ISCHR(info.st_mode)) {...}dosyanın mevcudiyetiŞöyle yaparız.
int file_exist (char *filename)
{
struct stat buffer;
return (stat (filename, &buffer) == 0);
}en son değişme zamanı - last modification timeŞöyle buluruz.
struct stat info;
stat("test.txt", &info);
printf("%s", ctime(&info.st_mtime));17 Eylül 2021 Cuma
Kubernetes Deployment İçin Volumes
Giriş
Çeşitli volume tipleri var.
1. emptyDir
2. PersistentVolume
gibi
emptyDir
Şu cümleler önemli
emptyDir are volumes that get created empty when a Pod is created.Deleting a Pod deletes all its emptyDirs.emptyDir are meant for temporary working disk space.
Örnek
Şöyle yaparız
apiVersion: apps/v1kind: Deploymentmetadata:name: dune-quote-servicespec:replicas: 1selector:matchLabels:app: dune-quote-servicetemplate:metadata:labels:app: dune-quote-servicespec:containers:- image: gamussa/reactive-quote-service:0.0.3imagePullPolicy: Alwaysname: dune-quote-serviceports:- containerPort: 9001env:...- name: GRPC_SERVER_SECURITY_CERTIFICATECHAINvalue: "file:/mnt/grpc-cert-chain/server.crt"- name: GRPC_SERVER_SECURITY_PRIVATEKEYvalue: "file:/mnt/grpc-pk/server.key"volumeMounts:- mountPath: /mnt/grpc-cert-chainname: grpc-cert-chain- mountPath: /mnt/grpc-pkname: grpc-pkvolumes:- name: grpc-cert-chainsecret:secretName: grpc-cert-chain- name: grpc-pksecret:secretName: grpc-pk
Örnek - sadece tmp Dizini Hakkı
Açıklaması şöyle
Applications running in a containerized environment seldom write data, as that practically goes against the logic of having an immutable system. However, at times, it may be needed for caching or temporary swapping/processing of files. Hence, to provide this functionality to the developer, we can mount an emptyDir as an ephemeral volume which is lost once the container is killed.With this in place, we can also add another security context attribute called “readOnlyRootFilesystem” and set it as true, since the application running inside the container no longer needs to write anywhere on the file-system other than the ‘tmp’ directory.
Şöyle yaparız
apiVersion: apps/v1kind: Deploymentmetadata:labels:app: springbootmavenname: springbootmavennamespace: bootspec:replicas: 1selector:matchLabels:app: springbootmaventemplate:metadata:labels:app: springbootmavenspec:securityContext:fsGroup: 1337runAsNonRoot: truerunAsUser: 1337containers:- image: salecharohit/springbootmavenname: springbootmavenports:- containerPort: 8080securityContext:allowPrivilegeEscalation: falsereadOnlyRootFilesystem: trueprivileged: falserunAsUser: 1337capabilities:drop: ["SETUID", "SETGID"]volumeMounts:- mountPath: /tmpname: tmpserviceAccountName: ""automountServiceAccountToken: falsevolumes:- emptyDir: {}name: tmp
16 Eylül 2021 Perşembe
Kubernetes Servis Nedir?
Giriş
Açıklaması şöyle
Açıklaması şöyle. Dış dünyaya açılan yüzümüz diye düşünebiliriz.
A Service enables network access to a set of Pods in Kubernetes.Services select Pods based on their labels. When a network request is made to the service, it selects all Pods in the cluster matching the service's selector, chooses one of them, and forwards the network request to it.
Service ve Deployment Farkı Nedir?
Açıklaması şöyle.A deployment is responsible for keeping a set of pods running.Servis Tipleri Nedir?
A service is responsible for enabling network access to a set of pods.
Açıklaması şöyle
The type property in the Service's spec determines how the service is exposed to the network. It changes where a Service is able to be accessed from. The possible types are ClusterIP, NodePort, and LoadBalancer
- ClusterIP – The default value. The service is only accessible from within the Kubernetes cluster – you can’t make requests to your Pods from outside the cluster!
- NodePort – This makes the service accessible on a static port on each Node in the cluster. This means that the service can handle requests that originate from outside the cluster.
- LoadBalancer – The service becomes accessible externally through a cloud provider's load balancer functionality. GCP, AWS, Azure, and OpenStack offer this functionality. The cloud provider will create a load balancer, which then automatically routes requests to your Kubernetes Service
servisleri görmek için kubectl get services kullanılır
ClusterIP Service yazısına bakabilirsiniz
LoadBalanceService yazısına bakabilirsiniz
IngressService yazısına bakabilirsiniz
Kubernetes Pod Nedir?
Giriş
Pod, Kubernetes mimarisinde Kubernetes Node'un bir parçası. Kısaca container'ları çalıştırır deyebiliriz.
The primary reason that Pods can have multiple containers is to support helper applications that assist a primary application. Typical examples of helper applications are data pullers, data pushers, and proxies. Helper and primary applications often need to communicate with each other. Typically this is done through a shared filesystem, as shown in this exercise, or through the loopback network interface, localhost. An example of this pattern is a web server along with a helper program that polls a Git repository for new updates.
Ancak bu tavsiye edilmediği için pod = container gibi düşünülebilir.
The containers are called as ‘Pod’ in Kubernetes terms. So a single Kubernetes node can have multiple containers.
Pod örneğin bir servis olabilir.
Kubernetes Servis Nedir? yazısına bakabilirsiniz
Örnek
Buradaki şekilde aynı Pod içinde çalışan farklı container'lar görülebilir.
Kaydol:
Kayıtlar (Atom)
