Skip to content

Commit

Permalink
kubernetes-3
Browse files Browse the repository at this point in the history
  • Loading branch information
Baykanurov committed Nov 26, 2023
1 parent 2f3bf60 commit 3bf8509
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 4 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,3 +448,31 @@ kubectl apply -f ./kubernetes/reddit/ -n dev
![img.png](docs/img.png)
![img1.png](docs/img1.png)
P.S. Удалил инстанс кластера т.к. домашние задания проверяются долго, а потребление кластера на YC очень дорогое.
## Kubernetes-3
### Что было сделано:
1. Разобрался и подключил сущности Kubernetes:
- Ingress Controller
- Ingress
- Secret
- TLS
- LoadBalancer Service
- Network Policies
- PersistentVolumes
- PersistentVolumeClaims
2. Установил ingress nginx
```shell
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.8.2/deploy/static/provider/cloud/deploy.yaml
```
3. Защитил сервис с помощью TLS
```shell
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout tls.key -out tls.crt -subj "/CN=158.160.124.211"
kubectl create secret tls ui-ingress --key tls.key --cert tls.crt -n dev
```
4. Создал диск в ya.cloud
```shell
yc compute disk create \
--name k8s \
--size 4 \
--description "disk for k8s"
```
14 changes: 14 additions & 0 deletions kubernetes/reddit/mongo-claim-dynamic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mongo-pvc-dynamic
labels:
app: reddit
component: pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
12 changes: 12 additions & 0 deletions kubernetes/reddit/mongo-claim.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mongo-pvc
spec:
storageClassName: ""
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 4Gi
volumeName: mongo-pv
3 changes: 2 additions & 1 deletion kubernetes/reddit/mongo-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ spec:
mountPath: /data/db
volumes:
- name: mongo-persistent-storage
emptyDir: {}
persistentVolumeClaim:
claimName: mongo-pvc
24 changes: 24 additions & 0 deletions kubernetes/reddit/mongo-network-policy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-db-traffic
labels:
app: reddit
spec:
podSelector:
matchLabels:
app: reddit
component: mongo
policyTypes:
- Ingress
ingress:
- from:
- podSelector:
matchLabels:
app: reddit
component: comment
- podSelector:
matchLabels:
app: reddit
component: post
13 changes: 13 additions & 0 deletions kubernetes/reddit/mongo-volume.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: mongo-pv
spec:
capacity:
storage: 4Gi
accessModes:
- ReadWriteOnce
csi:
driver: disk-csi-driver.mks.ycloud.io
fsType: ext4
volumeHandle: fhm2akn991odm4jric8j
22 changes: 22 additions & 0 deletions kubernetes/reddit/ui-ingress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ui
spec:
ingressClassName: nginx
rules:
- host: ui.reddit.baykanurov.ru
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: ui
port:
number: 80
tls:
- hosts:
- ui.reddit.baykanurov.ru
secretName: ui-ingress
5 changes: 2 additions & 3 deletions kubernetes/reddit/ui-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ metadata:
spec:
type: NodePort
ports:
- nodePort: 32092
port: 80
- port: 9292
protocol: TCP
targetPort: 9292
selector:
app: reddit
component: ui
component: ui

0 comments on commit 3bf8509

Please sign in to comment.