Skip to content

Commit

Permalink
Retool the demo
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
thockin committed Jun 9, 2024
1 parent 750e20e commit 71c24c4
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 155 deletions.
36 changes: 13 additions & 23 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -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

## Usage

### Build demo containers (Optional)

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
```
For the purposes of this demo, it's about as trivial as it can get.

If you end up using a different registry, be sure to update `config/deployment.yaml`.

###
## Usage

Create the pod and the service for the blog
Apply the deployment and the service files:

```
kubectl create -f config
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
```

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.
Empty file removed demo/blog/archetypes/.keep
Empty file.
3 changes: 0 additions & 3 deletions demo/blog/config.toml

This file was deleted.

9 changes: 0 additions & 9 deletions demo/blog/content/about.md

This file was deleted.

9 changes: 0 additions & 9 deletions demo/blog/content/post/first.md

This file was deleted.

Empty file removed demo/blog/layouts/.keep
Empty file.
Empty file removed demo/blog/static/.keep
Empty file.
49 changes: 0 additions & 49 deletions demo/config/deployment.yaml

This file was deleted.

50 changes: 50 additions & 0 deletions demo/deployment.yaml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions demo/html/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<body>

<h1>That's it, that's the demo</h1>
<p>Impressive, right?</p>

</body>
</html>
26 changes: 0 additions & 26 deletions demo/hugo/Dockerfile

This file was deleted.

12 changes: 0 additions & 12 deletions demo/hugo/README.md

This file was deleted.

21 changes: 0 additions & 21 deletions demo/hugo/run-hugo

This file was deleted.

7 changes: 4 additions & 3 deletions demo/config/service.yaml → demo/service.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 71c24c4

Please sign in to comment.