Helm/PhpMyAdmin: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
 
(22 intermediate revisions by the same user not shown)
Line 8: Line 8:
export KUBECONFIG="${HOME}/.kube/gcp-kubeconfig.yaml"
export KUBECONFIG="${HOME}/.kube/gcp-kubeconfig.yaml"
export KUBECONFIG="${HOME}/.kube/config"
export KUBECONFIG="${HOME}/.kube/config"
</syntaxhighlight>
==PMA DB==
<syntaxhighlight lang="sql">
cat << DDL | mariadb
CREATE DATABASE IF NOT EXISTS phpmyadmin;
CREATE USER 'phpmyadmin'@'%' IDENTIFIED BY 'sadaqah!';
GRANT ALL PRIVILEGES ON phpmyadmin.* TO 'phpmyadmin'@'%';
FLUSH PRIVILEGES;
DDL
</syntaxhighlight>
</syntaxhighlight>


Line 24: Line 34:
</syntaxhighlight>
</syntaxhighlight>


|valign="bottom"|
|-
|colspan="2"|
----
|-
|colspan="2"|
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
kubectl get ns|grep phpmyadmin
kubectl get ns|grep phpmyadmin
kubectl create ns  phpmyadmin
kubectl create ns  phpmyadmin
</syntaxhighlight>
</syntaxhighlight>
|-
|colspan="3"|
----
----
|-
|colspan="3"|
<syntaxhighlight lang="yaml">
<syntaxhighlight lang="yaml">
cat <<YML | helm -n phpmyadmin install    phpmyadmin bitnami/phpmyadmin --version=17.0.9 -f -
cat <<YML | helm -n phpmyadmin install    phpmyadmin bitnami/phpmyadmin --version=17.0.9 -f -
Line 48: Line 57:


|-
|-
|colspan="3"|
|colspan="2"|
----
----
|-
|-
|valign='top'|
|valign='top'|
<syntaxhighlight lang="bash">
<syntaxhighlight lang="properties">
echo -n password: ;read -s MYSQL_PWD;export MYSQL_PWD;echo
xdg-open http://mariadb.k8s.local &>/dev/null &
mariadb -hmariadb.k8s.local -p3306 -uacademia academia
gnome-open http://mariadb.k8s.local &>/dev/null &
mariadb -hmariadb.k8s.local -p3306 -uroot mysql
</syntaxhighlight>
</syntaxhighlight>


|valign='top'|
|valign='top'|
<syntaxhighlight lang="bash">
<syntaxhighlight lang="properties">
echo -n password: ;read -s MYSQL_PWD;export MYSQL_PWD;echo
x-www-browser http://mariadb.k8s.local &>/dev/null &
mariadb 'mariadb://root@mariadb.k8s.local:3306/academia'
sensible-browser http://mariadb.k8s.local &>/dev/null &
mariadb 'mariadb://root@mariadb.k8s.local:3306/mysql'
</syntaxhighlight>
 
|}
 
==Create » Secret==
<syntaxhighlight lang="php">
cat <<-'PHP' | kubectl -n phpmyadmin create secret generic config-inc-php --from-file=config.inc.php=/dev/stdin
<?php
declare(strict_types=1);
 
$cfg['blowfish_secret'] = '3zxp0lOKWGD97uA3uWHOoVCkn6FKgN5r';
$i = 0;
 
$i++;
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['host'] = 'mariadb.mariadb';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;
 
$i++;
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['host'] = 'host.minikube.internal';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;
 
/* User used to manipulate with storage */
$cfg['Servers'][$i]['controlhost'] = 'host.minikube.internal';
$cfg['Servers'][$i]['controlport'] = '3306';
$cfg['Servers'][$i]['controluser'] = 'phpmyadmin';
$cfg['Servers'][$i]['controlpass'] = 'sadaqah!';
 
