Kubernetes’e Giriş
Frank Heilmann
Platform Architect and Freelance Instructor
kubectl: Kubernetes nesneleriyle etkileşim için temel komutpod, service vb.$$
Tipik kullanım kalıpları:
kubectl create -f <Manifest.yml>: yeni nesneler oluşturur; -f “filename” içindirkubectl apply -f <Manifest.yml>: yeni nesneler oluşturur ve nesnelerin durumunu değiştirirkubectl get <object>: Kubernetes’te dağıtılan nesnelere genel bakışkubectl describe <object>: bir nesne hakkında ayrıntılı bilgi$$
Ayrıntılı yardım: --help komut satırı seçeneği ile
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 5
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.25.4
ports:
- containerPort: 80
Durumsuz uygulamalar:
Kesintide, durumsuz uygulamanın yeni bir kopyası oluşturulur ve çalışmaya başlar.
apiVersion ve kindmetadata ve specspec, replicas sayısını, bir selector ve bir template tanımlarselector hakkında daha sonratemplate, Deployment’taki pod’ların nasıl oluşturulacağını açıklarapiVersion: apps/v1
kind: Deployment
metadata:
name: <deployment name>
labels:
app: <a label for the application>
spec:
replicas: <number of initial replicas>
selector:
matchLabels:
app: <matches the label above>
template:
metadata:
labels:
app: <label to be given to each pod>
spec:
containers:
- name: <container name>
image: <the image to be used>
ports:
- containerPort: <ports for networking>
kubectl apply -f <manifest.yml>.Kubernetes’e Giriş