- Google Cloud Platform (GCP) account.
- A project in the account (we're using
postal-165921
in our example commands).
- Set the defailt zone to use with our
gcloud
commands:gcloud config set compute/zone us-central1-a
gcloud config set container/cluster postal
- Navigate to https://console.cloud.google.com/ and create a new project for Postal (our example one will be called Postal and has an ID of
postal-165921
). - Navigate to the Container Engine section and create a new cluster called
postal
. The command we are using to create isgcloud container --project "postal-165921" clusters create "postal" --zone "us-central1-a" --machine-type "n1-standard-1" --image-type "COS" --disk-size "100" --scopes "https://www.googleapis.com/auth/compute","https://www.googleapis.com/auth/devstorage.read_only","https://www.googleapis.com/auth/logging.write","https://www.googleapis.com/auth/servicecontrol","https://www.googleapis.com/auth/service.management.readonly","https://www.googleapis.com/auth/trace.append" --num-nodes "3" --network "default" --enable-cloud-logging --no-enable-cloud-monitoring
- In a moment you should be able to run
gcloud container clusters get-credentials postal --zone us-central1-a --project postal-165921
to set up your localkubectl
credentials. - Create a MySQL 5.7 instance in the SQL console. Our example is called
postal
. - In IAM and Admin create a service account. Role will be SQL Client and check to Furnish new private key (JSON type). Save the key somewhere locally.
- Create the proxy user with
gcloud beta sql users create postal cloudsqlproxy~% --instance=postal --password=p0st4l
- Run
gcloud sql instances describe postal
to get the connectionName. Our example ispostal-165921:us-central1:postal
. kubectl create secret generic cloudsql-instance-credentials --from-file=credentials.json=/Users/andy/Documents/Postal-d609301cc404.json
kubectl create secret generic cloudsql-db-credentials --from-literal=username=postal --from-literal=password=p0st4l
- Create a
grants.sql
file with the following contents:
CREATE DATABASE `postal` CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
GRANT ALL ON `postal`.* TO `postal`@`cloudsqlproxy~%`;
GRANT ALL PRIVILEGES ON `postal-%` . * to `postal`@`cloudsqlproxy~%`;
- Create a new storage bucket and upload the
grants.sql
file to it. - Import this SQL file into the new
postal
database. - Enable Google Cloud SQL API at https://console.developers.google.com/apis/api/sqladmin.googleapis.com/overview?project=postal-165921&duration=PT1H.
- Create two external IP addresses (
mx1
andmx2
) for later use in SMTP load balancers.
- Generate a SSL certificate using
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout tls.key -out tls.crt -subj "/CN=postaldemo/O=postaldemo"
. kubectl create secret tls postal-tls --key tls.key --cert tls.crt
- Create your configuration map using
kubectl create configmap postal-config --from-file ~/.postal --dry-run -o yaml
. This assumes you already have the files from thepostal initialize-config
command living at~/.postal
.
We are using the domain postaldemo.com
for our demo. We are going to host it in GCP.
- Create the zone:
gcloud dns managed-zones create postaldemo --dns-name postaldemo.com --description "Postal demonstration domain"
. - Get the name servers to use at the registrar using
gcloud dns managed-zones describe postaldemo
and update your registrar name server records. - Set static IPs for MX1 and MX2 to the instances in the SMTP server pool:
gcloud compute addresses create mx1 mx2 --addresses $(gcloud compute instances list --filter='name:postal-smtp' --format='value[terminator=","](networkInterfaces[0].accessConfigs[0].natIP)')
- Create MX1:
gcloud dns record-sets transaction add --zone postaldemo --type A --name mx1.postaldemo.com. --ttl 300 $(gcloud compute addresses describe mx1 --format "value(address)")
. - Create MX2:
gcloud dns record-sets transaction add --zone postaldemo --type A --name mx2.postaldemo.com. --ttl 300 $(gcloud compute addresses describe mx2 --format "value(address)")
. - Create SMTP endpoint:
gcloud dns record-sets transaction add --zone postaldemo --type CNAME --name smtp.postaldemo.com. --ttl 300 $(gcloud compute addresses describe mx2 --format "value(address)") $(gcloud compute addresses describe mx1 --format "value(address)")
.
- Convert all the initial GCP stuff to Terraform.
- Use https://github.com/kubernetes-incubator/external-dns instead of manual DNS.
- Figure out if we can use a PersistentVolume in a job for read/write and then read-only in the pods (for assets). Currently using a gcePersistentDisk for this instead.
- How to add 443 as Ingress controllers frontend ports.