-
Notifications
You must be signed in to change notification settings - Fork 0
/
owncloud_deploy.yaml
162 lines (144 loc) · 5.8 KB
/
owncloud_deploy.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: owncloud-dockerhub
labels:
app: owncloud
spec:
replicas: 1
template:
metadata:
# unlike a "name" is not included, instead it is automatically
# generated based upon the deployment name.
labels:
app: owncloud
# track: stable
# annotations:
spec:
volumes:
- name: config-store
persistentVolumeClaim:
claimName: owncloud-config-claim
- name: data-store
persistentVolumeClaim:
claimName: owncloud-data-claim
- name: app-store
persistentVolumeClaim:
claimName: owncloud-apps-claim
- name: mdata-store
persistentVolumeClaim:
claimName: mariadb-owncloud-claim
containers:
- name: mariadb
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: owncloud
key: mariadb_root_password
image: mariadb:10.1
ports:
- containerPort: 3306
volumeMounts:
- name: mdata-store
mountPath: /var/lib/mysql
- name: owncloud
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: owncloud
key: mariadb_root_password
- name: OWC_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: owncloud
key: owncloud_admin_password
- name: OWC_DB_TYPE
valueFrom:
configMapKeyRef:
name: owncloud-configmap
key: owc_db_type
- name: OWC_DB_NAME
valueFrom:
configMapKeyRef:
name: owncloud-configmap
key: owc_db_name
- name: OWC_DB_ROOT_USER
valueFrom:
configMapKeyRef:
name: owncloud-configmap
key: owc_db_root_user
- name: OWC_ADMIN_USER
valueFrom:
configMapKeyRef:
name: owncloud-configmap
key: owc_admin_user
- name: OWC_TRUSTED_IP
valueFrom:
configMapKeyRef:
name: owncloud-configmap
key: owc_trusted_ip
image: owncloud:9.1
ports:
- containerPort: 80
volumeMounts:
- name: config-store
mountPath: /var/www/html/config
- name: data-store
mountPath: /var/www/html/data
- name: app-store
mountPath: /var/www/html/apps
command:
- bash
- "-c"
- |
# Enable bash debug tracing and blow up if any command fails
set -ex
# In order to get this running successfully in k8's what we'll do is essentially
# copy the normal Docker startup process. Which is essentially to untar owncloud
# into a apache install and then fire up apache. But instead of the untar and then
# immediately firing up apache, we'll inject the necessary setup to get things
# playing nicely in k8's.
# Extracted from the Owncloud Docker image with a docker inspect owncloud:9.1
OWC_DOCKER_WORKING_DIR=/var/www/html
OWC_DOCKER_ENTRYPOINT=/entrypoint.sh
OWC_DOCKER_CMD=apache2-foreground
# Some of the files need to have specific perms and some of the commands
# are best executed as the www user in order that things work nicely
OWC_DOCKER_USER=www-data
OWC_DOCKER_GROUP=nogroup
# No sudo installed, so need to emulate
SU_CMD_STEM="su --login www-data --shell /bin/sh --command "
# Perform default Owncloud Docker intialisation because we've overridden it
# and we need it in in place before we can do a command line installation.
# (this does untar etc on the owncloud install)
cd $OWC_DOCKER_WORKING_DIR
$OWC_DOCKER_ENTRYPOINT
# Check we have got what looks like a working owncloud install after running the entrypoint
$SU_CMD_STEM "which php"
ls occ
# Now we tailor the installation to run under kubernetes. Some of this we only want to
# do once, as the Owncloud will tailor the settings itself and we do not want to
# stamp on those. Others we need to do every time because they are specific to the
# pod instance.
RUN_BEFORE_FLAG_FILE=config/k8initialised.touch
num_trusted_domains=0
if [[ -f $RUN_BEFORE_FLAG_FILE ]]; then
# Then the disk has already been set up.
echo INFO Owncloud initialised on this volume, not running config setup again.
else
echo INFO Initialising Owncloud on this volume.
# Fix broken ownership from the install on data (comes out as root otherwise)
chown --recursive $OWC_DOCKER_USER:$OWC_DOCKER_GROUP data
# Invoke Owncloud's command line installation tools to add DB, trusted_domain etc.
$SU_CMD_STEM "cd $OWC_DOCKER_WORKING_DIR && php occ maintenance:install --database $OWC_DB_TYPE --database-host 127.0.0.1 --database-name $OWC_DB_NAME --database-user $OWC_DB_ROOT_USER --database-pass $MYSQL_ROOT_PASSWORD --admin-user $OWC_ADMIN_USER --admin-pass $OWC_ADMIN_PASSWORD"
# Add a file so that we do not run the same set up again and stamp
# on the existing setup
touch $RUN_BEFORE_FLAG_FILE
fi
# Add trusted_domains so that can access with Owncloud
$SU_CMD_STEM "cd $OWC_DOCKER_WORKING_DIR && php occ config:system:set trusted_domains $num_trusted_domains --value=$(OWC_TRUSTED_IP)"
num_trusted_domains=`expr $num_trusted_domains + 1`
#Fire off the normal Docker startup
$OWC_DOCKER_CMD