diff --git a/contrib/git-sync/demo/README.md b/contrib/git-sync/demo/README.md new file mode 100644 index 00000000000..b458135bfd9 --- /dev/null +++ b/contrib/git-sync/demo/README.md @@ -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 /git-sync .. +docker build -t /hugo hugo/ +docker push /hugo /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 diff --git a/contrib/git-sync/demo/blog/archetypes/.keep b/contrib/git-sync/demo/blog/archetypes/.keep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/contrib/git-sync/demo/blog/config.toml b/contrib/git-sync/demo/blog/config.toml new file mode 100644 index 00000000000..ab3aa9e446e --- /dev/null +++ b/contrib/git-sync/demo/blog/config.toml @@ -0,0 +1,3 @@ +baseurl = "http://example.com" +languageCode = "en-us" +title = "example blog" diff --git a/contrib/git-sync/demo/blog/content/about.md b/contrib/git-sync/demo/blog/content/about.md new file mode 100644 index 00000000000..afb2ac0f4bb --- /dev/null +++ b/contrib/git-sync/demo/blog/content/about.md @@ -0,0 +1,9 @@ ++++ +date = "2014-12-19T15:29:48-08:00" +draft = true +title = "about" ++++ + +## A headline + +Some content about the blog. diff --git a/contrib/git-sync/demo/blog/content/post/first.md b/contrib/git-sync/demo/blog/content/post/first.md new file mode 100644 index 00000000000..630bbbd01d3 --- /dev/null +++ b/contrib/git-sync/demo/blog/content/post/first.md @@ -0,0 +1,9 @@ ++++ +date = "2014-12-19T15:30:18-08:00" +draft = true +title = "first" ++++ + +## first port + +This is the first post. diff --git a/contrib/git-sync/demo/blog/layouts/.keep b/contrib/git-sync/demo/blog/layouts/.keep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/contrib/git-sync/demo/blog/static/.keep b/contrib/git-sync/demo/blog/static/.keep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/contrib/git-sync/demo/config/pod.yaml b/contrib/git-sync/demo/config/pod.yaml new file mode 100644 index 00000000000..75ff074c18b --- /dev/null +++ b/contrib/git-sync/demo/config/pod.yaml @@ -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 diff --git a/contrib/git-sync/demo/config/service.yaml b/contrib/git-sync/demo/config/service.yaml new file mode 100644 index 00000000000..646b4c59aa6 --- /dev/null +++ b/contrib/git-sync/demo/config/service.yaml @@ -0,0 +1,8 @@ +id: blog-service +kind: Service +apiVersion: v1beta1 +port: 80 +containerPort: http-server +selector: + name: blog +createExternalLoadBalancer: true diff --git a/contrib/git-sync/demo/hugo/Dockerfile b/contrib/git-sync/demo/hugo/Dockerfile new file mode 100644 index 00000000000..40af5e67ed8 --- /dev/null +++ b/contrib/git-sync/demo/hugo/Dockerfile @@ -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"] diff --git a/contrib/git-sync/demo/hugo/run-hugo b/contrib/git-sync/demo/hugo/run-hugo new file mode 100755 index 00000000000..c90daa85e25 --- /dev/null +++ b/contrib/git-sync/demo/hugo/run-hugo @@ -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