/* Storage database and tables */
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
$cfg['Servers'][$i]['relation'] = 'pma__relation';
$cfg['Servers'][$i]['table_info'] = 'pma__table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma__column_info';
$cfg['Servers'][$i]['history'] = 'pma__history';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
$cfg['Servers'][$i]['tracking'] = 'pma__tracking';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['recent'] = 'pma__recent';
$cfg['Servers'][$i]['favorite'] = 'pma__favorite';
$cfg['Servers'][$i]['users'] = 'pma__users';
$cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
$cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
$cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
$cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';
$cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings';
$cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';
 
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
//$cfg['RowActionType'] = 'icons';
//$cfg['ShowAll'] = true;
//$cfg['MaxRows'] = 50;
//$cfg['ProtectBinary'] = false;
//$cfg['DefaultLang'] = 'en';
//$cfg['PropertiesNumColumns'] = 2;
//$cfg['QueryHistoryDB'] = true;
//$cfg['QueryHistoryMax'] = 100;
//$cfg['SendErrorReports'] = 'always';
//$cfg['URLQueryEncryption'] = true;
//$cfg['URLQueryEncryptionSecretKey'] = '';
//$cfg['AllowArbitraryServer'] = true;
PHP
</syntaxhighlight>
</syntaxhighlight>


|valign='top'|
==Patch » config==
<syntaxhighlight lang="bash">
cat <<YML | kubectl -n phpmyadmin patch deploy/phpmyadmin --patch-file=/dev/stdin
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: phpmyadmin
  namespace: phpmyadmin
spec:
  template:
    spec:
      containers:
      - name: phpmyadmin
        volumeMounts:
        - name: myadmin-secret
          mountPath: /opt/bitnami/phpmyadmin/config.inc.php
          subPath: config.inc.php
      volumes:
      - name: myadmin-secret
        secret:
          secretName: config-inc-php
          items:
          - key: config.inc.php
            path: config.inc.php
YML


|}
kubectl -n phpmyadmin get deploy/phpmyadmin -oyaml|yq '.spec.template.spec.containers[]|select(.name=="phpmyadmin").volumeMounts[]|select(.name=="myadmin-secret" and .subPath=="config.inc.php")'
kubectl -n phpmyadmin get deploy/phpmyadmin -oyaml|yq '.spec.template.spec.containers[]|select(.name=="phpmyadmin").volumeMounts[]|select(.name=="myadmin-secret")'
kubectl -n phpmyadmin get deploy/phpmyadmin -oyaml|yq '.spec.template.spec.volumes[]  |select(.name=="myadmin-secret")'
kubectl -n phpmyadmin exec -it svc/phpmyadmin -c phpmyadmin -- cat /opt/bitnami/phpmyadmin/config.inc.php
kubectl -n phpmyadmin rollout restart deploy phpmyadmin
</syntaxhighlight>


==Uninstall==
==Uninstall==
Line 77: Line 184:
==Swiss Knife==
==Swiss Knife==
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
kubectl -n mariadb run -i --tty --rm mariadb-client --image=alpine --restart=Never -- sh
# kubectl -n mariadb run -i --tty --rm mariadb-client --image=alpine --restart=Never -- sh
# apk --update add --no-cache mariadb-client inetutils-telnet
 
kubectl -n phpmyadmin exec -it svc/phpmyadmin -c phpmyadmin -- bash
echo -n password: ;read -s MYSQL_PWD;export MYSQL_PWD; echo
echo -n password: ;read -s MYSQL_PWD;export MYSQL_PWD; echo
apk --update add --no-cache mariadb-client inetutils-telnet


mariadb -hmariadb.mariadb.svc.cluster.local -uroot academia
mariadb -hmariadb.mariadb.svc.cluster.local -uroot -Dacademia
mariadb -hmariadb.mariadb.svc -uroot academia
mariadb -hmariadb.mariadb.svc -uroot -Dacademia
mariadb -hmariadb.mariadb -uroot academia
mariadb -hmariadb.mariadb -uroot -Dacademia
mariadb -hmariadb -uroot academia
mariadb -hmariadb -uroot -Dacademia
 
