-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
unknown
authored and
unknown
committed
May 19, 2024
1 parent
36078d6
commit 059cb66
Showing
9 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: homework-4-conf | ||
namespace: homework | ||
data: | ||
health: "100" | ||
player_initial_lives: "3" | ||
ui_properties_file_name: "user-interface.properties" | ||
power: "3000" | ||
speed: "18" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: nginx-conf | ||
namespace: homework | ||
data: | ||
default.conf: | | ||
server { | ||
listen 8000; | ||
listen [::]:8000; | ||
server_name localhost; | ||
#access_log /var/log/nginx/host.access.log main; | ||
location / { | ||
root /homework; | ||
index index.php; #костыль, чтобы отображалось содержимое директории, даже если в ней есть файл index.html | ||
autoindex on; | ||
autoindex_localtime on; | ||
autoindex_exact_size off; | ||
charset utf-8; | ||
} | ||
location /homepage { #заглушка для /homepage чтоб не было 404 | ||
root /homework; | ||
try_files $uri $uri/ /homepage.html; | ||
} | ||
location ~/conf/ { | ||
autoindex on; | ||
root /homework; | ||
default_type "text/html"; | ||
} | ||
# error_page 404 /404.html; | ||
# redirect server error pages to the static page /50x.html | ||
error_page 500 502 503 504 /50x.html; | ||
location = /50x.html { | ||
root /usr/share/nginx/html; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: nginx | ||
namespace: homework | ||
labels: | ||
app: nginx | ||
spec: | ||
replicas: 3 | ||
selector: | ||
matchLabels: | ||
app: nginx | ||
strategy: | ||
type: RollingUpdate | ||
rollingUpdate: | ||
maxUnavailable: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: nginx | ||
spec: | ||
nodeSelector: | ||
homework: "true" | ||
initContainers: | ||
- name: init-container | ||
image: busybox:1.36.1 | ||
command: ["/bin/sh", "-c", "echo Hello, world! > /init/index.html && echo Hello from homepage > /init/homepage.html"] | ||
volumeMounts: | ||
- name: shared-data | ||
mountPath: /init | ||
containers: | ||
- name: nginx | ||
image: nginx:1.14.2 | ||
ports: | ||
- containerPort: 8000 | ||
readinessProbe: | ||
httpGet: | ||
path: /index.html | ||
port: 8000 | ||
scheme: HTTP | ||
volumeMounts: | ||
- name: shared-data | ||
mountPath: /homework | ||
- name: nginx-conf | ||
mountPath: /etc/nginx/conf.d | ||
- name: homework-4-conf | ||
mountPath: /homework/conf | ||
lifecycle: | ||
preStop: | ||
exec: | ||
command: ["rm", "-f", "/homework/index.html"] | ||
volumes: | ||
- name: nginx-conf | ||
configMap: | ||
name: nginx-conf | ||
- name: homework-4-conf | ||
configMap: | ||
name: homework-4-conf | ||
- name: shared-data | ||
persistentVolumeClaim: | ||
claimName: homework-pvc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: nginx-ingress | ||
namespace: homework | ||
# annotations: | ||
# nginx.ingress.kubernetes.io/rewrite-target: /homepage/ | ||
spec: | ||
ingressClassName: nginx | ||
rules: | ||
- host: homework.otus | ||
http: | ||
paths: | ||
# - path: /index.html | ||
# pathType: ImplementationSpecific | ||
# backend: | ||
# service: | ||
# name: nginx-service | ||
# port: | ||
# number: 80 | ||
- path: / | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: nginx-service | ||
port: | ||
number: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: homework |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: homework-pvc | ||
namespace: homework | ||
spec: | ||
storageClassName: "custom" | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 1Gi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Для проверки нужно: | ||
- включить миникуб minikube start | ||
- включить ингресс-контроллер minikube addons ingress | ||
- включить туннель в миникуб minikube tunnel | ||
- добавить в hosts запись 127.0.0.1 homework.otus | ||
- выполнить kubectl label nodes minikube homework=true (для того точбы запустились поды, см. доп. задания из ДЗ №2) | ||
- перейти в папку с ДЗ №4 cd kubernetes-volumes | ||
- выполнить команды: | ||
kubectl apply -f namespace.yaml - создание неймспейса homework | ||
kubectl apply -f configmap-nginx.yaml - создание конфигурации nginx | ||
kubectl apply -f cm.yaml - создание конфигмапа из задания 4 (с произвольным набором ключей) | ||
kubectl apply -f storageClass.yaml - создание storageClass для выполнения доп.задания | ||
kubectl apply -f pvc.yaml - создание pvc c кастомным storageClass | ||
kubectl apply -f deployment.yaml - развертывание приложения | ||
kubectl apply -f service.yaml - настройка сервиса | ||
kubectl apply -f ingress.yaml - настройка ингресса |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: nginx-service | ||
namespace: homework | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
app: nginx | ||
ports: | ||
- protocol: TCP | ||
port: 80 | ||
targetPort: 8000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: storage.k8s.io/v1 | ||
kind: StorageClass | ||
metadata: | ||
name: custom | ||
namespace: homework | ||
provisioner: k8s.io/minikube-hostpath | ||
reclaimPolicy: Retain | ||
volumeBindingMode: Immediate |