its a live
This commit is contained in:
parent
694a2042ac
commit
bdd57d0a05
16
run.sh
16
run.sh
@ -1,21 +1,21 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
IP=$(kubectl get node -o=custom-columns='DATA:status.addresses[0].address' | sed -n 2p)
|
IP=$(kubectl get node -o=custom-columns='DATA:status.addresses[0].address' | sed -n 2p)
|
||||||
|
|
||||||
|
|
||||||
minikube addons enable dashboard
|
|
||||||
minikube addons enable metallb
|
minikube addons enable metallb
|
||||||
minikube addons enable metrics-server
|
minikube addons enable metrics-server
|
||||||
|
|
||||||
eval $(minikube docker-env)
|
eval $(minikube docker-env)
|
||||||
|
minikube dashboard &
|
||||||
docker build -t ngnix_image srcs/nginx
|
docker build -t nginx_image srcs/nginx
|
||||||
docker build -t phpmyadmin_image srcs/phpmyadmin
|
docker build -t phpmyadmin_image srcs/phpmyadmin
|
||||||
docker build -t mysqlserver srcs/mysql
|
docker build -t mariadb-image srcs/newmysql
|
||||||
|
|
||||||
kubectl apply -f srcs/yaml/metallb.yaml
|
kubectl apply -f srcs/yaml/metallb.yaml
|
||||||
kubectl apply -f srcs/yaml/nginx_service.yaml
|
kubectl apply -f srcs/yaml/nginx_service.yaml
|
||||||
kubectl apply -f srcs/yaml/persistencevolume.yaml
|
# kubectl apply -f srcs/yaml/persistencevolume.yaml
|
||||||
kubectl apply -f srcs/yaml/mysql.yaml
|
kubectl apply -f srcs/newmysql/mariadb.yaml
|
||||||
kubectl apply -f srcs/yaml/phpsvc.yaml
|
kubectl apply -f srcs/yaml/phpsvc.yaml
|
||||||
|
|
||||||
echo "Minikube IP: ${IP}"
|
echo "Minikube IP: ${IP}"
|
||||||
|
|
||||||
|
|
||||||
|
# sh minikubenewpc.sh sh ~/Desktop/ft_services/run.sh
|
||||||
21
setup.sh
21
setup.sh
@ -1,21 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
IP=$(kubectl get node -o=custom-columns='DATA:status.addresses[0].address' | sed -n 2p)
|
|
||||||
|
|
||||||
|
|
||||||
minikube addons enable dashboard
|
|
||||||
minikube addons enable metallb
|
|
||||||
minikube addons enable metrics-server
|
|
||||||
|
|
||||||
eval $(minikube docker-env)
|
|
||||||
|
|
||||||
docker build -t ngnix_image srcs/nginx
|
|
||||||
docker build -t phpmyadmin_image srcs/phpmyadmin
|
|
||||||
docker build -t mysqlserver srcs/mysql
|
|
||||||
|
|
||||||
kubectl apply -f srcs/yaml/metallb.yaml
|
|
||||||
kubectl apply -f srcs/yaml/nginx_service.yaml
|
|
||||||
kubectl apply -f srcs/yaml/persistencevolume.yaml
|
|
||||||
kubectl apply -f srcs/yaml/mysql.yaml
|
|
||||||
kubectl apply -f srcs/yaml/phpsvc.yaml
|
|
||||||
|
|
||||||
echo "Minikube IP: ${IP}"
|
|
||||||
BIN
srcs/.DS_Store
vendored
Normal file
BIN
srcs/.DS_Store
vendored
Normal file
Binary file not shown.
12
srcs/mysqlrc/Dockerfile
Executable file
12
srcs/mysqlrc/Dockerfile
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
FROM alpine:3.12.3
|
||||||
|
RUN apk update
|
||||||
|
RUN apk add mariadb mariadb-common mariadb-client openrc supervisor
|
||||||
|
COPY my.cnf /etc/my.cnf
|
||||||
|
COPY mysql.sql ./
|
||||||
|
COPY wordpress.sql ./
|
||||||
|
COPY supervisord.conf /etc/supervisord.conf
|
||||||
|
EXPOSE 3306
|
||||||
|
COPY start.sh /start.sh
|
||||||
|
RUN chmod +x /start.sh
|
||||||
|
VOLUME ["/var/lib/mysql"]
|
||||||
|
CMD ["/start.sh"]
|
||||||
6
srcs/mysqlrc/my.cnf
Executable file
6
srcs/mysqlrc/my.cnf
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
[mysqld]
|
||||||
|
user = root
|
||||||
|
datadir = /var/lib/mysql
|
||||||
|
port = 3306
|
||||||
|
bind-address = 0.0.0.0
|
||||||
|
skip-networking = false
|
||||||
4
srcs/mysqlrc/mysql.sql
Normal file
4
srcs/mysqlrc/mysql.sql
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
CREATE DATABASE my_db;
|
||||||
|
CREATE USER 'root'@'%' IDENTIFIED BY 'root';
|
||||||
|
GRANT ALL PRIVILEGES ON my_db.* TO 'root';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
63
srcs/mysqlrc/start.sh
Executable file
63
srcs/mysqlrc/start.sh
Executable file
@ -0,0 +1,63 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
rc default
|
||||||
|
|
||||||
|
if [ ! -d "/run/mysqld" ]; then
|
||||||
|
mkdir -p /run/mysqld
|
||||||
|
fi
|
||||||
|
|
||||||
|
rc-status
|
||||||
|
touch /run/openrc/softlevel
|
||||||
|
/etc/init.d/mariadb setup
|
||||||
|
/etc/init.d/mariadb start
|
||||||
|
mysql < mysql.sql
|
||||||
|
mysql -u root wordpress < wordpress.sql
|
||||||
|
/etc/init.d/mariadb stop
|
||||||
|
/usr/bin/supervisord
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# if [ -d /var/lib/mysql/mysql ]; then
|
||||||
|
# echo '[i] MySQL directory already present, skipping creation'
|
||||||
|
# else
|
||||||
|
# echo "[i] MySQL data directory not found, creating initial DBs"
|
||||||
|
|
||||||
|
# # chown -R mysql:mysql /var/lib/mysql
|
||||||
|
|
||||||
|
# # init database
|
||||||
|
# echo 'Initializing database'
|
||||||
|
# mysql_install_db --user=mysql > /dev/null
|
||||||
|
# echo 'Database initialized'
|
||||||
|
|
||||||
|
# echo "[i] MySql root password: root"
|
||||||
|
|
||||||
|
# # create temp file
|
||||||
|
# tfile=`mktemp`
|
||||||
|
# if [ ! -f "$tfile" ]; then
|
||||||
|
# return 1
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# # save sql
|
||||||
|
# echo "[i] Create temp file: $tfile"
|
||||||
|
# cat << EOF > $tfile
|
||||||
|
# CREATE DATABASE wordpress;
|
||||||
|
# CREATE USER 'new'@'%' IDENTIFIED BY '';
|
||||||
|
# GRANT ALL PRIVILEGES ON *.* TO 'new'@'%' WITH GRANT OPTION;
|
||||||
|
# FLUSH PRIVILEGES;
|
||||||
|
# EOF
|
||||||
|
|
||||||
|
# echo 'FLUSH PRIVILEGES;' >> $tfile
|
||||||
|
|
||||||
|
# # run sql in tempfile
|
||||||
|
# echo "[i] run tempfile: $tfile"
|
||||||
|
# /usr/bin/mysqld --user=mysql --bootstrap --verbose=0 < $tfile
|
||||||
|
# rm -f $tfile
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# echo "[i] Sleeping 5 sec"
|
||||||
|
# sleep 5
|
||||||
|
|
||||||
|
# echo '[i] start running mysqld'
|
||||||
|
# exec /usr/bin/mysqld_safe
|
||||||
6
srcs/mysqlrc/supervisord.conf
Executable file
6
srcs/mysqlrc/supervisord.conf
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
[supervisord]
|
||||||
|
user = root
|
||||||
|
nodaemon=true
|
||||||
|
|
||||||
|
[program:mysqld_safe]
|
||||||
|
command = sh -c "/usr/bin/mysqld_safe && kill -s SIGTERM $(cat supervisord.pid)"
|
||||||
647
srcs/mysqlrc/wordpress.sql
Executable file
647
srcs/mysqlrc/wordpress.sql
Executable file
File diff suppressed because one or more lines are too long
18
srcs/newmysql/Dockerfile
Normal file
18
srcs/newmysql/Dockerfile
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
FROM alpine:3.12.3
|
||||||
|
|
||||||
|
RUN apk update && apk upgrade
|
||||||
|
RUN apk add mariadb mariadb-client openrc
|
||||||
|
|
||||||
|
RUN mkdir "/run/mysqld" && chown -R mysql /run/mysqld
|
||||||
|
|
||||||
|
COPY create_db.sql .
|
||||||
|
COPY my.cnf /etc/
|
||||||
|
COPY wp_db.sql .
|
||||||
|
COPY start_mysql.sh .
|
||||||
|
RUN chmod +x start_mysql.sh
|
||||||
|
|
||||||
|
VOLUME ["/var/lib/mysql"]
|
||||||
|
|
||||||
|
EXPOSE 3306
|
||||||
|
|
||||||
|
CMD sh start_mysql.sh
|
||||||
3
srcs/newmysql/create_db.sql
Normal file
3
srcs/newmysql/create_db.sql
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
CREATE DATABASE wp_db;
|
||||||
|
GRANT ALL PRIVILEGES ON *.* TO 'mdenys'@'%' IDENTIFIED BY 'mdenys' WITH GRANT OPTION;
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
80
srcs/newmysql/mariadb.yaml
Normal file
80
srcs/newmysql/mariadb.yaml
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: mariadb-service
|
||||||
|
labels:
|
||||||
|
app: mariadb
|
||||||
|
spec:
|
||||||
|
type: ClusterIP
|
||||||
|
ports:
|
||||||
|
- port: 3306
|
||||||
|
name: mariadb
|
||||||
|
targetPort: 3306
|
||||||
|
selector:
|
||||||
|
app: mariadb
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: mariadb
|
||||||
|
labels:
|
||||||
|
app: mariadb
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: mariadb
|
||||||
|
replicas: 1
|
||||||
|
strategy:
|
||||||
|
type: Recreate
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: mariadb
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: mariadb-container
|
||||||
|
image: mariadb-image
|
||||||
|
imagePullPolicy: Never
|
||||||
|
ports:
|
||||||
|
- containerPort: 3306
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: "/var/lib/mysql"
|
||||||
|
name: mariadb-pv
|
||||||
|
volumes:
|
||||||
|
- name: mariadb-pv
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: mariadb-pvc
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolume
|
||||||
|
metadata:
|
||||||
|
name: mariadb-pv
|
||||||
|
labels:
|
||||||
|
type: local
|
||||||
|
spec:
|
||||||
|
storageClassName: manual
|
||||||
|
capacity:
|
||||||
|
storage: 500Mi
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
hostPath:
|
||||||
|
path: "/var/lib/mysql"
|
||||||
|
claimRef:
|
||||||
|
name: mysql-pvc
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: mariadb-pvc
|
||||||
|
labels:
|
||||||
|
app: mariadb
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 500Mi
|
||||||
7
srcs/newmysql/my.cnf
Normal file
7
srcs/newmysql/my.cnf
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[mysqld]
|
||||||
|
|
||||||
|
user = root
|
||||||
|
port = 3306
|
||||||
|
datadir = /var/lib/mysql
|
||||||
|
bind-address = 0.0.0.0
|
||||||
|
skip-networking = false
|
||||||
7
srcs/newmysql/start_mysql.sh
Executable file
7
srcs/newmysql/start_mysql.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
openrc default
|
||||||
|
/etc/init.d/mariadb setup
|
||||||
|
rc-service mariadb start
|
||||||
|
mysql < create_db.sql
|
||||||
|
mysql -u root wp_db < wp_db.sql
|
||||||
|
rc-service mariadb stop
|
||||||
|
/usr/bin/mysqld_safe --datadir="/var/lib/mysql"
|
||||||
661
srcs/newmysql/wp_db.sql
Normal file
661
srcs/newmysql/wp_db.sql
Normal file
File diff suppressed because one or more lines are too long
@ -5,10 +5,11 @@ RUN apk add supervisor nginx php7 php7-fpm php7-opcache php7-gd php7-m
|
|||||||
RUN mkdir -p /var/www/localhost/htdocs/
|
RUN mkdir -p /var/www/localhost/htdocs/
|
||||||
RUN mkdir -p /run/php7
|
RUN mkdir -p /run/php7
|
||||||
RUN mkdir -p /run/nginx
|
RUN mkdir -p /run/nginx
|
||||||
RUN wget http://files.directadmin.com/services/all/phpMyAdmin/phpMyAdmin-5.0.1-all-languages.tar.gz
|
RUN wget https://files.phpmyadmin.net/phpMyAdmin/5.0.4/phpMyAdmin-5.0.4-english.tar.gz
|
||||||
RUN tar -xvf phpMyAdmin-5.0.1-all-languages.tar.gz --strip-components 1 -C /var/www/localhost/htdocs/
|
RUN tar -xvf phpMyAdmin-5.0.4-english.tar.gz --strip-components 1 -C /var/www/localhost/htdocs/
|
||||||
COPY phpmyadmin.inc.php /var/www/localhost/htdocs/config.inc.php
|
COPY phpmyadmin.inc.php /var/www/localhost/htdocs/config.inc.php
|
||||||
RUN mkdir -p /var/www/localhost/htdocs/tmp
|
RUN mkdir -p /var/www/localhost/htdocs/tmp
|
||||||
|
RUN chmod 777 /var/www/localhost/htdocs/tmp
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
COPY supervisord.conf /etc/supervisord.conf
|
COPY supervisord.conf /etc/supervisord.conf
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
server {
|
server {
|
||||||
listen 0.0.0.0:5000;
|
listen 0.0.0.0:5000;
|
||||||
|
server_name localhost;
|
||||||
root /var/www/localhost/htdocs/;
|
root /var/www/localhost/htdocs/;
|
||||||
autoindex on;
|
autoindex on;
|
||||||
index index.php;
|
index index.php;
|
||||||
|
|||||||
@ -3,10 +3,12 @@ $cfg['blowfish_secret'] = 'ZX8lwV2k,PSlDhg40E=38i7Rm1pczKVr';
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
$i++;
|
$i++;
|
||||||
$cfg['Servers'][$i]['auth_type'] = 'cookie';
|
$cfg['Servers'][$i]['auth_type'] = 'cookie';
|
||||||
$cfg['Servers'][$i]['host'] = 'mysql-service';
|
$cfg['Servers'][$i]['host'] = 'mariadb-service:3306';
|
||||||
$cfg['Servers'][$i]['port'] = 3306;
|
$cfg['Servers'][$i]['user'] = 'mdenys';
|
||||||
|
$cfg['Servers'][$i]['password'] = 'mdenys';
|
||||||
$cfg['Servers'][$i]['compress'] = false;
|
$cfg['Servers'][$i]['compress'] = false;
|
||||||
$cfg['Servers'][$i]['AllowNoPassword'] = true;
|
$cfg['Servers'][$i]['AllowNoPassword'] = false;
|
||||||
$cfg['UploadDir'] = '';
|
$cfg['UploadDir'] = '';
|
||||||
$cfg['SaveDir'] = '';
|
$cfg['SaveDir'] = '';
|
||||||
|
$cfg['TempDir'] = '/tmp';
|
||||||
?>
|
?>
|
||||||
@ -9,4 +9,4 @@ data:
|
|||||||
- name: default
|
- name: default
|
||||||
protocol: layer2
|
protocol: layer2
|
||||||
addresses:
|
addresses:
|
||||||
- 192.168.99.100-192.168.99.200
|
- 192.168.99.165-192.168.99.200
|
||||||
@ -6,9 +6,11 @@ metadata:
|
|||||||
app: mysql
|
app: mysql
|
||||||
spec:
|
spec:
|
||||||
type: ClusterIP
|
type: ClusterIP
|
||||||
clusterIP: None
|
|
||||||
ports:
|
ports:
|
||||||
- port: 3306
|
- port: 3306
|
||||||
|
targetPort: 3306
|
||||||
|
protocol: TCP
|
||||||
|
name: mysql-port
|
||||||
selector:
|
selector:
|
||||||
app: mysql
|
app: mysql
|
||||||
---
|
---
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user