@@ -19,135 +19,17 @@ requirements. This repository contains:
1919
2020 https://docs.openshift.org/latest/using_images/db_images/postgresql.html
2121
22- ## Initial deployment
23- Gogs can be easily deployed using the included template:
24-
25- oc process -f gogs.yaml | oc create -f -
26-
27- If you wish to change the route URL or change the name of the application
28- components, you can do so:
29-
30- oc process -f gogs.yaml -v APPLICATION_NAME=foo,HOSTNAME_HTTP=www.bar.baz \
31- | oc create -f -
32-
33- HTTPS is currently unsupported. Pull requests welcome.
34-
35- Once Gogs is running, continue to Initial Setup
36-
37- ## Initial setup
38- The template creates a route by default. Given the project name ` gogs ` and the
39- default template, that might look something like:
40-
41- http://gogs-gogs.apps.yourdomain.com
42-
43- Visit this URL and you will be greeted with the initial setup / installation
44- page for Gogs. Follow the instructions. The installation process will also set
45- up the necessary tables in the database.
46-
47- Some notes:
48-
49- * If your database is hosted on OpenShift and in the same project, you can
50- simply use the service's name as the database host. For example, if your
51- database service is called ` postgresql ` then the database host line can just
52- be ` postgresql:5432 ` .
53-
54- * The value of "Application URL" is the FQDN of your route, with context, if
55- relevant. Using the example above, our "Application URL" is
56- ` http://gogs-gogs.apps.yourdomain.com ` .
57-
58- * Be sure to set an administration user, or the first user to register will
59- automatically become an administrator.
60-
61- ## ConfigMap
62- After the initial installation, Gogs has created a file on the local container
63- filesystem ` /etc/gogs/conf/app.ini ` . Unfortunately, this config file will not be
64- persisted if the container restarts.
65-
66- It is a "waste" to use an entire persistent volume for a ~ 12KiB file, so,
67- instead we will use a
68- [ ConfigMap] ( https://docs.openshift.org/latest/dev_guide/configmaps.html ) .
69-
70- First, find the name of the deployed pod using the ` oc ` tool, or the web
71- console:
72-
73- oc get pod
74- NAME READY STATUS RESTARTS AGE
75- gogs-1-h1vfn 1/1 Running 0 5m
76- postgresql-1-fznew 1/1 Running 0 2m
77-
78- You can use ` oc exec ` to execute a command inside the container. In this case,
79- we will use it to cat out the contents of the Gogs config file and place them
80- into a ConfigMap:
81-
82- oc create configmap gogs --from-file=appini=<(oc exec gogs-1-h1vfn -- \
83- cat /etc/gogs/conf/app.ini)
84-
85- ## Volume Mount
86- We can use the data stored in the ConfigMap as a volume and actually mount it
87- into our running container's filesystem. The following command will update the
88- deployment definition for Gogs to add the volume definition and volume mount:
89-
90- oc volume dc/gogs --add --overwrite --name=config-volume -m /etc/gogs/conf/ \
91- --source='{"configMap":{"name":"gogs","items":[{"key":"appini","path":"app.ini"}]}}'
92-
93- Note that this will trigger a new deployment of the Gogs pod(s). It assumes that
94- you did not change the name of the application in the initial template process
95- step. If you * did* change the name of the application, make sure you substitute
96- ` dc/gogs ` for the appropriate name of your deployment.
97-
98- ## Persistent Storage for Repositories
99- Gogs stores the actual git repository data on the filesystem inside the
100- container. This, too, requires some more work so that data is persisted across
101- container restarts.
102-
103- Configuration of persistent volumes and claims is outside of scope of this
104- readme, but more documentation on it can be found
105- [ here] ( https://docs.openshift.org/latest/dev_guide/persistent_volumes.html ) .
106-
107- Some sample claim/volume definitions are in this repository. Once your volume
108- and claim exist, you could do something like the following:
109-
110- oc volume dc/gogs --add --overwrite -t persistentVolumeClaim \
111- --claim-name gogs-pvc -m /home/gogs/gogs-repositories --name repos
112-
113- As Gogs only currently supports writing to a local filesystem, horizontal
114- scaling of the Gogs server may prove difficult.
115-
116-
117- ## Shortcut Instructions
118-
119- gogs (create your admin in ui)
120-
121- oc project gogs
122- oc new-app -f https://raw.githubusercontent.com/eformat/gogs-openshift-docker/master/gogs-persistent.yaml
123-
124- get POSTGRES USER PASSWORD
125-
126- oc exec $(oc get pods | grep postgres | awk '{print $1}') env | grep POSTGRES
127-
128- login to gogs url, setup:
129-
130- postgres settings
131-
132- postgresql:5432
133- POSTGRESQL_USER=gogs
134- POSTGRESQL_PASSWORD=<password>
135- POSTGRESQL_DATABASE=gogs
136-
137- gogs settings
138-
139- application url: http://gogs-gogs.192.168.137.2.xip.io
140- repos: /var/tmp
141- setup an admin user / pwd (you)
142-
143- once started, set configmap with admin setup
144-
145- oc project gogs
146- oc create configmap gogs --from-file=appini=<(oc exec $(oc get pods | grep gogs | awk '{print $1}') -- cat /etc/gogs/conf/app.ini)
147- oc volume dc/gogs --add --overwrite --name=config-volume -m /etc/gogs/conf/ \
148- --source='{"configMap":{"name":"gogs","items":[{"key":"appini","path":"app.ini"}]}}'
22+ ## Deployment
23+ Gogs can be easily deployed using the included templates in ` openshift ` folder.
24+ If your have persistent volumes available in your cluster:
25+
26+ ```
27+ oc new-app -f https://raw.githubusercontent.com/OpenShiftDemos/gogs-openshift-docker/master/openshift/gogs-persistent-template.yaml --param=HOSTNAME=gogs-demo.yourdomain.com
28+ ```
29+ Otherwise:
30+ ```
31+ oc new-app -f https://raw.githubusercontent.com/OpenShiftDemos/gogs-openshift-docker/master/openshift/gogs-template.yaml --param=HOSTNAME=gogs-demo.yourdomain.com
32+ ```
14933
15034## ToDos
151- * add liveness/readiness probe(s)
152- * complete template with persistent postgresql - DONE
15335* git via ssh support
0 commit comments