contrib/git-sync: add demo

This commit is contained in:
Johan Euphrosine 2015-02-02 18:02:18 -08:00
parent 5aba5f00c0
commit 19751abe13
11 changed files with 126 additions and 0 deletions

View File

@ -0,0 +1,28 @@
# git-blog-demo
This demo shows how to use the `git-sync` sidekick container along side `volumes` and `volumeMounts` to create a markdown powered blog.
## How it works
The pod is composed of 3 containers that share directories using 2 volumes:
- The `git-sync` container clones a git repo into the `markdown` volume
- The `hugo` container read from the `markdown` volume and render it into the `html` volume.
- The `nginx` container serve the content from the `html` volume.
## Usage
Build the demo containers, and push them to a registry
``
docker build -t <some-registry>/git-sync ..
docker build -t <some-registry>/hugo hugo/
docker push <some-registry>/hugo <some-registry>/git-sync
```
Create the pod and the service for the blog
```
kubectl pods create config/pod.html
kubectl services create config/pod.html
```
Open the external ip in your browser

View File

@ -0,0 +1,3 @@
baseurl = "http://example.com"
languageCode = "en-us"
title = "example blog"

View File

@ -0,0 +1,9 @@
+++
date = "2014-12-19T15:29:48-08:00"
draft = true
title = "about"
+++
## A headline
Some content about the blog.

View File

@ -0,0 +1,9 @@
+++
date = "2014-12-19T15:30:18-08:00"
draft = true
title = "first"
+++
## first port
This is the first post.

View File

View File

View File

@ -0,0 +1,50 @@
id: blog-pod
kind: Pod
apiVersion: v1beta1
desiredState:
manifest:
version: v1beta1
containers:
- name: git-sync
image: proppy/git-sync
imagePullPolicy: PullAlways
env::
- name: GIT_SYNC_REPO
value: https://github.com/proppy/blog.git
- name: GIT_SYNC_DEST
value: /git
volumeMounts:
- name: markdown
mountPath: /git
- name: hugo
image: proppy/hugo
imagePullPolicy: PullAlways
env:
- name: SRC
value: /src
- name: BUILD_DRAFT
value: 'true'
- name: BASE_URL
value: kube.proppy.sh
volumeMounts:
- name: markdown
mountPath: /src
- name: html
mountPath: /dest
- name: nginx
image: nginx
volumeMounts:
- name: html
mountPath: /usr/share/nginx/html
ports:
- name: http-server
containerPort: 80
volumes:
- name: markdown
source:
emptyDir: {}
- name: html
source:
emptyDir: {}
labels:
name: blog

View File

@ -0,0 +1,8 @@
id: blog-service
kind: Service
apiVersion: v1beta1
port: 80
containerPort: http-server
selector:
name: blog
createExternalLoadBalancer: true

View File

@ -0,0 +1,13 @@
FROM golang
RUN go get -v github.com/spf13/hugo
RUN git clone --recursive https://github.com/spf13/hugoThemes.git /themes
VOLUME ["/src", "/dest"]
EXPOSE 1313
ENV SRC /src
ENV DEST /dest
ENV THEME hyde
ENV BUILD_DRAFT false
ENV BASE_URL ""
ADD run-hugo /run-hugo
ENTRYPOINT ["/run-hugo"]
CMD ["server", "--source=${SRC}", "--theme=${THEME}", "--buildDrafts=${BUILD_DRAFT}", "--baseUrl=${BASE_URL}", "--watch", "--destination=${DEST}", "--appendPort=false"]

View File

@ -0,0 +1,6 @@
#!/bin/bash
set -ex
if [ ! -d ${SRC}/themes ]; then
ln -s /themes ${SRC}/themes
fi
hugo $(eval echo $*) # force default CMD env expansion