Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
Install Hipstershop as demo app
Browse files Browse the repository at this point in the history
Also:
* Pinning the terraform-google-kubernetes-engine module to 6.2.0
  due to breaking change: terraform-google-modules/terraform-google-kubernetes-engine#257
* Cleaning buckets before removing them (TF fails otherwise)

Fixes: http://b/148036307

Change-Id: Icde3335ee8690190ac87c46a9cbde265f263e84c
  • Loading branch information
MrTrustor committed Jan 28, 2020
1 parent 5248f77 commit 5c1360d
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 5 deletions.
8 changes: 4 additions & 4 deletions 1_clusters/clusters.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ data "google_compute_subnetwork" "anthos-platform-east" {
}

module "anthos-platform-prod-central" {
source = "github.com/terraform-google-modules/terraform-google-kubernetes-engine"
source = "github.com/terraform-google-modules/terraform-google-kubernetes-engine?ref=v6.2.0"
project_id = "${var.project_id}"
name = "prod-us-central1"
regional = true
Expand All @@ -36,7 +36,7 @@ module "anthos-platform-prod-central" {
}

module "anthos-platform-prod-east" {
source = "github.com/terraform-google-modules/terraform-google-kubernetes-engine"
source = "github.com/terraform-google-modules/terraform-google-kubernetes-engine?ref=v6.2.0"
project_id = "${var.project_id}"
name = "prod-us-east1"
regional = true
Expand All @@ -51,7 +51,7 @@ module "anthos-platform-prod-east" {
}

module "anthos-platform-staging" {
source = "github.com/terraform-google-modules/terraform-google-kubernetes-engine"
source = "github.com/terraform-google-modules/terraform-google-kubernetes-engine?ref=v6.2.0"
project_id = "${var.project_id}"
name = "staging-us-central1"
regional = true
Expand All @@ -67,7 +67,7 @@ module "anthos-platform-staging" {


module "anthos-platform-dev" {
source = "github.com/terraform-google-modules/terraform-google-kubernetes-engine"
source = "github.com/terraform-google-modules/terraform-google-kubernetes-engine?ref=v6.2.0"
project_id = "${var.project_id}"
name = "dev-us-central1"
regional = true
Expand Down
36 changes: 36 additions & 0 deletions 4_microservices-demo/install-microservices-demo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash -xe

if [ -z ${GITLAB_HOSTNAME} ];then
read -p "What is the GitLab hostname (i.e. my.gitlab.server)? " GITLAB_HOSTNAME
fi

if [ -z ${GITLAB_TOKEN} ];then
read -p "What is the GitLab token? " GITLAB_TOKEN
fi

wget -O anthos-platform-cli https://storage.googleapis.com/solutions-public-assets/anthos-platform-cli/v0.4.0/anthos-platform-cli-v0.4.0-linux-amd64
chmod +x anthos-platform-cli

./anthos-platform-cli add app --name microservices-demo --gitlab-hostname ${GITLAB_HOSTNAME} \
--gitlab-token ${GITLAB_TOKEN} --template-name golang-template

git clone https://root:${GITLAB_TOKEN}@${GITLAB_HOSTNAME}/microservices-demo/microservices-demo.git microservices-demo-clone
cd microservices-demo-clone
git rm -r Dockerfile main.go skaffold.yaml k8s
mkdir hydrated-manifests
curl -o hydrated-manifests/stg.yaml https://raw.githubusercontent.com/GoogleCloudPlatform/microservices-demo/master/release/kubernetes-manifests.yaml
# workaround for b/148377817 -- gke-deploy doesn't like a yaml file finishing with "---"
sed -i '$ d' hydrated-manifests/stg.yaml
cp hydrated-manifests/stg.yaml hydrated-manifests/prod.yaml
cat <<EOF >.gitlab-ci.yml
include:
- project: 'platform-admins/shared-ci-cd'
file: 'cd/push-manifests.yaml'
stages:
- push-manifests
EOF
git add .
git commit -m "Removing template and adding microservices-demo app"
git push
cd ..
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ For a user guide on what to do after the install, please go to:
curl -o claim.sh https://cloud-tutorial.dev/claim.sh
chmod +x claim.sh
./claim.sh ${SUBDOMAIN}
rm claim.sh
```

1. Map your gitlab address above to your domain.
Expand All @@ -67,7 +68,7 @@ For a user guide on what to do after the install, please go to:
gcloud dns record-sets transaction execute --zone ${SUBDOMAIN}-zone
```

1. Run Cloud Build to create the necessary resources.
1. Run Cloud Build to create the necessary resources. This takes around 30 minutes.

```shell
export DOMAIN=${SUBDOMAIN}.cloud-tutorial.dev
Expand All @@ -84,6 +85,9 @@ At this stage, you should have a working ACM installation good enough for most
demos. If you want to follow production best practices, read
[Best practices for policy management with Anthos Config Management and GitLab](https://cloud.google.com/solutions/best-practices-for-policy-management-with-anthos-config-management).

Always leave at least one namespace defined in `namespaces/managed-apps`, otherwise ACM will
stop syncing.

## Contributing

To contribute follows these instrcutions for the development flow:
Expand Down
7 changes: 7 additions & 0 deletions cloudbuild-destroy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ steps:
sed -i "s/YOUR_PROJECT_ID/${PROJECT_ID}/g" 0_foundation/terraform.tfvars
sed -i "s/YOUR_PROJECT_ID/${PROJECT_ID}/g" 1_clusters/terraform.tfvars
sed -i "s/YOUR_PROJECT_ID/${PROJECT_ID}/g" 2_gitlab/terraform.tfvars
- name: gcr.io/cloud-builders/gsutil
id: 'clean-buckets'
entrypoint: 'bash'
args:
- -c
- |
gsutil -m rm gs://${PROJECT_ID}-gitlab-artifacts/** gs://${PROJECT_ID}-registry/** || exit 0
- name: 'gcr.io/${PROJECT_ID}/anthos-platform-installer'
id: 'destroy-gitlab'
entrypoint: 'bash'
Expand Down
5 changes: 5 additions & 0 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ steps:
./install_acm.sh
cd ..
# Install microservices-demo
cd 4_microservices-demo
./install-microservices-demo.sh
cd ..
# Output final notes
echo -e "\e[32mLog in to your GitLab instance at: https://gitlab.${_DOMAIN}"
echo -e "\e[32mUsername: root"
Expand Down
8 changes: 8 additions & 0 deletions starter-repos/anthos-config-management/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@ to manage to test ACM's configuration.
a ConfigMap for each of your clusters, with the right cluster selection
annotation, and the right GitLab Runner tag.
1. In `.gitlab-ci.yml`, add a job for each cluster, modifying the tag each time.

### Restrictions

The `namespaces/managed-apps` directory is an [abstract namespace directory](https://cloud.google.com/anthos-config-management/docs/concepts/namespace-inheritance).
This means that all the resources defined in this directory are inherited by
the namespaces that are defined within that directory. `managed-apps` is *not*
a real directory. You need to define at least one real namespace within this
directory for ACM to work.

0 comments on commit 5c1360d

Please sign in to comment.