+
+ +
+
+ + + + diff --git a/Artyom_Serchenya/1/nginx-deployment.yaml b/Artyom_Serchenya/1/nginx-deployment.yaml new file mode 100644 index 0000000..a4c6170 --- /dev/null +++ b/Artyom_Serchenya/1/nginx-deployment.yaml @@ -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 \ No newline at end of file diff --git a/README.md b/README.md index b9de75b..19bb469 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/_hw#1/files/nginx-blackout/blackout.html b/_hw#1/files/nginx-blackout/blackout.html new file mode 100644 index 0000000..3f3b8c2 --- /dev/null +++ b/_hw#1/files/nginx-blackout/blackout.html @@ -0,0 +1,41 @@ + + +Добро пожаловать в Интернет без Nginx
+
+
+
+
+
+
+
Добро пожаловать в Интернет без Nginx
+IGOR_SYSOEV_ILLEGAL_SEARCH_AND_SEIZURE
+Разработчик Nginx Игорь Сысоев был задержан по уголовному делу, сфабрикованному на основе безосновательной претензии Рамблера, пытающегося осуществить рейдерский захват Nginx. Без Nginx большинство сайтов в Интернете не смогут существовать, в том числе и этот.
+ +
+
+ + + + diff --git a/Artyom_Serchenya/1/nginx-deployment.yaml b/Artyom_Serchenya/1/nginx-deployment.yaml new file mode 100644 index 0000000..a4c6170 --- /dev/null +++ b/Artyom_Serchenya/1/nginx-deployment.yaml @@ -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 \ No newline at end of file diff --git a/README.md b/README.md index b9de75b..19bb469 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/_hw#1/files/nginx-blackout/blackout.html b/_hw#1/files/nginx-blackout/blackout.html new file mode 100644 index 0000000..3f3b8c2 --- /dev/null +++ b/_hw#1/files/nginx-blackout/blackout.html @@ -0,0 +1,41 @@ + + +
+
+
+
+ +
+
+ + + +
Добро пожаловать в Интернет без Nginx
+IGOR_SYSOEV_ILLEGAL_SEARCH_AND_SEIZURE
+Разработчик Nginx Игорь Сысоев был задержан по уголовному делу, сфабрикованному на основе безосновательной претензии Рамблера, пытающегося осуществить рейдерский захват Nginx. Без Nginx большинство сайтов в Интернете не смогут существовать, в том числе и этот.
+ +
+
+ + + +