From 94c6c121cccdacddb4a121de4f0eb683996f16ef Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Mon, 1 Jun 2015 11:12:42 -0700 Subject: [PATCH 1/3] update contrib/git-sync/demo to v1beta3 --- contrib/git-sync/demo/config/pod.yaml | 91 +++++++++++------------ contrib/git-sync/demo/config/service.yaml | 16 ++-- 2 files changed, 53 insertions(+), 54 deletions(-) diff --git a/contrib/git-sync/demo/config/pod.yaml b/contrib/git-sync/demo/config/pod.yaml index 6e5326df7fc..72a3db7ae0f 100644 --- a/contrib/git-sync/demo/config/pod.yaml +++ b/contrib/git-sync/demo/config/pod.yaml @@ -1,50 +1,47 @@ -id: blog-pod +apiVersion: v1beta3 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/GoogleCloudPlatform/kubernetes.git - - name: GIT_SYNC_DEST - value: /git - volumeMounts: - - name: markdown - mountPath: /git - - name: hugo - image: proppy/hugo - imagePullPolicy: PullAlways - env: - - name: HUGO_SRC - value: /src/contrib/git-sync/demo/blog - - name: HUGO_BUILD_DRAFT - value: 'true' - - name: HUGO_BASE_URL - value: example.com - 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: +metadata: + labels: + name: blog + name: blog-pod +spec: + containers: + - name: git-sync + image: gcr.io/google_containers/git-sync + imagePullPolicy: Always + volumeMounts: - name: markdown - source: - emptyDir: {} + mountPath: /git + env: + - name: GIT_SYNC_REPO + value: https://github.com/GoogleCloudPlatform/kubernetes.git + - name: GIT_SYNC_DEST + value: /git + - name: hugo + image: gcr.io/google_containers/hugo + imagePullPolicy: Always + volumeMounts: + - name: markdown + mountPath: /src - name: html - source: - emptyDir: {} -labels: - name: blog + mountPath: /dest + env: + - name: HUGO_SRC + value: /src/contrib/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: + - name: http-server + containerPort: 80 + volumes: + - name: markdown + emptyDir: {} + - name: html + emptyDir: {} diff --git a/contrib/git-sync/demo/config/service.yaml b/contrib/git-sync/demo/config/service.yaml index 3f71fe78c2e..06215c0e21d 100644 --- a/contrib/git-sync/demo/config/service.yaml +++ b/contrib/git-sync/demo/config/service.yaml @@ -1,8 +1,10 @@ -id: blog-service +apiVersion: v1beta3 kind: Service -apiVersion: v1beta1 -port: 80 -containerPort: 80 -selector: - name: blog -createExternalLoadBalancer: true +metadata: + name: blog-service +spec: + createExternalLoadBalancer: true + ports: + - port: 80 + selector: + name: blog From 1f8404cb6a91855dbc3a07a197a87c6d34b26730 Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Mon, 1 Jun 2015 11:13:37 -0700 Subject: [PATCH 2/3] let the contrib/git-sync use a for-loop, rather than relying on the pod's restart policy, to periodically pull from the repo --- contrib/git-sync/main.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/contrib/git-sync/main.go b/contrib/git-sync/main.go index 201e7515cd7..0222ad27e16 100644 --- a/contrib/git-sync/main.go +++ b/contrib/git-sync/main.go @@ -66,12 +66,14 @@ func main() { if _, err := exec.LookPath("git"); err != nil { log.Fatalf("required git executable not found: %v", err) } - if err := syncRepo(*flRepo, *flDest, *flBranch, *flRev); err != nil { - log.Fatalf("error syncing repo: %v", err) + for { + if err := syncRepo(*flRepo, *flDest, *flBranch, *flRev); err != nil { + log.Fatalf("error syncing repo: %v", err) + } + log.Printf("wait %d seconds", *flWait) + time.Sleep(time.Duration(*flWait) * time.Second) + log.Println("done") } - log.Printf("wait %d seconds", *flWait) - time.Sleep(time.Duration(*flWait) * time.Second) - log.Println("done") } // syncRepo syncs the branch of a given repository to the destination at the given rev. From 28c1d7ac5b6d49be3fc1616329040902fe7a93e4 Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Mon, 1 Jun 2015 11:37:03 -0700 Subject: [PATCH 3/3] remove ports.name --- contrib/git-sync/demo/config/pod.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contrib/git-sync/demo/config/pod.yaml b/contrib/git-sync/demo/config/pod.yaml index 72a3db7ae0f..e8ccc720cfc 100644 --- a/contrib/git-sync/demo/config/pod.yaml +++ b/contrib/git-sync/demo/config/pod.yaml @@ -38,8 +38,7 @@ spec: - name: html mountPath: /usr/share/nginx/html ports: - - name: http-server - containerPort: 80 + - containerPort: 80 volumes: - name: markdown emptyDir: {}