Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
linux_faq:deploy_dokuwiki_in_kubernetes [2020/01/30 11:09] – [Создаем объекты в kubernetes] admin | linux_faq:deploy_dokuwiki_in_kubernetes [2020/01/30 11:17] (current) – admin | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | Todo: | ||
+ | - change sendmail path in php.ini | ||
+ | ====== Dockerfile ====== | ||
+ | ===== Вариант с postfix ===== | ||
+ | Недостаток - жирный сервис постфикса нужно запускать в контейнере. | ||
+ | < | ||
+ | FROM php:fpm | ||
+ | RUN echo " | ||
+ | && echo " | ||
+ | && DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y \ | ||
+ | postfix \ | ||
+ | libfreetype6-dev \ | ||
+ | libjpeg62-turbo-dev \ | ||
+ | libpng-dev \ | ||
+ | libicu-dev \ | ||
+ | libldap2-dev \ | ||
+ | libxml2-dev \ | ||
+ | libxslt1-dev \ | ||
+ | libwebp-dev \ | ||
+ | libxpm-dev \ | ||
+ | && | ||
+ | --with-png-dir --with-zlib-dir --with-xpm-dir --with-freetype-dir \ | ||
+ | && | ||
+ | calendar gettext intl ldap shmop sockets sysvmsg \ | ||
+ | sysvsem sysvshm tokenizer xml xmlreader xmlwriter xsl \ | ||
+ | && | ||
+ | && | ||
+ | && | ||
+ | && | ||
+ | && | ||
+ | && | ||
+ | && | ||
+ | && | ||
+ | && | ||
+ | && | ||
+ | && | ||
+ | && | ||
+ | && | ||
+ | && | ||
+ | && | ||
+ | && | ||
+ | && | ||
+ | </ | ||
+ | ===== Вариант с nullmailer ===== | ||
+ | http:// | ||
+ | < | ||
+ | FROM php:fpm | ||
+ | RUN echo " | ||
+ | && echo " | ||
+ | && echo " | ||
+ | && echo " | ||
+ | && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ | ||
+ | nullmailer \ | ||
+ | libfreetype6-dev \ | ||
+ | libjpeg62-turbo-dev \ | ||
+ | libpng-dev \ | ||
+ | libicu-dev \ | ||
+ | libldap2-dev \ | ||
+ | libxml2-dev \ | ||
+ | libxslt1-dev \ | ||
+ | libwebp-dev \ | ||
+ | libxpm-dev \ | ||
+ | && | ||
+ | --with-png-dir --with-zlib-dir --with-xpm-dir --with-freetype-dir \ | ||
+ | && | ||
+ | calendar gettext intl ldap shmop sockets sysvmsg \ | ||
+ | sysvsem sysvshm tokenizer xml xmlreader xmlwriter xsl \ | ||
+ | && | ||
+ | && | ||
+ | && | ||
+ | && | ||
+ | && | ||
+ | && | ||
+ | && | ||
+ | </ | ||
+ | ===== Собираем и пушим образ ===== | ||
+ | docker build -t registry.autosys.tk/ | ||
+ | docker login -u _reg_user_ -p __superpassword__ registry.domain.com | ||
+ | #docker tag dokuwiki-php registry.autosys.tk/ | ||
+ | docker push registry.autosys.tk/ | ||
+ | ====== Создаем объекты в kubernetes ====== | ||
+ | < | ||
+ | apiVersion: v1 | ||
+ | metadata: | ||
+ | name: wiki | ||
+ | labels: | ||
+ | name: wiki | ||
+ | --- | ||
+ | apiVersion: v1 | ||
+ | data: | ||
+ | .dockerconfigjson: | ||
+ | kind: Secret | ||
+ | metadata: | ||
+ | name: autosys-regcred | ||
+ | namespace: wiki | ||
+ | type: kubernetes.io/ | ||
+ | --- | ||
+ | apiVersion: apps/v1 | ||
+ | kind: Deployment | ||
+ | metadata: | ||
+ | name: wiki | ||
+ | namespace: wiki | ||
+ | spec: | ||
+ | replicas: 1 | ||
+ | selector: | ||
+ | matchLabels: | ||
+ | app: wiki | ||
+ | template: | ||
+ | metadata: | ||
+ | labels: | ||
+ | app: wiki | ||
+ | spec: | ||
+ | imagePullSecrets: | ||
+ | - name: autosys-regcred | ||
+ | containers: | ||
+ | - name: wiki-php-fpm | ||
+ | image: registry.autosys.tk/ | ||
+ | volumeMounts: | ||
+ | - name: doku-wiki-files | ||
+ | mountPath: /var/www | ||
+ | - name: wiki-nginx | ||
+ | image: nginx | ||
+ | volumeMounts: | ||
+ | - name: doku-wiki-files | ||
+ | mountPath: /var/www | ||
+ | - name: nginx-config-volume | ||
+ | mountPath: / | ||
+ | subPath: nginx.conf | ||
+ | volumes: | ||
+ | - name: doku-wiki-files | ||
+ | persistentVolumeClaim: | ||
+ | claimName: doku-wiki-files-pv-claim | ||
+ | - name: nginx-config-volume | ||
+ | configMap: | ||
+ | name: nginx-config | ||
+ | | ||
+ | --- | ||
+ | apiVersion: v1 | ||
+ | kind: PersistentVolumeClaim | ||
+ | metadata: | ||
+ | name: doku-wiki-files-pv-claim | ||
+ | namespace: wiki | ||
+ | spec: | ||
+ | accessModes: | ||
+ | - ReadWriteOnce | ||
+ | resources: | ||
+ | requests: | ||
+ | storage: 20Gi | ||
+ | selector: | ||
+ | matchLabels: | ||
+ | app: wiki | ||
+ | --- | ||
+ | apiVersion: v1 | ||
+ | kind: PersistentVolume | ||
+ | metadata: | ||
+ | name: doku-wiki-data-pv | ||
+ | | ||
+ | | ||
+ | app: wiki | ||
+ | spec: | ||
+ | capacity: | ||
+ | storage: 20Gi | ||
+ | accessModes: | ||
+ | - ReadWriteOnce | ||
+ | hostPath: | ||
+ | path: "/ | ||
+ | type: Directory | ||
+ | persistentVolumeReclaimPolicy: | ||
+ | claimRef: {} | ||
+ | --- | ||
+ | kind: ConfigMap | ||
+ | apiVersion: v1 | ||
+ | metadata: | ||
+ | name: nginx-config | ||
+ | namespace: wiki | ||
+ | data: | ||
+ | nginx.conf: | | ||
+ | user www-data; | ||
+ | worker_processes 4; | ||
+ | worker_rlimit_nofile 100000; | ||
+ | | ||
+ | events { | ||
+ | worker_connections 4000; | ||
+ | multi_accept on; | ||
+ | use epoll; | ||
+ | } | ||
+ | http { | ||
+ | ## | ||
+ | # Basic Settings | ||
+ | ## | ||
+ | sendfile on; | ||
+ | tcp_nopush on; | ||
+ | tcp_nodelay on; | ||
+ | types_hash_max_size 2048; | ||
+ | server_tokens off; | ||
+ | |||
+ | ## | ||
+ | # Cache | ||
+ | ## | ||
+ | open_file_cache max=200000 inactive=20s; | ||
+ | open_file_cache_valid 30s; | ||
+ | open_file_cache_min_uses 2; | ||
+ | open_file_cache_errors on; | ||
+ | |||
+ | include / | ||
+ | default_type application/ | ||
+ | | ||
+ | ## | ||
+ | # Gzip Settings | ||
+ | ## | ||
+ | # reduce the data that needs to be sent over network -- for testing environment | ||
+ | gzip on; | ||
+ | # gzip_static on; | ||
+ | gzip_min_length 10240; | ||
+ | gzip_comp_level 9; | ||
+ | gzip_vary on; | ||
+ | gzip_disable msie6; | ||
+ | gzip_proxied expired no-cache no-store private auth; | ||
+ | gzip_types | ||
+ | text/html | ||
+ | text/css | ||
+ | text/ | ||
+ | text/xml | ||
+ | text/plain | ||
+ | text/ | ||
+ | application/ | ||
+ | application/ | ||
+ | application/ | ||
+ | application/ | ||
+ | application/ | ||
+ | application/ | ||
+ | font/ | ||
+ | font/ | ||
+ | application/ | ||
+ | image/ | ||
+ | |||
+ | ## | ||
+ | # Misc options | ||
+ | ## | ||
+ | |||
+ | # allow the server to close connection on non responding client, this will free up memory | ||
+ | reset_timedout_connection on; | ||
+ | |||
+ | # request timed out -- default 60 | ||
+ | client_body_timeout 10; | ||
+ | |||
+ | # if client stop responding, free up memory -- default 60 | ||
+ | send_timeout 2; | ||
+ | |||
+ | # server will close connection after this time -- default 75 | ||
+ | keepalive_timeout 30; | ||
+ | |||
+ | # number of requests client can make over keep-alive -- for testing environment | ||
+ | keepalive_requests 100000; | ||
+ | |||
+ | server { | ||
+ | listen 80 default_server; | ||
+ | listen [::]:80 default_server; | ||
+ | |||
+ | root /var/www; | ||
+ | # | ||
+ | autoindex off; | ||
+ | client_max_body_size 15M; | ||
+ | client_body_buffer_size 128k; | ||
+ | index doku.php; | ||
+ | | ||
+ | location ~ / | ||
+ | deny all; | ||
+ | } | ||
+ | | ||
+ | location / { | ||
+ | try_files $uri $uri/ @dokuwiki; | ||
+ | } | ||
+ | |||
+ | location ~ ^/ | ||
+ | expires 30d; | ||
+ | } | ||
+ | |||
+ | location = / | ||
+ | location = / | ||
+ | location ~ /\. { access_log off; log_not_found off; deny all; } | ||
+ | location ~ ~$ { access_log off; log_not_found off; deny all; } | ||
+ | |||
+ | location @dokuwiki { | ||
+ | rewrite ^/ | ||
+ | rewrite ^/ | ||
+ | rewrite ^/ | ||
+ | rewrite ^/ | ||
+ | rewrite ^/(.*) / | ||
+ | } | ||
+ | |||
+ | location ~ \.php$ { | ||
+ | include / | ||
+ | fastcgi_param | ||
+ | try_files $uri =404; | ||
+ | fastcgi_pass 127.0.0.1: | ||
+ | fastcgi_intercept_errors | ||
+ | fastcgi_ignore_client_abort | ||
+ | fastcgi_connect_timeout 60; | ||
+ | fastcgi_send_timeout 180; | ||
+ | fastcgi_read_timeout 180; | ||
+ | fastcgi_buffer_size 128k; | ||
+ | fastcgi_buffers 4 256k; | ||
+ | fastcgi_busy_buffers_size 256k; | ||
+ | fastcgi_temp_file_write_size 256k; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | --- | ||
+ | apiVersion: v1 | ||
+ | kind: Service | ||
+ | metadata: | ||
+ | name: wiki-http | ||
+ | namespace: wiki | ||
+ | spec: | ||
+ | selector: | ||
+ | app: wiki | ||
+ | type: ClusterIP | ||
+ | ports: | ||
+ | - name: http | ||
+ | port: 80 | ||
+ | protocol: TCP | ||
+ | targetPort: 80 | ||
+ | --- | ||
+ | apiVersion: extensions/ | ||
+ | kind: Ingress | ||
+ | metadata: | ||
+ | annotations: | ||
+ | kubernetes.io/ | ||
+ | cert-manager.io/ | ||
+ | nginx.ingress.kubernetes.io/ | ||
+ | nginx.ingress.kubernetes.io/ | ||
+ | nginx.ingress.kubernetes.io/ | ||
+ | name: wiki-ingress | ||
+ | namespace: wiki | ||
+ | spec: | ||
+ | rules: | ||
+ | - host: wiki.autosys.tk | ||
+ | http: | ||
+ | paths: | ||
+ | - backend: | ||
+ | serviceName: | ||
+ | servicePort: | ||
+ | path: / | ||
+ | tls: | ||
+ | - hosts: | ||
+ | - wiki.autosys.tk | ||
+ | secretName: | ||
+ | </ |