Update kubernetes demo/config for example

A couple of changes to make the kubernetes config work
and follow best practices.

- Use `deployment` instead of `pod`.
- Use correct image names.

After these changes, running `kubectl create -f demo/config/` creates a
working deployment/service.
This commit is contained in:
mattjmcnaughton 2018-05-31 22:33:16 -04:00 committed by Tim Hockin
parent ef9bc21b8f
commit 94c7154683
3 changed files with 64 additions and 50 deletions

View File

@ -12,6 +12,8 @@ The pod is composed of 3 containers that share directories using 2 volumes:
## Usage ## Usage
### Build demo containers (Optional)
Build the demo containers, and push them to a registry Build the demo containers, and push them to a registry
``` ```
@ -20,11 +22,14 @@ docker build -t <some-registry>/hugo hugo/
docker push <some-registry>/hugo <some-registry>/git-sync docker push <some-registry>/hugo <some-registry>/git-sync
``` ```
If you end up using a different registry, be sure to update `config/deployment.yaml`.
###
Create the pod and the service for the blog Create the pod and the service for the blog
``` ```
kubectl pods create config/pod.yaml kubectl create -f config
kubectl services create config/service.yaml
``` ```
Open the service external ip in your browser Open the service external ip in your browser

View File

@ -0,0 +1,57 @@
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: blog
labels:
name: blog
spec:
replicas: 1
selector:
matchLabels:
name: blog
template:
metadata:
labels:
name: blog
spec:
containers:
- name: git-sync
image: staging-k8s.gcr.io/git-sync-amd64:v2.0.6
imagePullPolicy: Always
volumeMounts:
- name: markdown
mountPath: /git
env:
- name: GIT_SYNC_REPO
value: https://github.com/kubernetes/git-sync.git
- name: GIT_SYNC_DEST
value: git-sync
- name: hugo
image: k8s.gcr.io/hugo
imagePullPolicy: Always
securityContext:
runAsUser: 0
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
ports:
- containerPort: 80
volumes:
- name: markdown
emptyDir: {}
- name: html
emptyDir: {}

View File

@ -1,48 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
labels:
name: blog
name: blog-pod
spec:
containers:
- name: git-sync
image: k8s.gcr.io/git-sync:v2.0.4
imagePullPolicy: Always
volumeMounts:
- name: markdown
mountPath: /git
env:
- name: GIT_SYNC_REPO
value: https://github.com/GoogleCloudPlatform/kubernetes.git
- name: GIT_SYNC_DEST
value: git
- name: hugo
image: k8s.gcr.io/hugo
imagePullPolicy: Always
securityContext:
runAsUser: 0
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
ports:
- containerPort: 80
volumes:
- name: markdown
emptyDir: {}
- name: html
emptyDir: {}