-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bryan Dollery
committed
Sep 15, 2020
1 parent
fc18847
commit 62795fb
Showing
5 changed files
with
426 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: frontend | ||
labels: | ||
app: frontend | ||
spec: | ||
type: ClusterIP | ||
ports: | ||
- port: 80 | ||
targetPort: 80 | ||
selector: | ||
app: frontend | ||
--- | ||
|
||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: frontend | ||
automountServiceAccountToken: true | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: nginx-configmap | ||
data: | ||
config: | | ||
# /etc/nginx/conf.d/default.conf | ||
server { | ||
listen 80; | ||
server_name localhost; | ||
#charset koi8-r; | ||
#access_log /var/log/nginx/host.access.log main; | ||
location / { | ||
root /usr/share/nginx/html; | ||
index index.html index.htm; | ||
} | ||
# Proxy pass the api location to save CORS | ||
# Use location exposed by Consul connect | ||
location /api { | ||
proxy_pass http://127.0.0.1:8080; | ||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection "Upgrade"; | ||
proxy_set_header Host $host; | ||
} | ||
error_page 500 502 503 504 /50x.html; | ||
location = /50x.html { | ||
root /usr/share/nginx/html; | ||
} | ||
} | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: frontend | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
service: frontend | ||
app: frontend | ||
template: | ||
metadata: | ||
labels: | ||
service: frontend | ||
app: frontend | ||
annotations: | ||
prometheus.io/scrape: "true" | ||
prometheus.io/port: "9102" | ||
consul.hashicorp.com/connect-inject: "true" | ||
consul.hashicorp.com/connect-service-upstreams: "public-api:8080" | ||
spec: | ||
serviceAccountName: frontend | ||
volumes: | ||
- name: config | ||
configMap: | ||
name: nginx-configmap | ||
items: | ||
- key: config | ||
path: default.conf | ||
containers: | ||
- name: frontend | ||
image: hashicorpdemoapp/frontend:v0.0.3 | ||
ports: | ||
- containerPort: 80 | ||
volumeMounts: | ||
- name: config | ||
mountPath: /etc/nginx/conf.d | ||
readOnly: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
--- | ||
# Service to expose web frontend | ||
|
||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: products-api-service | ||
spec: | ||
selector: | ||
app: products-api | ||
ports: | ||
- name: http | ||
protocol: TCP | ||
port: 9090 | ||
targetPort: 9090 | ||
|
||
--- | ||
|
||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: products-api | ||
automountServiceAccountToken: true | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: db-configmap | ||
data: | ||
config: | | ||
{ | ||
"db_connection": "host=postgres port=5432 user=postgres password=password dbname=products sslmode=disable", | ||
"bind_address": ":9090", | ||
"metrics_address": ":9103" | ||
} | ||
--- | ||
# Web frontend | ||
|
||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: products-api | ||
labels: | ||
app: products-api | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: products-api | ||
template: | ||
metadata: | ||
labels: | ||
app: products-api | ||
annotations: | ||
prometheus.io/scrape: "true" | ||
prometheus.io/port: "9102" | ||
consul.hashicorp.com/connect-inject: "true" | ||
consul.hashicorp.com/connect-service-upstreams: "postgres:5432" | ||
spec: | ||
serviceAccountName: products-api | ||
volumes: | ||
- name: config | ||
configMap: | ||
name: db-configmap | ||
items: | ||
- key: config | ||
path: conf.json | ||
containers: | ||
- name: products-api | ||
image: hashicorpdemoapp/product-api:v0.0.11 | ||
ports: | ||
- containerPort: 9090 | ||
- containerPort: 9103 | ||
env: | ||
- name: "CONFIG_FILE" | ||
value: "/config/conf.json" | ||
livenessProbe: | ||
httpGet: | ||
path: /health | ||
port: 9090 | ||
initialDelaySeconds: 15 | ||
timeoutSeconds: 1 | ||
periodSeconds: 10 | ||
failureThreshold: 30 | ||
volumeMounts: | ||
- name: config | ||
mountPath: /config | ||
readOnly: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: postgres | ||
labels: | ||
app: postgres | ||
spec: | ||
type: ClusterIP | ||
ports: | ||
- port: 5432 | ||
targetPort: 5432 | ||
selector: | ||
app: postgres | ||
|
||
--- | ||
|
||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: postgres | ||
automountServiceAccountToken: true | ||
|
||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: postgres | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
service: postgres | ||
app: postgres | ||
template: | ||
metadata: | ||
labels: | ||
service: postgres | ||
app: postgres | ||
annotations: | ||
prometheus.io/scrape: "true" | ||
prometheus.io/port: "9102" | ||
consul.hashicorp.com/connect-inject: "true" | ||
spec: | ||
serviceAccountName: postgres | ||
containers: | ||
- name: postgres | ||
image: hashicorpdemoapp/product-api-db:v0.0.11 | ||
ports: | ||
- containerPort: 5432 | ||
env: | ||
- name: POSTGRES_DB | ||
value: products | ||
- name: POSTGRES_USER | ||
value: postgres | ||
- name: POSTGRES_PASSWORD | ||
value: password | ||
volumeMounts: | ||
- mountPath: "/var/lib/postgresql/data" | ||
name: "pgdata" | ||
volumes: | ||
- name: pgdata | ||
emptyDir: {} |
Oops, something went wrong.