Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

homework 2 #2

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading