Skip to content

Commit

Permalink
Fix and update lots of stuff
Browse files Browse the repository at this point in the history
- Use D2 for README diagram
- Packer HCL templates
- Use newer Ubuntu
- Consul and Nomad updates
  • Loading branch information
picatz committed Sep 10, 2023
1 parent f3eae7f commit c0b17ec
Show file tree
Hide file tree
Showing 21 changed files with 593 additions and 371 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,20 @@ help:
@echo 'Targets:'
@egrep '^(.+)\:\ ##\ (.+)' $(MAKEFILE_LIST) | column -t -c 2 -s ':#'

.PHONY: packer/init
packer/init: ## Initializes the Packer config
@cd packer && packer init template.pkr.hcl

.PHONY: packer/validate
packer/validate: ## Validates the Packer config
@cd packer && packer validate template.json
@cd packer && packer validate template.pkr.hcl

.PHONY: packer/build
packer/build: ## Forces a build with Packer
@cd packer && time packer build \
-force \
-timestamp-ui \
template.json
template.pkr.hcl

.PHONY: terraform/validate
terraform/validate: ## Validates the Terraform config
Expand Down
45 changes: 1 addition & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,53 +20,10 @@ For a full interactive tutorial to get started using this module:

[![Open in Cloud Shell](https://gstatic.com/cloudssh/images/open-btn.svg)](https://ssh.cloud.google.com/cloudshell/editor?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fpicatz%2Fterraform-google-nomad&cloudshell_print=cloud-shell%2Fprint.txt&cloudshell_tutorial=cloud-shell%2Fsteps.md&shellonly=true)

<details><summary>Manual Steps for Development</summary>
<p>

## Bootstrap a brand new GCP project using [`gcloud`](https://cloud.google.com/sdk/gcloud)

Bootstrap a new GCP using the `setup_gcp.sh` shell script:

```console
$ bash setup_gcp.sh $YOUR_PROJECT_NAME
...
```

It will automatically create, link the billing account, and enable the compute API in GCP.

### Set Environment Variables

Using your GCP project name and new created `account.json` Terraform service account file from the previous step:

```console
$ export GOOGLE_APPLICATION_CREDENTIALS=$(realpath account.json)
$ export GOOGLE_PROJECT="$YOUR_PROJECT_NAME"
```

## Build the Bastion/Server/Client Images with Packer

```console
$ cd packer
$ packer build template.json
...
```

## Build Infrastructure

```console
$ terraform plan -var="project=$GOOGLE_PROJECT" -var="credentials=$GOOGLE_APPLICATION_CREDENTIALS"
...
$ terraform apply -var="project=$GOOGLE_PROJECT" -var="credentials=$GOOGLE_APPLICATION_CREDENTIALS"
...
```

</p>
</details>

## Infrastructure Diagram

<p align="center">
<img alt="Infrastructure Diagram" src="https://raw.githubusercontent.com/picatz/terraform-google-nomad/master/diagram.png" height="700"/>
<img alt="Infrastructure Diagram" src="./diagrams/readme.svg" height="900"/>
</p>

## Logs
Expand Down
Binary file removed diagram.png
Binary file not shown.
141 changes: 141 additions & 0 deletions diagrams/readme.d2
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
admin -> deploy -> cloud

cloud.org.project.vpc.lb -> cloud.org.project.vpc.subnet.cluster

admin: "Administrator" {
style: {
fill: "#ffffff"
stroke: grey
border-radius: 4
}
terraform: "" {
shape: image
icon: https://www.svgrepo.com/show/408174/woman-technologist-medium-dark-skin-tone.svg
}
}

deploy: "Deploy" {
style: {
fill: "#ffffff"
stroke: grey
border-radius: 4
}
terraform: "" {
shape: image
icon: https://www.svgrepo.com/show/376353/terraform.svg
}
}

cloud: "Google Cloud Platform" {
direction: down
icon: https://www.svgrepo.com/show/353805/google-cloud.svg
icon.near: top-right
style: {
fill: "#ffffff"
stroke: grey
border-radius: 4
}
org: "Organization" {
project: "Project" {
vpc: "VPC" {
lb: "Load Balancer"
subnet: "Subnet" {
cluster: "Nomad Cluster" {
label.near: top-center
icon: https://www.svgrepo.com/show/448241/nomad.svg
icon.near: top-right

servers: "Servers" {
a: "Server A" {
agent: "" {
shape: image
width: 100
icon: https://www.svgrepo.com/show/448241/nomad.svg
}
icon: https://www.svgrepo.com/show/448216/consul.svg
icon.near: bottom-right
}
b: "Server B" {
agent: "" {
shape: image
width: 100
icon: https://www.svgrepo.com/show/448241/nomad.svg
}
icon: https://www.svgrepo.com/show/448216/consul.svg
icon.near: bottom-right
}
c: "Server C" {
agent: "" {
shape: image
width: 100
icon: https://www.svgrepo.com/show/448241/nomad.svg
}
icon: https://www.svgrepo.com/show/448216/consul.svg
icon.near: bottom-right
}
direction: right
}
clients: "Clients" {
a: "Client A" {
agent: "" {
shape: image
width: 100
icon: https://www.svgrepo.com/show/448241/nomad.svg
}
icon: https://www.svgrepo.com/show/448216/consul.svg
icon.near: bottom-right
}
b: "Client B" {
agent: "" {
shape: image
width: 100
icon: https://www.svgrepo.com/show/448241/nomad.svg
}
icon: https://www.svgrepo.com/show/448216/consul.svg
icon.near: bottom-right
}
c: "Client C" {
agent: "" {
shape: image
width: 100
icon: https://www.svgrepo.com/show/448241/nomad.svg
}
icon: https://www.svgrepo.com/show/448216/consul.svg
icon.near: bottom-right
}
d: "Client D" {
agent: "" {
shape: image
width: 100
icon: https://www.svgrepo.com/show/448241/nomad.svg
}
icon: https://www.svgrepo.com/show/448216/consul.svg
icon.near: bottom-right
}
e: "Client E" {
agent: "" {
shape: image
width: 100
icon: https://www.svgrepo.com/show/448241/nomad.svg
}
icon: https://www.svgrepo.com/show/448216/consul.svg
icon.near: bottom-right
}
e: "Client F" {
agent: "" {
shape: image
width: 100
icon: https://www.svgrepo.com/show/448241/nomad.svg
}
icon: https://www.svgrepo.com/show/448216/consul.svg
icon.near: bottom-right
}
}

servers <-> clients
}
}
}
}
}
}
Loading

0 comments on commit c0b17ec

Please sign in to comment.