Skip to content

Commit

Permalink
Kubedb
Browse files Browse the repository at this point in the history
  • Loading branch information
davlloyd committed Mar 10, 2020
1 parent adf1c03 commit 1d42192
Show file tree
Hide file tree
Showing 26 changed files with 359 additions and 108 deletions.
43 changes: 0 additions & 43 deletions README.md

This file was deleted.

27 changes: 15 additions & 12 deletions docker/lychee-web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,20 @@ ENV DB_USER dbuser
ENV DB_PASSWORD password
ENV DB_PREFIX ""


# Get the Core installed

RUN apt-get update
RUN apt-get install -yq language-pack-en-base software-properties-common
RUN LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
RUN apt-get update

# Lychee requires the following php extensions Installed (session, exif, mbstring, gd, mysqli, json, zip)
# Where lychee defaults to consuming local mysql services no mysql server instance will be located in this image
RUN apt-get -yq install git nginx imagemagick curl mysql-client vim nfs-common \
php7.0-fpm php7.0-common php7.0-cli php7.0-mysqlnd \
php7.0-mysqli php-curl php7.0-json php7.0-zip php7.0-exif \
php7.0-mbstring php7.0-gd php7.0-exif php-pear php7.0-dev
RUN pecl install mongodb
RUN apt-get -yq install git nginx imagemagick curl mysql-client vim nfs-common
RUN apt-get -yq install php7.4-fpm php7.4-common php7.4-cli php7.4-mysqlnd
RUN apt-get -yq install php7.4-mysqli php-curl php7.4-json php7.4-zip php7.4-exif \
php7.4-mbstring php7.4-gd php7.4-exif php-pear php7.4-dev
#RUN pecl install mongodb

# Activate app in NGINX
COPY files/lychee-webapp /etc/nginx/sites-available
Expand All @@ -59,16 +62,16 @@ RUN rm /etc/nginx/sites-enabled/default && \
#RUN ln -s /etc/nginx/sites-available/lychee-ssl-webapp /etc/nginx/sites-enabled

# Configure PHP
RUN sed -i -e "s/output_buffering\s*=\s*4096/output_buffering = Off/g" /etc/php/7.0/fpm/php.ini && \
sed -i -e "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" /etc/php/7.0/fpm/php.ini && \
sed -i -e "s/upload_max_filesize\s*=\s*2M/upload_max_filesize = 1G/g" /etc/php/7.0/fpm/php.ini && \
sed -i -e "s/post_max_size\s*=\s*8M/post_max_size = 1G/g" /etc/php/7.0/fpm/php.ini && \
sed -i -e "s/;clear_env = no/clear_env = no/" /etc/php/7.0/fpm/pool.d/www.conf
RUN sed -i -e "s/output_buffering\s*=\s*4096/output_buffering = Off/g" /etc/php/7.4/fpm/php.ini && \
sed -i -e "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" /etc/php/7.4/fpm/php.ini && \
sed -i -e "s/upload_max_filesize\s*=\s*2M/upload_max_filesize = 1G/g" /etc/php/7.4/fpm/php.ini && \
sed -i -e "s/post_max_size\s*=\s*8M/post_max_size = 1G/g" /etc/php/7.4/fpm/php.ini && \
sed -i -e "s/;clear_env = no/clear_env = no/" /etc/php/7.4/fpm/pool.d/www.conf

# Get Lychee code
RUN mkdir -p /usr/share/webapps && \
cd /usr/share/webapps && \
git clone https://github.com/davlloyd/Lychee.git && \
git clone https://github.com/electerious/Lychee && \
mv /usr/share/webapps/Lychee /usr/share/webapps/lychee

# Set entry point
Expand Down
12 changes: 6 additions & 6 deletions docker/lychee-web/files/entry_point.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ done
echo "?>" >> /config/lychee/config.php

# Set variables for web application
[ -e /etc/php/7.0/fpm/pool.d/www.conf ] && \
echo "env[DB_USER] = $DB_USER" >> /etc/php/7.0/fpm/pool.d/www.conf && \
echo "env[DB_PASSWORD] = $DB_PASSWORD" >> /etc/php/7.0/fpm/pool.d/www.conf && \
echo "env[DB_HOST] = $DB_HOST" >> /etc/php/7.0/fpm/pool.d/www.conf && \
echo "env[DB_NAME] = $DB_NAME" >> /etc/php/7.0/fpm/pool.d/www.conf
[ -e /etc/php/7.4/fpm/pool.d/www.conf ] && \
echo "env[DB_USER] = $DB_USER" >> /etc/php/7.4/fpm/pool.d/www.conf && \
echo "env[DB_PASSWORD] = $DB_PASSWORD" >> /etc/php/7.4/fpm/pool.d/www.conf && \
echo "env[DB_HOST] = $DB_HOST" >> /etc/php/7.4/fpm/pool.d/www.conf && \
echo "env[DB_NAME] = $DB_NAME" >> /etc/php/7.4/fpm/pool.d/www.conf


