From 3ddaa4bf725a3edd41b29ef3b521772b7c730247 Mon Sep 17 00:00:00 2001 From: Bo Xu Date: Mon, 14 Jun 2021 16:41:35 -0700 Subject: [PATCH] Create a dev mixer instance (#536) * Create a dev mixer instance * copyright year * gitignore --- .gitignore | 1 + deploy/gke/dev.yaml | 23 ++++++++ deploy/overlays/dev/kustomization.yaml | 44 +++++++-------- deploy/overlays/local/kustomization.yaml | 53 +++++++++++++++++++ .../{dev => local}/patch_deployment.yaml | 14 +++++ deploy/overlays/{dev => local}/patch_esp.yaml | 0 .../{dev => local}/serviceaccount.yaml | 0 scripts/deploy_gke.sh | 8 +-- skaffold.yaml | 4 +- 9 files changed, 117 insertions(+), 30 deletions(-) create mode 100644 deploy/gke/dev.yaml create mode 100644 deploy/overlays/local/kustomization.yaml rename deploy/overlays/{dev => local}/patch_deployment.yaml (82%) rename deploy/overlays/{dev => local}/patch_esp.yaml (100%) rename deploy/overlays/{dev => local}/serviceaccount.yaml (100%) diff --git a/.gitignore b/.gitignore index 4c79aab61..284edf1d6 100644 --- a/.gitignore +++ b/.gitignore @@ -55,5 +55,6 @@ deploy/overlays/prod/prod.yaml deploy/overlays/staging/staging.yaml deploy/overlays/autopush/autopush.yaml deploy/overlays/encode/encode.yaml +deploy/overlays/dev/dev.yaml deploy/git/mixer_hash.txt \ No newline at end of file diff --git a/deploy/gke/dev.yaml b/deploy/gke/dev.yaml new file mode 100644 index 000000000..af45f7ad6 --- /dev/null +++ b/deploy/gke/dev.yaml @@ -0,0 +1,23 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Dev Mixer GKE params + +project: datcom-mixer-dev-316822 +region: us-central1 +ip: 35.244.157.41 +domain: dev.api.datacommons.org +api_title: DataCommons API (Dev) +nodes: 1 +store: datcom-store diff --git a/deploy/overlays/dev/kustomization.yaml b/deploy/overlays/dev/kustomization.yaml index e89398a09..a14cccef8 100644 --- a/deploy/overlays/dev/kustomization.yaml +++ b/deploy/overlays/dev/kustomization.yaml @@ -12,42 +12,38 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Kustomization for dev mixer in local Minikube environment. -# - Adds "dev" suffix to all the resources -# - Use "serviceaccount.yaml" to create service account explicitly. -# Note the GKE cluster service account is created once at cluster creation time. -# - Patch deployment with "api-compiler" image that can updates the gRPC config on code change. -# - Update the esp startup options for local container. +# Kustomization for dev mixer running on GCP `datcom-mixer-dev` project. +# - Adds "dev" suffix to all the resources. +# - Use replica of 8. apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization nameSuffix: -dev -namespace: mixer - -bases: - - ../../datacommons resources: - - serviceaccount.yaml + - ../../datacommons configMapGenerator: - name: mixer-configmap behavior: create + namespace: mixer literals: - - mixerProject=datcom-mixer-dev - - serviceName= - -generatorOptions: - disableNameSuffixHash: true + - mixerProject=datcom-mixer-dev-316822 + - serviceName=dev.api.datacommons.org patchesStrategicMerge: - - patch_deployment.yaml - -patchesJson6902: - - target: - group: apps - version: v1 - kind: Deployment + - |- + apiVersion: apps/v1 + kind: Deployment + metadata: name: mixer-grpc - path: patch_esp.yaml + spec: + replicas: 8 + - |- + apiVersion: extensions/v1beta1 + kind: Ingress + metadata: + name: mixer-ingress + annotations: + ingress.gcp.kubernetes.io/pre-shared-cert: mixer-certificate diff --git a/deploy/overlays/local/kustomization.yaml b/deploy/overlays/local/kustomization.yaml new file mode 100644 index 000000000..20bbb11a7 --- /dev/null +++ b/deploy/overlays/local/kustomization.yaml @@ -0,0 +1,53 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Kustomization for local mixer in local Minikube environment. +# - Adds "local" suffix to all the resources +# - Use "serviceaccount.yaml" to create service account explicitly. +# Note the GKE cluster service account is created once at cluster creation time. +# - Patch deployment with "api-compiler" image that can updates the gRPC config on code change. +# - Update the esp startup options for local container. + +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +nameSuffix: -local +namespace: mixer + +bases: + - ../../datacommons + +resources: + - serviceaccount.yaml + +configMapGenerator: + - name: mixer-configmap + behavior: create + literals: + - mixerProject=datcom-mixer-dev-316822 + - serviceName= + +generatorOptions: + disableNameSuffixHash: true + +patchesStrategicMerge: + - patch_deployment.yaml + +patchesJson6902: + - target: + group: apps + version: v1 + kind: Deployment + name: mixer-grpc + path: patch_esp.yaml diff --git a/deploy/overlays/dev/patch_deployment.yaml b/deploy/overlays/local/patch_deployment.yaml similarity index 82% rename from deploy/overlays/dev/patch_deployment.yaml rename to deploy/overlays/local/patch_deployment.yaml index e18e4c675..b76199b84 100644 --- a/deploy/overlays/dev/patch_deployment.yaml +++ b/deploy/overlays/local/patch_deployment.yaml @@ -29,10 +29,24 @@ spec: - name: mixer image: datacommons/mixer imagePullPolicy: Never + resources: + limits: + memory: "3G" + cpu: "800m" + requests: + memory: "3G" + cpu: "800m" - name: esp volumeMounts: - mountPath: /esp name: mixer-grpc-json + resources: + limits: + memory: "1G" + cpu: "200m" + requests: + memory: "1G" + cpu: "200m" - name: api-compiler image: datacommons/api-compiler imagePullPolicy: Never diff --git a/deploy/overlays/dev/patch_esp.yaml b/deploy/overlays/local/patch_esp.yaml similarity index 100% rename from deploy/overlays/dev/patch_esp.yaml rename to deploy/overlays/local/patch_esp.yaml diff --git a/deploy/overlays/dev/serviceaccount.yaml b/deploy/overlays/local/serviceaccount.yaml similarity index 100% rename from deploy/overlays/dev/serviceaccount.yaml rename to deploy/overlays/local/serviceaccount.yaml diff --git a/scripts/deploy_gke.sh b/scripts/deploy_gke.sh index 128391948..9fba4fd20 100755 --- a/scripts/deploy_gke.sh +++ b/scripts/deploy_gke.sh @@ -18,9 +18,9 @@ # # Usage: # -# ./deploy_key.sh <"prod"|"staging"|"autopush"|"encode"> +# ./deploy_key.sh <"prod"|"staging"|"autopush"|"encode"|"dev"> # -# First argument is either "prod" or "staging" or "autopush" or "encode". +# First argument is either "prod" or "staging" or "autopush" or "encode" or "dev". # (Optional) second argument is the git commit hash of the mixer repo. # # !!! WARNING: Run this script in a clean Git checkout at the desired commit. @@ -33,8 +33,8 @@ set -e ENV=$1 -if [[ $ENV != "staging" && $ENV != "prod" && $ENV != "autopush" && $ENV != "encode" ]]; then - echo "First argument should be 'staging' or 'prod' 'autopush' or 'encode'" +if [[ $ENV != "staging" && $ENV != "prod" && $ENV != "autopush" && $ENV != "encode" && $ENV != "dev" ]]; then + echo "First argument should be 'staging' or 'prod' or 'autopush' or 'encode' or 'dev'" exit fi diff --git a/skaffold.yaml b/skaffold.yaml index a35584cea..98036bf31 100644 --- a/skaffold.yaml +++ b/skaffold.yaml @@ -38,10 +38,10 @@ deploy: kubeContext: minikube kustomize: paths: - - deploy/overlays/dev + - deploy/overlays/local portForward: - resourceType: service - resourceName: mixer-service-dev + resourceName: mixer-service-local namespace: mixer port: 80 localPort: 9090