This experimentation is a WIP...
Some things are GKE-specific.
-
There's a simple grails CRUD app that works on the MongoDB database. More capabilities will be added to this as time goes on to test Elasticsearch, etc.
-
All data sources are derived from Helm charts and live under the
./helm
directory. See helm-chart-basics. Here are the charts:
Ensure the following dependencies are already fulfilled on your host Linux/Windows/Mac Workstation/Laptop:
-
An account has been registered with the Google Compute Platform (GCP). You can sign up to a free trial for GCP. Note: The free trial places some restrictions on account resource quotas, in particular restricting storage to a maximum of 100GB.
-
GCP’s client command line tool gcloud has been installed.
-
Your local workstation has been initialised to:
- use your GCP account,
- install the Kubernetes command tool (“kubectl”),
- configure authentication credentials, and
- set the default GCP zone to be deployed to:
$ gcloud init $ gcloud components install kubectl $ gcloud auth application-default login $ gcloud config set compute/zone europe-west1-b
Note: To specify an alternative zone to deploy to, in the above command, you can first view the list of available zones by running the command: $ gcloud compute zones list
- Make sure Kubernetes API is enabled in Google cloud console
- To create a 3-node, auto-scaling (9 max) cluster, run:
gcloud container clusters create css-sandbox \ --zone=us-central1-a \ --enable-autorepair \ --enable-autoupgrade \ --machine-type=n1-standard-2 \ --enable-autoscaling --min-nodes=3 --max-nodes=9
- Deploy MongoDB, Elasticsearch, Redis HA, ...
- See Helm manifests
- Deploy App (this is for test app but steps are pretty much the same for any)
- In the grails-crud test app...
./gradlew build
./gradlew prepareDocker
docker build -t grails-crud ./build/docker
docker tag grails-crud gcr.io/<GCP-projectID>/grails-crud:1.4
(change theimage
name:version in k8s/grails-crud.yaml to match)docker push gcr.io/<GCP-projectID>/grails-crud:1.4
(push image to GCR)kubectl apply -f k8s/grails-crud.yaml
(deploy. pulls image from GCR.)kubectl get pods
(should see something like):
NAME READY STATUS RESTARTS AGE grails-crud-666b6794c5-mgl8m 1/1 Running 0 6s mongo-0 1/1 Running 0 1h mongo-1 1/1 Running 0 1h mongo-2 1/1 Running 0 1h
- See grails-crud for K8s testing.
This step is not needed for this example.
Whenever downloading a private key, put it in a safe place. By all means do NOT add it to source control.
To create and download a gcloud private key file if you DON'T already have a service account:
-
Go to the Google Cloud Platform / IAM & admin / Service Accounts page.
-
Choose
+ Create Service Account
-
In the resulting dialog, give it a name (for example,
<project-name>-admin-service-account
) -
Leave the
Service account ID
-
Select the required roles for creating and modifying a Kubernetes cluster:
- Compute Engine / Compute Admin
- Kubernetes Engine / Kubernetes Engine Admin
- Storage / Storage Admin
- Service Accounts / Service Account User
-
Check the box that says
Furnish a new private key
-
Select
Create
-
The key is downloaded to your computer.
-
Store the key file in a safe and accessible place. Do not check it in to source control.
To create and download a gcloud private key file if you DO already have a service account:
-
Go to the Google Cloud Platform / IAM & admin / Service Accounts page.
-
Choose your service account by selecting the ellipses (three dots) on its right.
-
Select
Create Key
-
Leave Key type as JSON
-
Select
Create
-
The key is downloaded to your computer.
-
Store the key file in a safe and accessible place. Do not check it in to source control.
- e.g.,
${HOME}/.k8sconfig/<name>.json
.
- e.g.,