GeezerVison is showing github.com — Merge pull request #62 from wangxf123456/django-guestbook-template-all · msedebay-git/cloud-code-samples@19fac0d
File treeExpand file treeCollapse file tree Open diff view settings python/django/python-guestbook
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: python/django/python-guestbook/.idea/externalDependencies.xml +6Lines changed: 6 additions & 0 deletions Collapse file Copy file name to clipboard +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +{ | | 2 | + "recommendations": [ | | 3 | + "googlecloudtools.cloudcode", | | 4 | + ] | | 5 | +} |
Collapse file Copy file name to clipboard +21Lines changed: 21 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +// launch.json contains information needed for the debugger to attach to processes | | 2 | +// See https://code.visualstudio.com/Docs/editor/debugging#_launch-configurations | | 3 | +// for documentation about how to create and manage configurations | | 4 | +{ | | 5 | + "version": "0.2.0", | | 6 | + "configurations": [ | | 7 | + { | | 8 | + "podSelector": { | | 9 | + "app": "python-guestbook", | | 10 | + "tier": "app" | | 11 | + }, | | 12 | + "type": "cloudcode", | | 13 | + "request": "attach", | | 14 | + "localRoot": "${workspaceFolder}/src", | | 15 | + "language": "Python", | | 16 | + "remoteRoot": "/app", | | 17 | + "name": "Debug on Kubernetes", | | 18 | + "debugPort": 8080 | | 19 | + } | | 20 | + ] | | 21 | +} |
Collapse file Copy file name to clipboard +15Lines changed: 15 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | + // tasks.josn defines quick commands that cam be launched in Visual Studio Code | | 2 | + // See https://go.microsoft.com/fwlink/?LinkId=733558 | | 3 | + // for the documentation about the tasks.json format | | 4 | +{ | | 5 | + "version": "2.0.0", | | 6 | + "tasks": [ | | 7 | + { | | 8 | + "label": "Pylint", | | 9 | + "type": "shell", | | 10 | + "command": "python3", | | 11 | + "args": ["-m", "pylint", "src/**/*.py"], | | 12 | + "problemMatcher": [] | | 13 | + } | | 14 | + ] | | 15 | +} |
Collapse file Copy file name to clipboard +41Lines changed: 41 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +apiVersion: extensions/v1beta1 | | 2 | +kind: Deployment | | 3 | +metadata: | | 4 | + name: python-guestbook-app | | 5 | + labels: | | 6 | + app: python-guestbook | | 7 | + tier: app | | 8 | +spec: | | 9 | + replicas: 1 | | 10 | + selector: | | 11 | + matchLabels: | | 12 | + app: python-guestbook | | 13 | + tier: app | | 14 | + template: | | 15 | + metadata: | | 16 | + labels: | | 17 | + app: python-guestbook | | 18 | + tier: app | | 19 | + spec: | | 20 | + initContainers: | | 21 | + # Wait for the database to get ready before starting the server, otherwise | | 22 | + # the server will crash | | 23 | + - name: check-db-ready | | 24 | + image: postgres | | 25 | + command: ['sh', '-c', | | 26 | + 'until pg_isready -h python-guestbook-db.default.svc.cluster.local -p 5432; | | 27 | + do echo waiting for database; sleep 2; done;'] | | 28 | + containers: | | 29 | + - name: python-guestbook | | 30 | + image: python-guestbook | | 31 | + ports: | | 32 | + - containerPort: 8080 | | 33 | + env: | | 34 | + - name: DATABASE_NAME | | 35 | + value: "postgres" | | 36 | + - name: DATABASE_USER | | 37 | + value: "postgres" | | 38 | + - name: DATABASE_HOST | | 39 | + value: "python-guestbook-db" | | 40 | + - name: DATABASE_PORT | | 41 | + value: "5432" |
Collapse file Copy file name to clipboard +34Lines changed: 34 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +# This file creates a job that migrates the Postgres database. The job creates a | | 2 | +# pod from the specified Docker image, wait for the database to get ready, and | | 3 | +# run database migration once the Postgres database service is ready to receive | | 4 | +# connections. | | 5 | +apiVersion: batch/v1 | | 6 | +kind: Job | | 7 | +metadata: | | 8 | + name: python-guestbook-migration | | 9 | +spec: | | 10 | + template: | | 11 | + metadata: | | 12 | + name: python-guestbook-migration | | 13 | + spec: | | 14 | + initContainers: | | 15 | + # Wait for the database to get ready before doing migration | | 16 | + - name: check-db-ready | | 17 | + image: postgres | | 18 | + command: ['sh', '-c', | | 19 | + 'until pg_isready -h python-guestbook-db.default.svc.cluster.local -p 5432; | | 20 | + do echo waiting for database; sleep 2; done;'] | | 21 | + containers: | | 22 | + - name: python-guestbook-migration | | 23 | + image: python-guestbook | | 24 | + command: [ "/bin/sh", "-c", "python manage.py migrate" ] | | 25 | + env: | | 26 | + - name: DATABASE_NAME | | 27 | + value: "postgres" | | 28 | + - name: DATABASE_USER | | 29 | + value: "postgres" | | 30 | + - name: DATABASE_HOST | | 31 | + value: "python-guestbook-db" | | 32 | + - name: DATABASE_PORT | | 33 | + value: "5432" | | 34 | + restartPolicy: OnFailure |
Collapse file Copy file name to clipboard +15Lines changed: 15 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +apiVersion: v1 | | 2 | +kind: Service | | 3 | +metadata: | | 4 | + name: python-guestbook-app | | 5 | + labels: | | 6 | + app: python-guestbook | | 7 | + tier: app | | 8 | +spec: | | 9 | + type: LoadBalancer | | 10 | + ports: | | 11 | + - port: 80 | | 12 | + targetPort: 8080 | | 13 | + selector: | | 14 | + app: python-guestbook | | 15 | + tier: app |
Collapse file Copy file name to clipboard +30Lines changed: 30 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +################################################################################ | | 2 | +# WARNING: These settings are used for educational purposes only. This Postgres | | 3 | +# database deployment is not suitable for production as the data is not | | 4 | +# persistently stored and will go away every time the Pod restarts. Consider | | 5 | +# using a Helm chart that provisions a StatefulSet instead of Deployment. | | 6 | +################################################################################ | | 7 | +apiVersion: apps/v1 | | 8 | +kind: Deployment | | 9 | +metadata: | | 10 | + name: python-guestbook-db | | 11 | + labels: | | 12 | + app: python-guestbook | | 13 | + tier: db | | 14 | +spec: | | 15 | + replicas: 1 | | 16 | + selector: | | 17 | + matchLabels: | | 18 | + app: python-guestbook | | 19 | + tier: db | | 20 | + template: | | 21 | + metadata: | | 22 | + labels: | | 23 | + app: python-guestbook | | 24 | + tier: db | | 25 | + spec: | | 26 | + containers: | | 27 | + - image: postgres:9.6 | | 28 | + name: db | | 29 | + ports: | | 30 | + - containerPort: 5432 |
Collapse file Copy file name to clipboard +15Lines changed: 15 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +apiVersion: v1 | | 2 | +kind: Service | | 3 | +metadata: | | 4 | + name: python-guestbook-db | | 5 | + labels: | | 6 | + app: python-guestbook | | 7 | + tier: db | | 8 | +spec: | | 9 | + type: ClusterIP | | 10 | + ports: | | 11 | + - port: 5432 | | 12 | + targetPort: 5432 | | 13 | + selector: | | 14 | + app: python-guestbook | | 15 | + tier: db |
Collapse file Copy file name to clipboard +19Lines changed: 19 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +apiVersion: skaffold/v1beta11 | | 2 | +kind: Config | | 3 | +build: | | 4 | + tagPolicy: | | 5 | + sha256: {} | | 6 | + # defines where to find the code at build time and where to push the resulting image | | 7 | + artifacts: | | 8 | + - context: src | | 9 | + image: python-guestbook | | 10 | +# defines the Kubernetes manifests to deploy on each run | | 11 | +deploy: | | 12 | + kubectl: | | 13 | + manifests: | | 14 | + - kubernetes-manifests/**.yaml | | 15 | +profiles: | | 16 | +# use the cloudbuild profile to build images using Google Cloud Build | | 17 | +- name: cloudbuild | | 18 | + build: | | 19 | + googleCloudBuild: {} |
|