From e701e1d4959be4857b5fe380c225409919dbc563 Mon Sep 17 00:00:00 2001 From: michalis Date: Fri, 7 Oct 2022 12:31:58 +0300 Subject: [PATCH] k8s draft --- guides/kubernetes.rst | 44 ++++++++++++++++++++++++++++++++ guides/kubernetes/config.rst | 2 ++ guides/kubernetes/cronjob.rst | 3 +++ guides/kubernetes/ingress.rst | 3 +++ guides/kubernetes/monitoring.rst | 3 +++ guides/kubernetes/pods.rst | 3 +++ guides/kubernetes/secrets.rst | 3 +++ guides/kubernetes/services.rst | 3 +++ guides/kubernetes/storage.rst | 3 +++ 9 files changed, 67 insertions(+) create mode 100644 guides/kubernetes.rst create mode 100644 guides/kubernetes/config.rst create mode 100644 guides/kubernetes/cronjob.rst create mode 100644 guides/kubernetes/ingress.rst create mode 100644 guides/kubernetes/monitoring.rst create mode 100644 guides/kubernetes/pods.rst create mode 100644 guides/kubernetes/secrets.rst create mode 100644 guides/kubernetes/services.rst create mode 100644 guides/kubernetes/storage.rst diff --git a/guides/kubernetes.rst b/guides/kubernetes.rst new file mode 100644 index 0000000..ea1a7f3 --- /dev/null +++ b/guides/kubernetes.rst @@ -0,0 +1,44 @@ +Kubernetes +###### + +**Kubernetes** :doc:`https://kubernetes.io/docs/home/`. + +**Image build:** + +- Custom built images based on `nginx:alpine `_ and `php:fpm-alpine `_ (for reverse proxy) + - stage step with `composer` image to git pull or dockerfile COPY app and `composer install` images locally (for both nginx and php dockerfiles) + - on PHP image dockerfile + - `COPY --chown="www-data"` app from `composer` to this image + - install any required php libs etc + - (optional) `COPY` here custom php.ini files inside image, from your host + - on NGINX image dockerfile + - `COPY --chown="nginx"` app from `composer` to this image + - (optional) `COPY` here custom server.conf or *.nginxtemplate files inside image, from your host +- push images to preferred repository + + +I guess the above is app agnostic for php apps. So we have 2 images. 1 for php-fpm and 1 for nginx. +In this stage with an added mysql service to docker-composer.yml we can quickly test locally for compatibilities. +Best practice because the whole app is bundled in image (then just do a cluster apply ____?) + +**The cluster** `should` **have:** + +- an admin pod with 2 containers (phpfpm + nginx) and a cluster ip service which maybe accessed by `admin123.example.com` +- an frontend horizontally auto-scaled pod with 2 containers (phpfpm + nginx) accessed by `example.com` + - admin & frontend pods could have an volumeMount of a configMap containing php .ini and nginx .conf files (even nginx templates) mounted on php and nginx containers respectively + - local.xml as stringData opaque secret mounted on the php containers +- (opt) phpmyadmin container on the admin pod or as separate pod (?) +- database (mysql or mariadb) as separate pod, with persistentVolumeClaim OR remote sql config on local.xml (remote sql adds latencies?) +- (opt) auto-generation of lets-encrypt certs, otherwise storage mounts for custom certs in nginx container +- (opt) redis server pod (probably required instead of having persistentVolume for sharing sessions between pods) +- log collection + monitoring (ex. graylog, elastic?) + private endpoints +- php-fpm pod for cronjobs (? per minute run but monitor if another cronjob already runs) + + +.. toctree:: + :glob: + :maxdepth: 1 + + kubernetes/* + + diff --git a/guides/kubernetes/config.rst b/guides/kubernetes/config.rst new file mode 100644 index 0000000..254b737 --- /dev/null +++ b/guides/kubernetes/config.rst @@ -0,0 +1,2 @@ +Configuration +###### diff --git a/guides/kubernetes/cronjob.rst b/guides/kubernetes/cronjob.rst new file mode 100644 index 0000000..3d720f8 --- /dev/null +++ b/guides/kubernetes/cronjob.rst @@ -0,0 +1,3 @@ +Cronjobs +###### + diff --git a/guides/kubernetes/ingress.rst b/guides/kubernetes/ingress.rst new file mode 100644 index 0000000..1b3d8e7 --- /dev/null +++ b/guides/kubernetes/ingress.rst @@ -0,0 +1,3 @@ +Ingress +###### + diff --git a/guides/kubernetes/monitoring.rst b/guides/kubernetes/monitoring.rst new file mode 100644 index 0000000..a1682b3 --- /dev/null +++ b/guides/kubernetes/monitoring.rst @@ -0,0 +1,3 @@ +Monitoring & Logs +###### + diff --git a/guides/kubernetes/pods.rst b/guides/kubernetes/pods.rst new file mode 100644 index 0000000..7256fee --- /dev/null +++ b/guides/kubernetes/pods.rst @@ -0,0 +1,3 @@ +Pods +###### + diff --git a/guides/kubernetes/secrets.rst b/guides/kubernetes/secrets.rst new file mode 100644 index 0000000..9310560 --- /dev/null +++ b/guides/kubernetes/secrets.rst @@ -0,0 +1,3 @@ +Secrets +###### + diff --git a/guides/kubernetes/services.rst b/guides/kubernetes/services.rst new file mode 100644 index 0000000..4012061 --- /dev/null +++ b/guides/kubernetes/services.rst @@ -0,0 +1,3 @@ +Services +###### + diff --git a/guides/kubernetes/storage.rst b/guides/kubernetes/storage.rst new file mode 100644 index 0000000..cb918f8 --- /dev/null +++ b/guides/kubernetes/storage.rst @@ -0,0 +1,3 @@ +Storage +###### +