Skip to content

Commit

Permalink
homework 2
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed May 8, 2024
1 parent 5263f1d commit 90f9145
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
34 changes: 34 additions & 0 deletions kubernetes-controllers/configmap-nginx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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;
}
# 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;
}
}
56 changes: 56 additions & 0 deletions kubernetes-controllers/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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"]
volumeMounts:
- name: shared-data
mountPath: /init
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 8000
readinessProbe:
exec:
command:
- sh
- -c
- cat /homework/index.html
volumeMounts:
- name: shared-data
mountPath: /homework
- name: nginx-conf
mountPath: /etc/nginx/conf.d
lifecycle:
preStop:
exec:
command: ["rm", "-f", "/homework/index.html"]
volumes:
- name: shared-data
emptyDir: {}
- name: nginx-conf
configMap:
name: nginx-conf
4 changes: 4 additions & 0 deletions kubernetes-controllers/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: homework

0 comments on commit 90f9145

Please sign in to comment.