Skip to content

Instantly share code, notes, and snippets.

@ssttuu
Last active May 7, 2017 17:15
Show Gist options
  • Save ssttuu/e332b3271a5fd320f27fa8f2c40170d6 to your computer and use it in GitHub Desktop.
Save ssttuu/e332b3271a5fd320f27fa8f2c40170d6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
yaml2json='python -c "import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)"'
# Deploy Compute Service
service_response=$(gcloud service-management deploy compute.pb api_config.yaml --format json)
service_id=$(echo ${service_response} | jq '.serviceConfig.id')
service_name=$(echo ${service_response} | jq '.serviceConfig.name')
echo "Deployment: ${service_id} of ${service_name}"
# Evaluate jinja templated YAML file
compute_template_yaml=$(jinja2 k8s/compute.deployment.yaml -D id=${service_id} -D name=${service_name})
# Convert YAML to JSON
compute_template_json=$(echo "${compute_template_yaml}" | eval ${yaml2json})
# Create deployment using JSON configuration
k8_result=$(echo ${compute_template_json} | kubectl create -f -)
echo ${k8_result}
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: compute-esp
spec:
replicas: 1
template:
metadata:
labels:
app: compute-esp
spec:
containers:
- name: esp
image: gcr.io/endpoints-release/endpoints-runtime:1
args: [
"-P", "9000",
"-s", {{name}},
"-v", {{id}},
"-a", "grpc://127.0.0.1:8000"
]
ports:
- containerPort: 9000
- name: compute
image: gcr.io/qubit-161916/qubit-compute:latest
ports:
- containerPort: 8000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment