mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 00:07:50 +00:00
contrib/git-sync: add demo
This commit is contained in:
parent
5aba5f00c0
commit
19751abe13
28
contrib/git-sync/demo/README.md
Normal file
28
contrib/git-sync/demo/README.md
Normal 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
|
0
contrib/git-sync/demo/blog/archetypes/.keep
Normal file
0
contrib/git-sync/demo/blog/archetypes/.keep
Normal file
3
contrib/git-sync/demo/blog/config.toml
Normal file
3
contrib/git-sync/demo/blog/config.toml
Normal file
@ -0,0 +1,3 @@
|
||||
baseurl = "http://example.com"
|
||||
languageCode = "en-us"
|
||||
title = "example blog"
|
9
contrib/git-sync/demo/blog/content/about.md
Normal file
9
contrib/git-sync/demo/blog/content/about.md
Normal file
@ -0,0 +1,9 @@
|
||||
+++
|
||||
date = "2014-12-19T15:29:48-08:00"
|
||||
draft = true
|
||||
title = "about"
|
||||
+++
|
||||
|
||||
## A headline
|
||||
|
||||
Some content about the blog.
|
9
contrib/git-sync/demo/blog/content/post/first.md
Normal file
9
contrib/git-sync/demo/blog/content/post/first.md
Normal file
@ -0,0 +1,9 @@
|
||||
+++
|
||||
date = "2014-12-19T15:30:18-08:00"
|
||||
draft = true
|
||||
title = "first"
|
||||
+++
|
||||
|
||||
## first port
|
||||
|
||||
This is the first post.
|
0
contrib/git-sync/demo/blog/layouts/.keep
Normal file
0
contrib/git-sync/demo/blog/layouts/.keep
Normal file
0
contrib/git-sync/demo/blog/static/.keep
Normal file
0
contrib/git-sync/demo/blog/static/.keep
Normal file
50
contrib/git-sync/demo/config/pod.yaml
Normal file
50
contrib/git-sync/demo/config/pod.yaml
Normal 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
|
8
contrib/git-sync/demo/config/service.yaml
Normal file
8
contrib/git-sync/demo/config/service.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
id: blog-service
|
||||
kind: Service
|
||||
apiVersion: v1beta1
|
||||
port: 80
|
||||
containerPort: http-server
|
||||
selector:
|
||||
name: blog
|
||||
createExternalLoadBalancer: true
|
13
contrib/git-sync/demo/hugo/Dockerfile
Normal file
13
contrib/git-sync/demo/hugo/Dockerfile
Normal 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"]
|
6
contrib/git-sync/demo/hugo/run-hugo
Executable file
6
contrib/git-sync/demo/hugo/run-hugo
Executable 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
|
Loading…
Reference in New Issue
Block a user