Skip to content
Open
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
3 changes: 3 additions & 0 deletions Artyom_Serchenya/1/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM nginx
COPY ./files /usr/share/nginx/html
COPY --from=lachlanevenson/k8s-kubectl:v1.10.3 /usr/local/bin/kubectl /usr/local/bin/kubectl
44 changes: 44 additions & 0 deletions Artyom_Serchenya/1/files/nginx-blackout/blackout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<html>
<head>
<title>Добро пожаловать в Интернет без Nginx</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<style>body{background-color:#f7f7f7;margin:0;padding:0;font-family:'Segoe UI',Tahoma,sans-serif}.gr{color:#f7f7f7}#main-frame-error{width:600px;margin:100px auto}.icon{-webkit-user-select:none;display:inline-block;background-repeat:no-repeat;background-size:100%;height:72px;margin:0 0 40px;width:72px;content:-webkit-image-set(url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABIAQMAAABvIyEEAAAABlBMVEUAAABTU1OoaSf/AAAAAXRSTlMAQObYZgAAAENJREFUeF7tzbEJACEQRNGBLeAasBCza2lLEGx0CxFGG9hBMDDxRy/72O9FMnIFapGylsu1fgoBdkXfUHLrQgdfrlJN1BdYBjQQm3UAAAAASUVORK5CYII=) 1x,url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJAAAACQAQMAAADdiHD7AAAABlBMVEUAAABTU1OoaSf/AAAAAXRSTlMAQObYZgAAAFJJREFUeF7t0cENgDAMQ9FwYgxG6WjpaIzCCAxQxVggFuDiCvlLOeRdHR9yzjncHVoq3npu+wQUrUuJHylSTmBaespJyJQoObUeyxDQb3bEm5Au81c0pSCD8HYAAAAASUVORK5CYII=) 2x)}h1{color:#333;font-size:1.6em;font-weight:normal;line-height:1.25em;margin-bottom:16px}.error-code{color:#696969;display:inline-block;font-size:13px;margin-bottom:15px;opacity:.5;text-transform:uppercase}#main-message{margin-bottom:50px}#details-button{background:inherit;border:0;float:none;margin:0;padding:10px 0;text-decoration:underline;cursor:pointer;color:#696969;font-size:.875em;float:right}#details{color:#696969;margin:45px 0 50px}.hidden{display:none}#adr{font-weight:bold}#reload-button{-webkit-user-select:none;background:#4c8efa;border:0;border-radius:2px;box-sizing:border-box;color:#fff;cursor:pointer;float:left;font-size:.875em;margin:0;padding:10px 24px;transition:box-shadow 200ms cubic-bezier(0.4,0,0.2,1)}</style>
<style>
#main-frame-error {
max-width: 600px;
margin: 100px auto;
padding: 15px;
}
@media (max-width: 640px) {
.icon {
margin-bottom: 10px;
}
h1 {
font-size: 1.2em;
}
#main-message {
margin-bottom: 20px;
}
}
</style>
</head>
<header>
Powered by nginx!
</header>
<body>
<div id="main-frame-error">
<div class="icon"></div>
<div id="main-message">
<h1>Добро пожаловать в Интернет без Nginx</h1>
<div class="error-code">IGOR_SYSOEV_ILLEGAL_SEARCH_AND_SEIZURE</div>
<div style="color: #696969;">Разработчик Nginx Игорь Сысоев был задержан по уголовному делу, сфабрикованному на основе безосновательной претензии Рамблера, пытающегося осуществить рейдерский захват Nginx. Без Nginx большинство сайтов в Интернете не смогут существовать, в том числе и этот.</div><br>
<div id="buttons">
<a href="https://habr.com/ru/post/480204/"><button id="reload-button">Подробнее</button></a>
</div>
<br/>
<br/>
<!-- https://github.com/podivilov/nginx-blackout/pull/6 -->
<!-- Yandex.Metrika counter --> <script type="text/javascript" > (function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)}; m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)}) (window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym"); ym(56668441, "init", { clickmap:true, trackLinks:true, accurateTrackBounce:true, webvisor:true }); </script> <noscript><div><img src="https://mc.yandex.ru/watch/56668441" style="position:absolute; left:-9999px;" alt="" /></div></noscript> <!-- /Yandex.Metrika counter -->
</body>
</html>
78 changes: 78 additions & 0 deletions Artyom_Serchenya/1/nginx-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: "nginx-configmap"
data:
nginx.conf: |
server {
listen 80;
location /nginx-blackout {
root /usr/share/nginx/html;
index blackout.html;
}

location / {
if ($time_iso8601 ~ ^2020-01-08T12:[1-5][0-9]:[0-9][0-9]) {
return 302 /nginx-blackout;
}
root /usr/share/nginx/html;
index index.html;
}
}

---

apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 1
selector:
matchLabels:
app: webserver
template:
metadata:
labels:
app: webserver
spec:
containers:
- name: nginx
image: ancientmystery/nginx-blackout
volumeMounts:
- name: nginx-config
mountPath: /etc/nginx/conf.d/
volumes:
- name: nginx-config
configMap:
name: nginx-configmap

---

apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
type: NodePort
selector:
app: webserver
ports:
- port: 80
nodePort: 30057

---

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: nginx-ingress
spec:
rules:
- host: local
http:
paths:
- path: /
backend:
serviceName: nginx-service
servicePort: 80
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,43 @@ The mentor should be able to simply use your files, run `vagrant up`, and have y
> - It should additionally show the percentage of memcached memory used (From the API. Not the percentage of the OS memory.)
> - Don't worry about the look and style of the page. Just make it functional.
> - There is a basic python Flask app in /var/www/app you can use as a starting template


# HomeWork #1

## Setup

Download and install [minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/) or setup kubernetes using [Docker Desktop](https://www.docker.com/products/docker-desktop).

## Summary
Probably all you heard about Nginx and Rambler story. Today you will try to implement stub page in support of Igor Sysoev

## Instructions

0. Get home task related files from folder `_hw#1`.
1. Learn the basics of how to use Minikube, configure and deploy kubernetes service with Nginx.
2. Install Nginx as [ingress controller](https://github.com/kubernetes/ingress-nginx). Nginx should be avialible on http://localhost:8080/
3. Configure Nginx to made it show stub page instead of default web page on custom date.
- Add to header "Powered by nginx"
- Add the HTML-file nginx-blackout folder somewhere to the server (e.g. /var/www/nginx-blackout/index.html)
Edit your root location in the nginx config to be like this:
```
location /nginx-blackout {
root /var/www;
break;
}

location / {
if ($time_iso8601 ~ ^2019-12-31T09:[0-2][0-9]:[0-9][0-9] ) {
return 302 /nginx-blackout;
}
# ... usual location config
}
```

4. Check that it works with the current date.
5. Prepare PR with your setup.

The mentor should be able to simply use your files, run `kubectl create -f yourfile.yaml`, and have your completed and fixed environment running for review.

### Optional task: made same config by using custom image for nginx
41 changes: 41 additions & 0 deletions _hw#1/files/nginx-blackout/blackout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<html>
<head>
<title>Добро пожаловать в Интернет без Nginx</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<style>body{background-color:#f7f7f7;margin:0;padding:0;font-family:'Segoe UI',Tahoma,sans-serif}.gr{color:#f7f7f7}#main-frame-error{width:600px;margin:100px auto}.icon{-webkit-user-select:none;display:inline-block;background-repeat:no-repeat;background-size:100%;height:72px;margin:0 0 40px;width:72px;content:-webkit-image-set(url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABIAQMAAABvIyEEAAAABlBMVEUAAABTU1OoaSf/AAAAAXRSTlMAQObYZgAAAENJREFUeF7tzbEJACEQRNGBLeAasBCza2lLEGx0CxFGG9hBMDDxRy/72O9FMnIFapGylsu1fgoBdkXfUHLrQgdfrlJN1BdYBjQQm3UAAAAASUVORK5CYII=) 1x,url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJAAAACQAQMAAADdiHD7AAAABlBMVEUAAABTU1OoaSf/AAAAAXRSTlMAQObYZgAAAFJJREFUeF7t0cENgDAMQ9FwYgxG6WjpaIzCCAxQxVggFuDiCvlLOeRdHR9yzjncHVoq3npu+wQUrUuJHylSTmBaespJyJQoObUeyxDQb3bEm5Au81c0pSCD8HYAAAAASUVORK5CYII=) 2x)}h1{color:#333;font-size:1.6em;font-weight:normal;line-height:1.25em;margin-bottom:16px}.error-code{color:#696969;display:inline-block;font-size:13px;margin-bottom:15px;opacity:.5;text-transform:uppercase}#main-message{margin-bottom:50px}#details-button{background:inherit;border:0;float:none;margin:0;padding:10px 0;text-decoration:underline;cursor:pointer;color:#696969;font-size:.875em;float:right}#details{color:#696969;margin:45px 0 50px}.hidden{display:none}#adr{font-weight:bold}#reload-button{-webkit-user-select:none;background:#4c8efa;border:0;border-radius:2px;box-sizing:border-box;color:#fff;cursor:pointer;float:left;font-size:.875em;margin:0;padding:10px 24px;transition:box-shadow 200ms cubic-bezier(0.4,0,0.2,1)}</style>
<style>
#main-frame-error {
max-width: 600px;
margin: 100px auto;
padding: 15px;
}
@media (max-width: 640px) {
.icon {
margin-bottom: 10px;
}
h1 {
font-size: 1.2em;
}
#main-message {
margin-bottom: 20px;
}
}
</style>
</head>
<body>
<div id="main-frame-error">
<div class="icon"></div>
<div id="main-message">
<h1>Добро пожаловать в Интернет без Nginx</h1>
<div class="error-code">IGOR_SYSOEV_ILLEGAL_SEARCH_AND_SEIZURE</div>
<div style="color: #696969;">Разработчик Nginx Игорь Сысоев был задержан по уголовному делу, сфабрикованному на основе безосновательной претензии Рамблера, пытающегося осуществить рейдерский захват Nginx. Без Nginx большинство сайтов в Интернете не смогут существовать, в том числе и этот.</div><br>
<div id="buttons">
<a href="https://habr.com/ru/post/480204/"><button id="reload-button">Подробнее</button></a>
</div>
<br/>
<br/>
<!-- https://github.com/podivilov/nginx-blackout/pull/6 -->
<!-- Yandex.Metrika counter --> <script type="text/javascript" > (function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)}; m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)}) (window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym"); ym(56668441, "init", { clickmap:true, trackLinks:true, accurateTrackBounce:true, webvisor:true }); </script> <noscript><div><img src="https://mc.yandex.ru/watch/56668441" style="position:absolute; left:-9999px;" alt="" /></div></noscript> <!-- /Yandex.Metrika counter -->
</body>
</html>