Skip to content

Commit 341ce8f

Browse files
proje cozum dosyaları
1 parent 551882b commit 341ce8f

16 files changed

+748
-13
lines changed

authetication/README.md

+24-9
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44

55

66
**Key ve CSR oluşturma**
7-
openssl genrsa -out ozgurozturk.key 2048
8-
openssl req -new -key ozgurozturk.key -out ozgurozturk.csr -subj "/CN=[email protected]/O=DevTeam"
7+
```
8+
$ openssl genrsa -out ozgurozturk.key 2048
99
10+
$ openssl req -new -key ozgurozturk.key -out ozgurozturk.csr -subj "/[email protected]/O=DevTeam"
11+
```
1012

1113
**CertificateSigningRequest oluşturma**
12-
cat <<EOF | kubectl apply -f -
14+
15+
```
16+
$ cat <<EOF | kubectl apply -f -
1317
apiVersion: certificates.k8s.io/v1
1418
kind: CertificateSigningRequest
1519
metadata:
@@ -22,13 +26,24 @@ spec:
2226
usages:
2327
- client auth
2428
EOF
29+
```
2530

2631
**CSR onaylama ve crt'yi alma**
27-
kubectl get csr
28-
kubectl certificate approve ozgurozturk
29-
kubectl get csr ozgurozturk -o jsonpath='{.status.certificate}' | base64 -d >> ozgurozturk.crt
32+
33+
```
34+
$ kubectl get csr
35+
36+
$ kubectl certificate approve ozgurozturk
37+
38+
$ kubectl get csr ozgurozturk -o jsonpath='{.status.certificate}' | base64 -d >> ozgurozturk.crt
39+
```
3040

3141
**kubectl config ayarları**
32-
kubectl config set-credentials [email protected] --client-certificate=ozgurozturk.crt --client-key=ozgurozturk.key
33-
kubectl config set-context ozgurozturk-context --cluster=minikube --user=[email protected]
34-
kubectl config use-context ozgurozturk-context
42+
43+
```
44+
$ kubectl config set-credentials [email protected] --client-certificate=ozgurozturk.crt --client-key=ozgurozturk.key
45+
46+
$ kubectl config set-context ozgurozturk-context --cluster=minikube [email protected]
47+
48+
$ kubectl config use-context ozgurozturk-context
49+
```

proje/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
- Her iki uygulama da aynı worker node üstünde schedule edilecek.
1919
- Her iki uygulama için de cpu ve memory kaynak kısıtları tanımlı olacak.
2020

21-
**7:** "test" namespace'inde deploy edilen wordpress uygulaması "testblog.example.com", "production" namespace'inde deploy edilen wordpress uygulaması "blog.example.com" olarak ingress üstünden dış dünyaya expose edilecek.
21+
**7:** "test" namespace'inde deploy edilen wordpress uygulaması "testblog.example.com", "production" namespace'inde deploy edilen wordpress uygulaması "companyblog.example.com" olarak ingress üstünden dış dünyaya expose edilecek.
2222

2323
**8:** "production" namespace'inde "ozgurozturknet/k8s:v1" imajından, 5 replikalı, update stratejisi olarak aynı anda 2 pod'un update edilebileceği bir deployment oluşturun. "/healthcheck" endpoint'ini sorgulayan "liveness probe" ve "/ready" endpoint'ini sorgulayan bir "readiness probe" tanımları da olsun.
2424

proje/cozum/README.md

+193-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
**1:** 5 node'lu "1 Master + 4 Worker Node" bir Kubernetes cluster kurun.
2-
2+
<details>
3+
<summary>Çözümü görmek için tıklayınız!</summary>
34
Minikube:
5+
46
```
5-
minikube start ---node=5
7+
$ minikube start ---node=5
68
```
79

