From 94c7154683f7cd3bcfcb3e12ce33365cbba6d970 Mon Sep 17 00:00:00 2001 From: mattjmcnaughton Date: Thu, 31 May 2018 22:33:16 -0400 Subject: [PATCH] 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. --- demo/README.md | 9 ++++-- demo/config/deployment.yaml | 57 +++++++++++++++++++++++++++++++++++++ demo/config/pod.yaml | 48 ------------------------------- 3 files changed, 64 insertions(+), 50 deletions(-) create mode 100644 demo/config/deployment.yaml delete mode 100644 demo/config/pod.yaml diff --git a/demo/README.md b/demo/README.md index 59c67c1..e628b2c 100644 --- a/demo/README.md +++ b/demo/README.md @@ -12,6 +12,8 @@ The pod is composed of 3 containers that share directories using 2 volumes: ## Usage +### Build demo containers (Optional) + Build the demo containers, and push them to a registry ``` @@ -20,11 +22,14 @@ docker build -t /hugo hugo/ docker push /hugo /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 ``` -kubectl pods create config/pod.yaml -kubectl services create config/service.yaml +kubectl create -f config ``` Open the service external ip in your browser diff --git a/demo/config/deployment.yaml b/demo/config/deployment.yaml new file mode 100644 index 0000000..a9958df --- /dev/null +++ b/demo/config/deployment.yaml @@ -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: {} diff --git a/demo/config/pod.yaml b/demo/config/pod.yaml deleted file mode 100644 index 1daafe2..0000000 --- a/demo/config/pod.yaml +++ /dev/null @@ -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: {}