# permissions
Expand All @@ -65,7 +65,7 @@ chown -R root:root \
chmod -R 777 /config /photos

# Get PHP started as installs stopped
service php7.0-fpm start
service php7.4-fpm start

# Get nginx service started as installs stopped
service nginx start
Expand Down
2 changes: 1 addition & 1 deletion docker/lychee-web/files/lychee-webapp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ server {

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
include fastcgi_params;
}

Expand Down
25 changes: 25 additions & 0 deletions lychee-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: gcm.vmware.com/v1alpha1
kind: ManagedCluster
metadata:
name: lychee1
namespace: lychee
spec:
topology:
controlPlane:
count: 1
class: guaranteed-small
storageClass: wcp-storage-general
workers:
count: 3
class: guaranteed-medium
storageClass: wcp-storage-general
distribution:
fullVersion: v1.15.5+vmware.1-tkg.1.85123d8
settings:
network:
cni:
name: calico
services:
cidrBlocks: ["198.51.100.0/12"]
pods:
cidrBlocks: ["192.0.2.0/16"]
16 changes: 15 additions & 1 deletion lychee-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
name: lychee-config
data:
db_name: lychee
db_user: lychee
db_user: root
user.ini: |
max_execution_time = 200
post_max_size = 200M
Expand All @@ -25,3 +25,17 @@ data:
$dbTablePrefix = '';
?>
---

apiVersion: v1
kind: Secret
metadata:
name: lychee-secret
labels:
app: lychee
type: Opaque
data:
username: cm9vdA==
password: cGFzc3dvcmQ=

42 changes: 42 additions & 0 deletions lychee-kubedb-mysql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: kubedb.com/v1alpha1
kind: MySQL
metadata:
name: lychee-mysql
namespace: default
labels:
app: lychee
tier: db
spec:
version: "8.0-v2"
databaseSecret:
secretName: lychee-secret
storageType: "Durable"
storage:
storageClassName: "wcp-storage-general"
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
monitor:
agent: prometheus.io/coreos-operator
prometheus:
namespace: monitoring
labels:
app: lychee
interval: 10s
# podTemplate:
# spec:
# resources:
# requests:
# memory: "64Mi"
# cpu: "250m"
# limits:
# memory: "128Mi"
# cpu: "500m"
serviceTemplate:
spec:
type: LoadBalancer
terminationPolicy: Terminate
updateStrategy:
type: RollingUpdate
10 changes: 0 additions & 10 deletions lychee-secret.yml

This file was deleted.

33 changes: 29 additions & 4 deletions lychee-web-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
app: lychee
tier: frontend
spec:
replicas: 2
replicas: 1
selector:
matchLabels:
app: lychee
Expand All @@ -20,12 +20,11 @@ spec:
spec:
containers:
- name: lychee
image: pks-harbor.syddsc.local/library/lychee-web:latest
# - image: davlloyd/lychee-web:latest
image: davlloyd/lychee-web:latest
imagePullPolicy: Always
env:
- name: DB_HOST
value: lychee-mysql-service
value: lychee-mysql
- name: DB_NAME
valueFrom:
configMapKeyRef:
Expand Down Expand Up @@ -61,3 +60,29 @@ spec:
configMap:
name: lychee-config

---

kind: Service
apiVersion: v1
metadata:
name: lychee-web-service
labels:
app: lychee
tier: frontend
spec:
externalTrafficPolicy: Cluster
selector:
app: lychee
tier: frontend
ports:
- name: http
port: 80
protocol: TCP
targetPort: 80
- name: https
port: 443
protocol: TCP
targetPort: 443
#sessionAffinity: None
sessionAffinity: ClientIP
type: LoadBalancer
6 changes: 3 additions & 3 deletions lychee-web-pvc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ metadata:
tier: frontend
spec:
accessModes:
- ReadWriteMany
volumeMode: Filesystem
- ReadWriteOnce
resources:
requests:
storage: 20Gi
storage: 5Gi
storageClassName: wcp-storage-general
24 changes: 0 additions & 24 deletions lychee-web-service.yml

This file was deleted.

7 changes: 7 additions & 0 deletions network-profiles/nlb-large.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "lb-large",
"description": "Large config LB Network profile",
"parameters": {
"lb_size": "large"
}
}
7 changes: 7 additions & 0 deletions network-profiles/nlb-medium.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "lb-medium",
"description": "Medium config LB Network profile",
"parameters": {
"lb_size": "medium"
}
}
7 changes: 7 additions & 0 deletions network-profiles/nlb-small.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "lb-small",
"description": "Small config LB Network profile",
"parameters": {
"lb_size": "small"
}
}
Loading

0 comments on commit 1d42192

Please sign in to comment.