810
AKS:
@@ -14,14 +16,202 @@ $ az aks create --name aks-k8sproje --resource-group rg-k8sproje --node-vm-size
1416
1517
$ az aks get-credentials --name aks-k8sproje --resource-group rg-k8sproje
1618
```
19+
</details>
20+
1721
***
1822
**2:** "test" ve "production" adlarında 2 namespace oluşturun.
23+
<details>
24+
<summary>Çözümü görmek için tıklayınız!</summary>
1925

2026
```
2127
$ kubectl create namespace test
2228
23-
$ kubectl create namespace prod
29+
$ kubectl create namespace production
2430
```
31+
</details>
32+
2533
***
2634
**3:** "junior" isimli grubun "test" namespace'inde tüm kaynaklar üstünde "okuma, listeleme, yaratma..." gibi tüm haklara, "production" namespace'inde ise tüm kaynaklar üstünde sadece "okuma ve listeleme" haklarına sahip olacağı rol oluşturup bunları grupla ilişkilendirin. Aynı şekilde "senior" isimli grubun "production" ve "test" namespace'lerindeki tüm kaynaklar üstünde "okuma, listeleme, yaratma..." gibi tüm haklara ve cluster üstündeki diğer kaynaklar üstünde ise sadece "okuma ve listeleme" haklarına sahip olacağı rol oluşturup bunları grupla ilişkilendirin.
2735

36+
<details>
37+
<summary>Çözümü görmek için tıklayınız!</summary>
38+
39+
```
40+
$ kubectl apply -f ./yaml/jr-production-rb.yaml
41+
42+
$ kubectl apply -f ./yaml/jr-test-rb.yaml
43+
44+
$ kubectl apply -f ./yaml/sr-cluster-crb.yaml
45+
46+
$ kubectl apply -f ./yaml/sr-production-rb.yaml
47+
48+
$ kubectl apply -f ./yaml/sr-test-rb.yaml
49+
```
50+
</details>
51+
52+
***
53+
**4:** Sizin seçeceğiniz bir "ingress controller" kurun. (nginx, traefik, haproxy vb.)
54+
55+
<details>
56+
<summary>Çözümü görmek için tıklayınız!</summary>
57+
58+
Nginx: https://kubernetes.github.io/ingress-nginx/deploy/
59+
60+
AKS:
61+
```
62+
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.47.0/deploy/static/provider/cloud/deploy.yaml
63+
```
64+
65+
Minikube:
66+
```
67+
$ minikube addons enable ingress
68+
```
69+
</details>
70+
71+
***
72+
**5:** Cluster'da seçeceğiniz 3 worker node sadece "production" ortamında deploy edeceğiniz ve cluster tarafından oluşturulan podlar schedule edilebilsin. Bunun dışındaki podların bu worker node üstünde oluşturulmamasını sağlayın.
73+
<details>
74+
<summary>Çözümü görmek için tıklayınız!</summary>
75+
76+
```
77+
$ node1=$(kubectl get no -o jsonpath="{.items[1].metadata.name}")
78+
79+
$ node2=$(kubectl get no -o jsonpath="{.items[2].metadata.name}")
80+
81+
$ node3=$(kubectl get no -o jsonpath="{.items[3].metadata.name}")
82+
83+
$ kubectl taint node $node1 tier=production:NoSchedule
84+
85+
$ kubectl taint node $node2 tier=production:NoSchedule
86+
87+
$ kubectl taint node $node3 tier=production:NoSchedule
88+
89+
$ kubectl label node $node1 tier=production
90+
91+
$ kubectl label node $node2 tier=production
92+
93+
$ kubectl label node $node3 tier=production
94+
```
95+
96+
</details>
97+
98+
***
99+
**6:** Wordpress uygulamasını hem "test" hem de "production" namespace'lerinde deploy edin. (wordpress:latest ve mysql:5.6 imajlarından oluşturulacak)
100+
101+
- mysql "ClusterIp" tipi bir servisle cluster içinden erişilebilir olacak.
102+
- Her iki uygulamanın da uzun dönem verilerini "persistent volume"ler üzerinde saklanacak.
103+
- Her iki uygulamanın da hiç bir hassas bilgisi "ör: şifre" uygulama ya da yaml dosyaları içerisinde tutulmayacak.
104+
- Her iki uygulama da aynı worker node üstünde schedule edilecek.
105+
- Her iki uygulama için de cpu ve memory kaynak kısıtları tanımlı olacak.
106+
<details>
107+
<summary>Çözümü görmek için tıklayınız!</summary>
108+
109+
```
110+
$ kubectl create secret generic mysql-test-secret -n test --from-file=MYSQL_ROOT_PASSWORD=./yaml/mysql_root_password.txt --from-file=MYSQL_USER=./yaml/mysql_user.txt --from-file=MYSQL_PASSWORD=./yaml/mysql_password.txt --from-file=MYSQL_DATABASE=./yaml/mysql_database.txt
111+
112+
$ kubectl create secret generic mysql-prod-secret -n production --from-file=MYSQL_ROOT_PASSWORD=./yaml/mysql_root_password.txt --from-file=MYSQL_USER=./yaml/mysql_user.txt --from-file=MYSQL_PASSWORD=./yaml/mysql_password.txt --from-file=MYSQL_DATABASE=./yaml/mysql_database.txt
113+
114+
$ kubectl apply -f ./yaml/wptest.yaml
115+
116+
$ kubectl apply -f ./yaml/wprod.yaml
117+
```
118+
119+
</details>
120+
121+
***
122+
**7:** "test" namespace'inde deploy edilen wordpress uygulaması "testblog.example.com", "production" namespace'inde deploy edilen wordpress uygulaması "companyblog.example.com" olarak ingress üstünden dış dünyaya expose edilecek.
123+
<details>
124+
<summary>Çözümü görmek için tıklayınız!</summary>
125+
126+
```
127+
$ kubectl apply -f ./yaml/wpingress.yaml
128+
```
129+
130+
</details>
131+
132+
***
133+
**8:** "production" namespace'inde "ozgurozturknet/k8s:v1" imajından, 5 replikalı, update stratejisi olarak aynı anda 2 pod'un update edilebileceği bir deployment oluşturun. "/healthcheck" endpoint'ini sorgulayan "liveness probe" ve "/ready" endpoint'ini sorgulayan bir "readiness probe" tanımları da olsun.
134+
<details>
135+
<summary>Çözümü görmek için tıklayınız!</summary>
136+
137+
```
138+
$ kubectl apply -f ./yaml/deployment.yaml
139+
```
140+
141+
</details>
142+
143+
***
144+
**9:** Bir önceki görevde oluşturduğunuz deployment'i "loadbalancer" tipi bir servisle dış dünyadan erişilebilir hale getirin.
145+
<details>
146+
<summary>Çözümü görmek için tıklayınız!</summary>
147+
148+
```
149+
$ kubectl expose deployment k8s-deployment --type=LoadBalancer -n production
150+
```
151+
152+
</details>
153+
154+
***
155+
**10:** Bu deployment'i önce 3 replikaya indirin. Ardından 10 replikaya çıkarın. Sonrasında bu deployment'i "ozgurozturknet/k8s:v2" imajıyla güncelleyin.
156+
<details>
157+
<summary>Çözümü görmek için tıklayınız!</summary>
158+
159+
```
160+
$ kubectl scale deployment k8s-deployment --replicas=3 -n production
161+
162+
$ kubectl scale deployment k8s-deployment --replicas=10 -n production
163+
164+
$ kubectl set image deployment/k8s-deployment k8s=ozgurozturknet/k8s:v2 -n production
165+
```
166+
167+
</details>
168+
169+
***
170+
**11:** "fluentd" uygulamasını bir "daemonset" olarak cluster'da deploy edin.
171+
<details>
172+
<summary>Çözümü görmek için tıklayınız!</summary>
173+
174+
```
175+
$
176+
177+
```
178+
179+
</details>
180+
181+
***
182+
**12:** 2 node'lu bir "mongodb" cluster'i "statefulset" olarak cluster'da deploy edin. "mongodb" cluster'ın çalıştığından emin olun.
183+
<details>
184+
<summary>Çözümü görmek için tıklayınız!</summary>
185+
186+
```
187+
$
188+
189+
```
190+
191+
</details>
192+
193+
***
194+
**13:** Cluster'da tüm objeler üstünde "okuma ve listeleme" haklarına sahip bir "service account" oluşturun. Bu service account’u bağladığınız bir pod oluşturun ve bağlanarak "curl" ile cluster’daki tüm podları listeleyin.
195+
<details>
196+
<summary>Çözümü görmek için tıklayınız!</summary>
197+
198+
```
199+
$
200+
201+
```
202+
203+
</details>
204+
205+
***
206+
**14:** Worker node'lardan bir tanesinin üzerindeki tüm podları tahliye edin ve ardından yeni pod schedule edilememesini sağlayın.
207+
<details>
208+
<summary>Çözümü görmek için tıklayınız!</summary>
209+
210+
```
211+
$
212+
213+
```
214+
215+
</details>
216+
217+
***

proje/cozum/yaml/deployment.yaml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: k8s-deployment
5+
labels:
6+
app: k8s
7+
namespace: production
8+
spec:
9+
replicas: 5
10+
selector:
11+
matchLabels:
12+
app: k8s
13+
strategy:
14+
type: RollingUpdate
15+
rollingUpdate:
16+
maxUnavailable: 0
17+
maxSurge: 2
18+
template:
19+
metadata:
20+
labels:
21+
app: k8s
22+
spec:
23+
containers:
24+
- name: k8s
25+
image: ozgurozturknet/k8s:v1
26+
ports:
27+
- containerPort: 80
28+
livenessProbe:
29+
httpGet:
30+
path: /healthcheck
31+
port: 80
32+
initialDelaySeconds: 5
33+
periodSeconds: 5
34+
readinessProbe:
35+
httpGet:
36+
path: /ready
37+
port: 80
38+
initialDelaySeconds: 20
39+
periodSeconds: 3
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: RoleBinding
3+
metadata:
4+
name: jr-production-rb
5+
namespace: production
6+
subjects:
7+
- kind: Group
8+
name: junior
9+
apiGroup: rbac.authorization.k8s.io
10+
roleRef:
11+
kind: ClusterRole
12+
name: view
13+
apiGroup: rbac.authorization.k8s.io

proje/cozum/yaml/jr-test-rb.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: RoleBinding
3+
metadata:
4+
name: jr-test-rb
5+
namespace: test
6+
subjects:
7+
- kind: Group
8+
name: junior
9+
apiGroup: rbac.authorization.k8s.io
10+
roleRef:
11+
kind: ClusterRole
12+
name: edit
13+
apiGroup: rbac.authorization.k8s.io

proje/cozum/yaml/mysql_database.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
wordpressdb

proje/cozum/yaml/mysql_password.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
P@ssw0rd1!
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
P@ssw0rd1!

proje/cozum/yaml/mysql_user.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mysqlwpadmin

proje/cozum/yaml/sr-cluster-crb.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRoleBinding
3+
metadata:
4+
name: sr-cluster-crb
5+
subjects:
6+
- kind: Group
7+
name: senior
8+
apiGroup: rbac.authorization.k8s.io
9+
roleRef:
10+
kind: ClusterRole
11+
name: view
12+
apiGroup: rbac.authorization.k8s.io
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: RoleBinding
3+
metadata:
4+
name: sr-production-rb
5+
namespace: production
6+
subjects:
7+
- kind: Group
8+
name: senior
9+
apiGroup: rbac.authorization.k8s.io
10+
roleRef:
11+
kind: ClusterRole
12+
name: edit
13+
apiGroup: rbac.authorization.k8s.io

0 commit comments

Comments
 (0)