Retool the demo
Rather than hugo, which I really don't know much about and don't care to maintain, it now is just a trivial HTTP server (python) serving content from this repo.
This commit is contained in:
parent
e027ef64ac
commit
aa230f92f8
|
|
@ -1,35 +1,25 @@
|
|||
# git-blog-demo
|
||||
# git-sync-demo
|
||||
|
||||
This demo shows how to use the `git-sync` sidekick container along side `volumes` and `volumeMounts` to create a markdown powered blog.
|
||||
This demo shows how to use a `git-sync` container alongside an HTTP server to
|
||||
serve static content.
|
||||
|
||||
## How it works
|
||||
|
||||
The pod is composed of 3 containers that share directories using 2 volumes:
|
||||
The pod is composed of 2 containers that share a volume.
|
||||
|
||||
- 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.
|
||||
- The `git-sync` container clones a git repo into the `content` volume
|
||||
- The `http` container serves that content
|
||||
|
||||
For the purposes of this demo, it's about as trivial as it can get.
|
||||
|
||||
## Usage
|
||||
|
||||
### Build demo containers (Optional)
|
||||
|
||||
Build the demo containers, and push them to a registry
|
||||
Apply the deployment and the service files:
|
||||
|
||||
```
|
||||
docker build -t <some-registry>/git-sync ..
|
||||
docker build -t <some-registry>/hugo hugo/
|
||||
docker push <some-registry>/hugo <some-registry>/git-sync
|
||||
kubectl apply -f deployment.yaml
|
||||
kubectl apply -f service.yaml
|
||||
```
|
||||
|
||||
If you end up using a different registry, be sure to update `config/deployment.yaml`.
|
||||
|
||||
###
|
||||
|
||||
Create the pod and the service for the blog
|
||||
|
||||
```
|
||||
kubectl create -f config
|
||||
```
|
||||
|
||||
Open the service external ip in your browser
|
||||
Wait for the service to be assigned a LoadBalancer IP, then open that IP in
|
||||
your browser.
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
baseurl = "http://example.com"
|
||||
languageCode = "en-us"
|
||||
title = "example blog"
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
+++
|
||||
date = "2014-12-19T15:29:48-08:00"
|
||||
draft = true
|
||||
title = "about"
|
||||
+++
|
||||
|
||||
## A headline
|
||||
|
||||
Some content about the blog.
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
+++
|
||||
date = "2014-12-19T15:30:18-08:00"
|
||||
draft = true
|
||||
title = "first"
|
||||
+++
|
||||
|
||||
## first port
|
||||
|
||||
This is the first post.
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: blog
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
name: blog
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
name: blog
|
||||
spec:
|
||||
containers:
|
||||
- name: git-sync
|
||||
image: registry.k8s.io/git-sync:v3.1.3
|
||||
volumeMounts:
|
||||
- name: markdown
|
||||
mountPath: /tmp/git
|
||||
env:
|
||||
- name: GITSYNC_REPO
|
||||
value: https://github.com/kubernetes/git-sync.git
|
||||
- name: GITSYNC_LINK
|
||||
value: git-sync
|
||||
- name: hugo
|
||||
image: registry.k8s.io/hugo
|
||||
volumeMounts:
|
||||
- name: markdown
|
||||
mountPath: /src
|
||||
- name: html
|
||||
mountPath: /dest
|
||||
env:
|
||||
- name: HUGO_SRC
|
||||
value: /src/git-sync/demo/blog
|
||||
- name: HUGO_BUILD_DRAFT
|
||||
value: "true"
|
||||
- name: HUGO_BASE_URL
|
||||
value: example.com
|
||||
- name: nginx
|
||||
image: nginx
|
||||
volumeMounts:
|
||||
- name: html
|
||||
mountPath: /usr/share/nginx/html
|
||||
volumes:
|
||||
- name: markdown
|
||||
emptyDir: {}
|
||||
- name: html
|
||||
emptyDir: {}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: static-server
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: static-server
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: static-server
|
||||
spec:
|
||||
volumes:
|
||||
- name: content
|
||||
emptyDir: {}
|
||||
containers:
|
||||
# This container pulls a git repo into the "content" volume. If this
|
||||
# were a "real" app it would probably have livenessProbe and resources,
|
||||
# and maybe a secret to get credentials for your git server.
|
||||
- name: git-sync
|
||||
image: registry.k8s.io/git-sync/git-sync:v4.2.3
|
||||
args:
|
||||
- --repo=https://github.com/kubernetes/git-sync
|
||||
- --root=/git
|
||||
- --period=60s
|
||||
- --link=head
|
||||
- --max-failures=1000000000
|
||||
- -v=2
|
||||
volumeMounts:
|
||||
- name: content
|
||||
mountPath: /git
|
||||
# This container is a trivial HTTP server for the content.
|
||||
# If this were a "real" app it would not be so trivial. For example,
|
||||
# nginx or apache are much more robust web servers! It's missing a
|
||||
# livenessProbe, resources, and many other things you would want for
|
||||
# running in production. Also, you would probably have a git repo
|
||||
# dedicated to holding your content.
|
||||
- name: http
|
||||
image: python:alpine
|
||||
args:
|
||||
- python3
|
||||
- -m
|
||||
- http.server
|
||||
- -d=/git/head/demo/html
|
||||
volumeMounts:
|
||||
- name: content
|
||||
mountPath: /git
|
||||
readOnly: true
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>That's it, that's the demo</h1>
|
||||
<p>Impressive, right?</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
# Copyright 2014 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
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 HUGO_SRC /src
|
||||
ENV HUGO_DEST /dest
|
||||
ENV HUGO_THEME hyde
|
||||
ENV HUGO_BUILD_DRAFT false
|
||||
ENV HUGO_BASE_URL ""
|
||||
ADD run-hugo /run-hugo
|
||||
ENTRYPOINT ["/run-hugo"]
|
||||
CMD ["server", "--source=${HUGO_SRC}", "--theme=${HUGO_THEME}", "--buildDrafts=${HUGO_BUILD_DRAFT}", "--baseUrl=${HUGO_BASE_URL}", "--watch", "--destination=${HUGO_DEST}", "--appendPort=false"]
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
# hugo
|
||||
|
||||
`hugo` is a container that convert markdown into html using [hugo static site generator](http://gohugo.io/).
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
# build the container
|
||||
docker build -t hugo .
|
||||
# run the hugo container
|
||||
docker run -e HUGO_BASE_URL=example.com -v /path/to/md:/src -v /path/to/html:/dest hugo
|
||||
```
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright 2014 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -ex
|
||||
if [ ! -d ${HUGO_SRC}/themes ]; then
|
||||
ln -s /themes ${HUGO_SRC}/themes
|
||||
fi
|
||||
hugo $(eval echo $*) # force default CMD env expansion
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: blog-service
|
||||
name: static-server
|
||||
spec:
|
||||
selector:
|
||||
app: static-server
|
||||
type: LoadBalancer
|
||||
ports:
|
||||
- port: 80
|
||||
selector:
|
||||
name: blog
|
||||
targetPort: 8000
|
||||
Loading…
Reference in New Issue