From 43fd54cd9bc4e8cd1a8c778fb175998f7e9f90f3 Mon Sep 17 00:00:00 2001 From: Danyliuk Date: Sat, 29 Oct 2022 22:46:44 +0300 Subject: [PATCH] init commit --- .gitignore | 109 +++++++++++++++++++++++++ antora.yml | 10 +++ k8s/backend-matomo.yaml | 11 +++ k8s/backend-mysql.yaml | 11 +++ k8s/deployment-matomo.yaml | 19 +++++ k8s/deployment-mysql.yaml | 38 +++++++++ k8s/ingress-matomo.yaml | 25 ++++++ k8s/ingress-mysql.yaml | 25 ++++++ k8s/kustomization.yaml | 4 + k8s/persistant-volume-claim-mysql.yaml | 12 +++ modules/ROOT/nav.adoc | 1 + modules/ROOT/pages/general.adoc | 92 +++++++++++++++++++++ 12 files changed, 357 insertions(+) create mode 100644 .gitignore create mode 100644 antora.yml create mode 100644 k8s/backend-matomo.yaml create mode 100644 k8s/backend-mysql.yaml create mode 100644 k8s/deployment-matomo.yaml create mode 100644 k8s/deployment-mysql.yaml create mode 100644 k8s/ingress-matomo.yaml create mode 100644 k8s/ingress-mysql.yaml create mode 100644 k8s/kustomization.yaml create mode 100644 k8s/persistant-volume-claim-mysql.yaml create mode 100644 modules/ROOT/nav.adoc create mode 100644 modules/ROOT/pages/general.adoc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d4f751b --- /dev/null +++ b/.gitignore @@ -0,0 +1,109 @@ +php_errors.log +*.tmp +*.pyc +.DS_Store +/.idea/ +/bootstrap.php +/build +/composer.phar +/config/config* +/config/*.pem +/crossdomain.xml +/documentation +/docs/ +/favicon.ico +/js/yui* +/misc/*.dat +/misc/*.dat.gz +/misc/*.tar.gz +/misc/*.mmdb +/misc/user/logo-header.png +/misc/user/logo.png +/misc/user/logo.svg +/misc/user/favicon.png +/piwik-min.js +/plugins/*.zip +/plugins/ImageGraph/fonts/unifont.ttf +/plugins/ImageGraph/fonts/unifont.ttf.zip +/plugins/*/tests/System/processed +/plugins/*/Test/System/processed +/plugins/*/tests/UI/processed-ui-screenshots +/plugins/*/Test/UI/processed-ui-screenshots +/plugins/*/tests/UI/screenshot-diffs +/plugins/*/Test/UI/screenshot-diffs +/robots.txt +/tmp/* +!/tmp/.gitkeep +!/tmp/CACHEDIR.TAG +/vendor/ +/.cache +/.externalToolBuilders +/.idea/* +/.metadata +/.project +/.settings +/*.buildpath +/tests/javascript/unittest.dbf +/tests/javascript/unittest2.dbf +/tests/lib/geoip-files/*.dat* +/tests/lib/xhprof* +/tests/PHPUnit/System/processed/ +/tests/PHPUnit/phpunit.xml +/tests/results/ +/.htaccess +/config/.htaccess +/core/.htaccess +/js/.htaccess +/lang/.htaccess +/libs/.htaccess +/misc/.htaccess +/misc/user/.htaccess +/misc/cron/.htaccess +/plugins/.htaccess +/tests/resources/overlay-test-site-real/ +/tests/PHPUnit/.phpunit.result.cache +/tests/PHPUnit/proxy/libs +/tests/PHPUnit/proxy/piwik.js +/tests/PHPUnit/proxy/matomo.js +/tests/PHPUnit/proxy/plugins +/tests/PHPUnit/proxy/tests +/tests/PHPUnit/proxy/misc +/tests/resources/piwik.test.js +/tests/resources/matomo.test.js +/config/*.config.ini.php +/Vagrantfile +/misc/vagrant +/.vagrant +/plugins/.gitignore +/js/container*.js +/.docker +docker-compose.yml +/node_modules/* +!/node_modules/angular +!/node_modules/angular-animate +!/node_modules/angular-cookies +!/node_modules/angular-mocks +!/node_modules/angular-sanitize +!/node_modules/chroma-js +!/node_modules/iframe-resizer +!/node_modules/jquery +!/node_modules/jquery-mousewheel +!/node_modules/jquery-ui-dist +!/node_modules/jquery.browser +!/node_modules/jquery.dotdotdot +!/node_modules/jquery.scrollto +!/node_modules/materialize-css +!/node_modules/mousetrap +!/node_modules/ng-dialog +!/node_modules/qrcodejs2 +!/node_modules/sprintf-js +!/node_modules/visibilityjs +/node_modules/vue/* +!/node_modules/vue +!/node_modules/vue/dist +/plugins/*/vue/dist/demo.html +/plugins/*/vue/dist/*.common.js +/plugins/*/vue/dist/*.map +/plugins/*/vue/dist/*.development.* +/plugins/CoreVue/polyfills/dist/MatomoPolyfills.min.js.map +/@types diff --git a/antora.yml b/antora.yml new file mode 100644 index 0000000..5eb9ab9 --- /dev/null +++ b/antora.yml @@ -0,0 +1,10 @@ +name: matomo-documentation +title: Matomo documentation +version: 1.0.1 +start_page: general.adoc +asciidoc: + attributes: + source-language: asciidoc@ + table-caption: false +nav: +- modules/ROOT/nav.adoc diff --git a/k8s/backend-matomo.yaml b/k8s/backend-matomo.yaml new file mode 100644 index 0000000..ed8f51b --- /dev/null +++ b/k8s/backend-matomo.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: matomo-playground +spec: + type: ClusterIP + selector: + app: matomo-playground + ports: + - protocol: TCP + port: 8081 diff --git a/k8s/backend-mysql.yaml b/k8s/backend-mysql.yaml new file mode 100644 index 0000000..32b297a --- /dev/null +++ b/k8s/backend-mysql.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: mysql-playground +spec: + type: ClusterIP + selector: + app: matomo-playground + ports: + - protocol: TCP + port: 3306 diff --git a/k8s/deployment-matomo.yaml b/k8s/deployment-matomo.yaml new file mode 100644 index 0000000..7a26a83 --- /dev/null +++ b/k8s/deployment-matomo.yaml @@ -0,0 +1,19 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: matomo-playground +spec: + replicas: 1 + selector: + matchLabels: + app: matomo + template: + metadata: + labels: + app: matomo + spec: + containers: + - name: matomo + image: matomo:4.12.0-apache + ports: + - containerPort: 8081 diff --git a/k8s/deployment-mysql.yaml b/k8s/deployment-mysql.yaml new file mode 100644 index 0000000..448e0ee --- /dev/null +++ b/k8s/deployment-mysql.yaml @@ -0,0 +1,38 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mysql-playground + labels: + app: matomo-playground +spec: + selector: + matchLabels: + app: matomo-playground + tier: mysql-playground + strategy: + type: Recreate + template: + metadata: + labels: + app: matomo-playground + tier: mysql-playground + spec: + containers: + - image: mysql:8.0.31 + name: mysql + env: + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: mysql-pass + key: password + ports: + - containerPort: 3306 + name: mysql + volumeMounts: + - name: mysql-persistent-storage + mountPath: /var/lib/mysql + volumes: + - name: mysql-persistent-storage + persistentVolumeClaim: + claimName: oleksii-mysql-pv-claim diff --git a/k8s/ingress-matomo.yaml b/k8s/ingress-matomo.yaml new file mode 100644 index 0000000..cf39f55 --- /dev/null +++ b/k8s/ingress-matomo.yaml @@ -0,0 +1,25 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: oleksii-matomo + annotations: + kubernetes.io/ingress.class: traefik + traefik.ingress.kubernetes.io/router.entrypoints: websecure + traefik.ingress.kubernetes.io/router.middlewares: traefik-sso@kubernetescrd + traefik.ingress.kubernetes.io/router.tls: "true" + external-dns.alpha.kubernetes.io/target: traefik.k-space.ee +spec: + rules: + - host: oleksii-matomo.k-space.ee + http: + paths: + - pathType: Prefix + path: "/" + backend: + service: + name: matomo-playground + port: + number: 8081 + tls: + - hosts: + - "*.k-space.ee" diff --git a/k8s/ingress-mysql.yaml b/k8s/ingress-mysql.yaml new file mode 100644 index 0000000..0aef68a --- /dev/null +++ b/k8s/ingress-mysql.yaml @@ -0,0 +1,25 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: oleksii-mysql + annotations: + kubernetes.io/ingress.class: traefik + traefik.ingress.kubernetes.io/router.entrypoints: websecure + traefik.ingress.kubernetes.io/router.middlewares: traefik-sso@kubernetescrd + traefik.ingress.kubernetes.io/router.tls: "true" + external-dns.alpha.kubernetes.io/target: traefik.k-space.ee +spec: + rules: + - host: oleksii-mysql.k-space.ee + http: + paths: + - pathType: Prefix + path: "/" + backend: + service: + name: matomo-playground + port: + number: 3306 + tls: + - hosts: + - "*.k-space.ee" diff --git a/k8s/kustomization.yaml b/k8s/kustomization.yaml new file mode 100644 index 0000000..ad393f3 --- /dev/null +++ b/k8s/kustomization.yaml @@ -0,0 +1,4 @@ +secretGenerator: +- name: mysql-pass + literals: + - password=helloworld diff --git a/k8s/persistant-volume-claim-mysql.yaml b/k8s/persistant-volume-claim-mysql.yaml new file mode 100644 index 0000000..edd47bb --- /dev/null +++ b/k8s/persistant-volume-claim-mysql.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: oleksii-mysql-pv-claim + labels: + app: matomo-playground +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 20Gi diff --git a/modules/ROOT/nav.adoc b/modules/ROOT/nav.adoc new file mode 100644 index 0000000..5490514 --- /dev/null +++ b/modules/ROOT/nav.adoc @@ -0,0 +1 @@ +* xref:general.adoc[] diff --git a/modules/ROOT/pages/general.adoc b/modules/ROOT/pages/general.adoc new file mode 100644 index 0000000..aa6b94c --- /dev/null +++ b/modules/ROOT/pages/general.adoc @@ -0,0 +1,92 @@ +:toc: right += Matomo + +https://hub.docker.com/_/matomo/[Official docker image]. + +Steps: + +. create Ingress object + + +== Ingress +[source, yaml] +---- +include::../.././../k8s/ingress-matomo.yaml[] +---- + + kubectl describe ingress ingress-matomo -n playground + + kubectl describe ingress -n playground + + kubectl describe ingress ingress-resource-backend -n playground + +=== Error + + + docker run --name=some-mysql -e MYSQL_ROOT_PASSWORD=admin123 -d mysql + + docker run --name myadmin -d --link testsql:db -p 8080:80 phpmyadmin/phpmyadmin + + docker run --name myadmin -d --link dockermysqlrabbitmq_mysql:db -p 8080:80 phpmyadmin/phpmyadmin + + docker run -d --link dockermysqlrabbitmq_mysql_1:db -v matomo:/var/www/html -p 8080:80 matomo + + + docker exec -ti dockermysqlrabbitmq_mysql_1 bash + + docker-compose up --build + + + +== Backend or Service +[source,yaml] +---- +include::../.././../k8s/backend-matomo.yaml[] +---- + +https://kubernetes.io/docs/concepts/services-networking/ingress/#resource-backend[Resource backends documentation] + +== Deployment + +[source,yaml] +---- +include::../.././../k8s/deployment-matomo.yaml[] +---- + +Logging UI https://playground.k-space.ee[address] + + +== Useful commands + + kubectl delete ingress matomo-ingress + + kubectl get ep -n playground + + kubectl config use-context default + + kubectl config get-contexts + + journalctl -u kubelet + + journalctl -f + + ip route list + + + kubectl apply -f k8s/ -n playground + + alias k="kubectl -n sb-4m3khtc9b8" + + + +== Secret + +[source,bash] +---- +cat <./kustomization.yaml +secretGenerator: +- name: mysql-pass +literals: +- password=helloworld +EOF +----