forked from ZcashFoundation/zebra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ncirc bootstrap (ZcashFoundation#44)
- Loading branch information
Showing
43 changed files
with
36,553 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Things are separate on the surface, shared deep down. | ||
|
||
## Separate | ||
|
||
### Ingress | ||
|
||
``` | ||
gcloud compute addresses create ncirc-test --global | ||
gcloud compute addresses create ncirc-stage --global | ||
gcloud compute addresses create ncirc-prod --global | ||
``` | ||
|
||
### Deployment manifests | ||
|
||
``` | ||
cd k8s/common/certmanager | ||
``` | ||
|
||
``` | ||
kubectl apply -f blank-secret.yaml -n test | ||
kubectl apply -f blank-secret.yaml -n stage | ||
kubectl apply -f blank-secret.yaml -n prod | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Inner Circles | ||
|
||
Exclusive stars. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
.../certmanager/lets-encrypt-production.yaml → k8s/free2z/issuer.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
load("@io_bazel_rules_k8s//k8s:objects.bzl", "k8s_objects") | ||
load("@k8s_deploy//:defaults.bzl", "k8s_deploy") | ||
load("@io_bazel_rules_docker//container:container.bzl", "container_image", "container_push") | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
k8s_deploy( | ||
name = "config", | ||
kind = "ConfigMap", | ||
substitutions = { | ||
# same namespace test/stage/prod as free2z | ||
"%{DBNAME}": "$(NAMESPACE)", | ||
}, | ||
template = "config.yaml", | ||
) | ||
|
||
k8s_deploy( | ||
name = "secret", | ||
kind = "Secret", | ||
template = ":secret.yaml", | ||
# Secret Manager secrets | ||
# https://console.cloud.google.com/security/secret-manager/secret/DBPASS/overview?project=free2z | ||
) | ||
|
||
container_image( | ||
name = "nginx", | ||
base = "@nginx//image", | ||
cmd = [ | ||
"nginx", | ||
"-g", | ||
"daemon off", | ||
], | ||
directory = "/base", | ||
files = [ | ||
"nginx.conf", | ||
], | ||
symlinks = { | ||
"/etc/nginx/conf.d/default.conf": "/base/nginx.conf", | ||
}, | ||
tars = [ | ||
"//py:ncirc-statictar", | ||
"//ts/react/ncirc:tar", | ||
], | ||
) | ||
|
||
k8s_deploy( | ||
name = "issuer", | ||
kind = "Issuer", | ||
template = "issuer.yaml", | ||
) | ||
|
||
k8s_deploy( | ||
name = "ingress", | ||
kind = "Ingress", | ||
substitutions = { | ||
"%{NAMESPACE}": "$(NAMESPACE)", | ||
"%{PREFIX}": "$(PREFIX)", | ||
}, | ||
template = "ingress.yaml", | ||
) | ||
|
||
k8s_deploy( | ||
name = "service", | ||
kind = "Service", | ||
substitutions = { | ||
}, | ||
template = "service.yaml", | ||
) | ||
|
||
k8s_deploy( | ||
name = "deployment", | ||
images = { | ||
"gcr.io/free2z/ncirc-nginx:latest": ":nginx", | ||
# TODO: could just be called "django" | ||
"gcr.io/free2z/free2z:latest": "//k8s/free2z:container", | ||
}, | ||
kind = "Deployment", | ||
substitutions = { | ||
"%{REPLICAS}": "3", | ||
}, | ||
template = ":deployment.yaml", | ||
) | ||
|
||
k8s_objects( | ||
name = "deploy-all", | ||
objects = [ | ||
# depends on ye' ol' commonproxy. should be moved out to common | ||
# "//k8s/free2z/sql-proxy:deployment", | ||
":config", | ||
":secret", | ||
":issuer", | ||
":ingress", | ||
":service", | ||
":deployment", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: ncirc | ||
data: | ||
DBHOST: sql-proxy-service | ||
DBNAME: "%{DBNAME}" | ||
DJANGO_SETTINGS_MODULE: "dj.ncirc.prod_settings" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: ncirc | ||
labels: | ||
app: ncirc | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: ncirc | ||
replicas: 3 | ||
strategy: | ||
type: RollingUpdate | ||
rollingUpdate: | ||
maxSurge: 50% | ||
maxUnavailable: 50% | ||
template: | ||
metadata: | ||
labels: | ||
app: ncirc | ||
spec: | ||
# uses free2z workload identity | ||
serviceAccountName: free2z-db | ||
containers: | ||
# NGINX FRONTEND | ||
- name: ncirc-nginx | ||
image: gcr.io/free2z/ncirc-nginx:latest | ||
resources: | ||
limits: | ||
memory: 50Mi | ||
requests: | ||
cpu: 50m | ||
memory: 25Mi | ||
args: ["nginx", "-g", "daemon off;"] | ||
ports: | ||
- containerPort: 8080 | ||
|
||
# DJANGO APP | ||
- name: ncirc-dj | ||
image: gcr.io/free2z/free2z:latest | ||
command: | ||
- "/usr/local/bin/daphne" | ||
- "-p" | ||
- "8000" | ||
- "dj.ncirc.asgi:application" | ||
resources: | ||
limits: | ||
cpu: 500m | ||
memory: 1200Mi | ||
requests: | ||
cpu: 10m | ||
memory: 100Mi | ||
envFrom: | ||
- configMapRef: | ||
name: ncirc | ||
- secretRef: | ||
name: ncirc | ||
ports: | ||
- containerPort: 8000 | ||
|
||
# https://cloud.google.com/sql/docs/postgres/connect-kubernetes-engine | ||
- name: cloud-sql-proxy | ||
# It is recommended to use the latest version of the Cloud SQL proxy | ||
# Make sure to update on a regular schedule! | ||
image: gcr.io/cloudsql-docker/gce-proxy:1.28.0 # make sure the use the latest version | ||
command: | ||
- "/cloud_sql_proxy" | ||
|
||
# If connecting from a VPC-native GKE cluster, you can use the | ||
# following flag to have the proxy connect over private IP | ||
# - "-ip_address_types=PRIVATE" | ||
|
||
# By default, the proxy will write all logs to stderr. In some | ||
# environments, anything printed to stderr is consider an error. To | ||
# disable this behavior and write all logs to stdout (except errors | ||
# which will still go to stderr), use: | ||
- "-log_debug_stdout" | ||
|
||
# Replace DB_PORT with the port the proxy should listen on | ||
# Defaults: MySQL: 3306, Postgres: 5432, SQLServer: 1433 | ||
- "-instances=free2z:us-east1:free2z=tcp:5432" | ||
securityContext: | ||
# The default Cloud SQL proxy image runs as the | ||
# "nonroot" user and group (uid: 65532) by default. | ||
runAsNonRoot: true |
Oops, something went wrong.