mariadb -hhost.minikube.internal -uphpmyadmin -Dphpmyadmin \
< /opt/bitnami/phpmyadmin/sql/create_tables.sql
 
mariadb -hhost.minikube.internal -uphpmyadmin -Dphpmyadmin
mariadb -hmariadb.mariadb.svc    -uphpmyadmin -Dphpmyadmin
</syntaxhighlight>
</syntaxhighlight>


Line 103: Line 218:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
kubectl -n phpmyadmin exec -it svc/phpmyadmin -c phpmyadmin -- mariadb -hhost.minikube.internal -uchorke -p
kubectl -n phpmyadmin exec -it svc/phpmyadmin -c phpmyadmin -- mariadb -hhost.minikube.internal -uchorke -p
kubectl -n phpmyadmin exec -it svc/phpmyadmin -- cat    /opt/bitnami/phpmyadmin/sql/create_tables.sql
kubectl -n phpmyadmin exec -it svc/phpmyadmin -- cat    /opt/bitnami/phpmyadmin/config.inc.php
kubectl -n phpmyadmin exec -it svc/phpmyadmin -- cat    /opt/bitnami/phpmyadmin/config.inc.php
kubectl -n phpmyadmin exec -it svc/phpmyadmin -- ls -lah /opt/bitnami/phpmyadmin/|grep config
kubectl -n phpmyadmin exec -it svc/phpmyadmin -- ls -lah /opt/bitnami/phpmyadmin/|grep config
Line 165: Line 281:
* [https://stackoverflow.com/questions/75596795/ Helm » Pass YAML/JSON using <code>stdin</code>]
* [https://stackoverflow.com/questions/75596795/ Helm » Pass YAML/JSON using <code>stdin</code>]
* [[Helm/Prometheus Stack|Helm » Prometheus Stack]]
* [[Helm/Prometheus Stack|Helm » Prometheus Stack]]
* [[Helm/GitLab External|Helm » GitLab External]]
* [[Helm/Cert Manager|Helm » Cert Manager]]
* [[Helm/Cert Manager|Helm » Cert Manager]]
* [https://artifacthub.io/packages/helm/bitnami/phpmyadmin Helm » phpmyadmin]
* [https://artifacthub.io/packages/helm/bitnami/phpmyadmin Helm » phpmyadmin]
* [[Helm/PgAdmin4|Helm » PgAdmin4]]
* [[Helm/MariaDB|Helm » MariaDB]]
* [[Helm/MariaDB|Helm » MariaDB]]
* [[Helm/GitLab|Helm » GitLab]]
* [[Helm]]
* [[Helm]]


Line 196: Line 315:
* [[K8s/Service|K8s » Service]]
* [[K8s/Service|K8s » Service]]
* [[K8s/Run|K8s » Run]]
* [[K8s/Run|K8s » Run]]
* [[MySQL]]
* [[MinIO]]
* [[MinIO]]
* [[CIDR]]
* [[CIDR]]
* [[UFW]]
* [[UFW]]
* [[Port]]


| valign="top" |
| valign="top" |
* [[PostgreSQL]]


|}
|}

Latest revision as of 06:13, 17 November 2024

helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update && helm repo list
kubectl config get-contexts

Config

export KUBECONFIG="${HOME}/.kube/dev-kubeconfig.yaml"
export KUBECONFIG="${HOME}/.kube/gcp-kubeconfig.yaml"
export KUBECONFIG="${HOME}/.kube/config"

PMA DB

cat << DDL | mariadb
CREATE DATABASE IF NOT EXISTS phpmyadmin;
CREATE USER 'phpmyadmin'@'%' IDENTIFIED BY 'sadaqah!';
GRANT ALL PRIVILEGES ON phpmyadmin.* TO 'phpmyadmin'@'%';
FLUSH PRIVILEGES;
DDL

Install

helm show values bitnami/phpmyadmin --version=17.0.0|less
helm show values bitnami/phpmyadmin --version=17.0.9|less
kubectl get ns|grep phpmyadmin
kubectl delete ns   phpmyadmin

kubectl get ns|grep phpmyadmin
kubectl create ns   phpmyadmin

cat <<YML | helm -n phpmyadmin install    phpmyadmin bitnami/phpmyadmin --version=17.0.9 -f -
---
ingress:
  enabled: true
  ingressClassName: nginx
  hostname: mariadb.k8s.local
  path: /
fullnameOverride: phpmyadmin
YML

xdg-open http://mariadb.k8s.local &>/dev/null &
gnome-open http://mariadb.k8s.local &>/dev/null &
x-www-browser http://mariadb.k8s.local &>/dev/null &
sensible-browser http://mariadb.k8s.local &>/dev/null &

Create » Secret

cat <<-'PHP' | kubectl -n phpmyadmin create secret generic config-inc-php --from-file=config.inc.php=/dev/stdin
<?php
declare(strict_types=1);

$cfg['blowfish_secret'] = '3zxp0lOKWGD97uA3uWHOoVCkn6FKgN5r';
$i = 0;

$i++;
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['host'] = 'mariadb.mariadb';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;

$i++;
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['host'] = 'host.minikube.internal';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;

/* User used to manipulate with storage */
$cfg['Servers'][$i]['controlhost'] = 'host.minikube.internal';
$cfg['Servers'][$i]['controlport'] = '3306';
$cfg['Servers'][$i]['controluser'] = 'phpmyadmin';
$cfg['Servers'][$i]['controlpass'] = 'sadaqah!';

/* Storage database and tables */
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
$cfg['Servers'][$i]['relation'] = 'pma__relation';
$cfg['Servers'][$i]['table_info'] = 'pma__table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma__column_info';
$cfg['Servers'][$i]['history'] = 'pma__history';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
$cfg['Servers'][$i]['tracking'] = 'pma__tracking';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['recent'] = 'pma__recent';
$cfg['Servers'][$i]['favorite'] = 'pma__favorite';
$cfg['Servers'][$i]['users'] = 'pma__users';
$cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
$cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
$cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
$cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';
$cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings';
$cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';

$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
//$cfg['RowActionType'] = 'icons';
//$cfg['ShowAll'] = true;
//$cfg['MaxRows'] = 50;
//$cfg['ProtectBinary'] = false;
//$cfg['DefaultLang'] = 'en';
//$cfg['PropertiesNumColumns'] = 2;
//$cfg['QueryHistoryDB'] = true;
//$cfg['QueryHistoryMax'] = 100;
//$cfg['SendErrorReports'] = 'always';
//$cfg['URLQueryEncryption'] = true;
//$cfg['URLQueryEncryptionSecretKey'] = '';
//$cfg['AllowArbitraryServer'] = true;
PHP

Patch » config

cat <<YML | kubectl -n phpmyadmin patch deploy/phpmyadmin --patch-file=/dev/stdin
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: phpmyadmin
  namespace: phpmyadmin
spec:
  template:
    spec:
      containers:
      - name: phpmyadmin
        volumeMounts:
        - name: myadmin-secret
          mountPath: /opt/bitnami/phpmyadmin/config.inc.php
          subPath: config.inc.php
      volumes:
      - name: myadmin-secret
        secret:
          secretName: config-inc-php
          items:
          - key: config.inc.php
            path: config.inc.php
YML

kubectl -n phpmyadmin get deploy/phpmyadmin -oyaml|yq '.spec.template.spec.containers[]|select(.name=="phpmyadmin").volumeMounts[]|select(.name=="myadmin-secret" and .subPath=="config.inc.php")'
kubectl -n phpmyadmin get deploy/phpmyadmin -oyaml|yq '.spec.template.spec.containers[]|select(.name=="phpmyadmin").volumeMounts[]|select(.name=="myadmin-secret")'
kubectl -n phpmyadmin get deploy/phpmyadmin -oyaml|yq '.spec.template.spec.volumes[]   |select(.name=="myadmin-secret")'
kubectl -n phpmyadmin exec -it svc/phpmyadmin -c phpmyadmin -- cat /opt/bitnami/phpmyadmin/config.inc.php
kubectl -n phpmyadmin rollout restart deploy phpmyadmin

Uninstall

helm uninstall -n phpmyadmin phpmyadmin
kubectl delete namespace phpmyadmin

Swiss Knife

# kubectl -n mariadb run -i --tty --rm mariadb-client --image=alpine --restart=Never -- sh
# apk --update add --no-cache mariadb-client inetutils-telnet

kubectl -n phpmyadmin exec -it svc/phpmyadmin -c phpmyadmin -- bash
echo -n password: ;read -s MYSQL_PWD;export MYSQL_PWD; echo

mariadb -hmariadb.mariadb.svc.cluster.local -uroot -Dacademia
mariadb -hmariadb.mariadb.svc -uroot -Dacademia
mariadb -hmariadb.mariadb -uroot -Dacademia
mariadb -hmariadb -uroot -Dacademia

mariadb -hhost.minikube.internal -uphpmyadmin -Dphpmyadmin \
 < /opt/bitnami/phpmyadmin/sql/create_tables.sql

mariadb -hhost.minikube.internal -uphpmyadmin -Dphpmyadmin
mariadb -hmariadb.mariadb.svc    -uphpmyadmin -Dphpmyadmin

Playground

helm -n phpmyadmin install    phpmyadmin bitnami/phpmyadmin --version=17.0.0
helm -n phpmyadmin upgrade -i phpmyadmin bitnami/phpmyadmin --version=17.0.9
helm show values bitnami/phpmyadmin --version=17.0.9|less

kubectl -n phpmyadmin exec -it svc/phpmyadmin -c phpmyadmin -- mariadb -hhost.minikube.internal -uchorke -p
kubectl -n phpmyadmin exec -it svc/phpmyadmin -- cat     /opt/bitnami/phpmyadmin/sql/create_tables.sql
kubectl -n phpmyadmin exec -it svc/phpmyadmin -- cat     /opt/bitnami/phpmyadmin/config.inc.php
kubectl -n phpmyadmin exec -it svc/phpmyadmin -- ls -lah /opt/bitnami/phpmyadmin/|grep config

kubectl -n phpmyadmin exec -it svc/phpmyadmin -c phpmyadmin -- bash
kubectl -n phpmyadmin exec -it svc/phpmyadmin -- mariadb --help

kubectl config --kubeconfig=${HOME}/.kube/aws-kubeconfig.yaml view --flatten
kubectl config --kubeconfig=${HOME}/.kube/dev-kubeconfig.yaml view --flatten
kubectl config --kubeconfig=${HOME}/.kube/gcp-kubeconfig.yaml view --flatten
kubectl config --kubeconfig=${HOME}/.kube/config view --flatten

kubectl -n phpmyadmin delete all --all
kubectl -n phpmyadmin delete ing --all
kubectl -n phpmyadmin delete sts --all
kubectl -n phpmyadmin delete svc --all
kubectl -n phpmyadmin delete pvc --all
kubectl -n phpmyadmin delete pv  --all

kubectl -n phpmyadmin rollout history deploy phpmyadmin
kubectl -n phpmyadmin rollout restart deploy phpmyadmin
kubectl -n phpmyadmin rollout status  deploy phpmyadmin
kubectl -n phpmyadmin exec -it svc/phpmyadmin -- mariadb --help
kubectl -n phpmyadmin logs -f svc/phpmyadmin -c phpmyadmin
kubectl -n phpmyadmin logs -f svc/phpmyadmin

References