mirror of
https://github.com/google/nomulus
synced 2026-01-05 04:56:03 +00:00
k8s does not have a way to expose a global load balancer with TCP endpoints, and setting up node port-based routing is a chore, even with Terraform (which is what we did with the standalone proxy). We will use Cloud DNS's geolocation routing policy to ensure that clients connect to the endpoint closest to them.
120 lines
2.5 KiB
YAML
120 lines
2.5 KiB
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: frontend
|
|
spec:
|
|
selector:
|
|
matchLabels:
|
|
service: frontend
|
|
template:
|
|
metadata:
|
|
labels:
|
|
service: frontend
|
|
spec:
|
|
serviceAccountName: nomulus
|
|
containers:
|
|
- name: frontend
|
|
image: gcr.io/GCP_PROJECT/nomulus
|
|
ports:
|
|
- containerPort: 8080
|
|
name: http
|
|
resources:
|
|
requests:
|
|
cpu: "500m"
|
|
args: [ENVIRONMENT]
|
|
env:
|
|
- name: POD_ID
|
|
valueFrom:
|
|
fieldRef:
|
|
fieldPath: metadata.name
|
|
- name: NAMESPACE_ID
|
|
valueFrom:
|
|
fieldRef:
|
|
fieldPath: metadata.namespace
|
|
- name: CONTAINER_NAME
|
|
value: frontend
|
|
- name: EPP
|
|
image: gcr.io/GCP_PROJECT/proxy
|
|
ports:
|
|
- containerPort: 30002
|
|
name: epp
|
|
resources:
|
|
requests:
|
|
cpu: "500m"
|
|
args: [--env, PROXY_ENV, --log, --local]
|
|
env:
|
|
- name: POD_ID
|
|
valueFrom:
|
|
fieldRef:
|
|
fieldPath: metadata.name
|
|
- name: NAMESPACE_ID
|
|
valueFrom:
|
|
fieldRef:
|
|
fieldPath: metadata.namespace
|
|
- name: CONTAINER_NAME
|
|
value: EPP
|
|
---
|
|
# Only need to define the service account once per cluster.
|
|
apiVersion: v1
|
|
kind: ServiceAccount
|
|
metadata:
|
|
name: nomulus
|
|
annotations:
|
|
iam.gke.io/gcp-service-account: "nomulus-service-account@GCP_PROJECT.iam.gserviceaccount.com"
|
|
---
|
|
apiVersion: autoscaling/v2
|
|
kind: HorizontalPodAutoscaler
|
|
metadata:
|
|
name: frontend
|
|
spec:
|
|
scaleTargetRef:
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
name: frontend
|
|
minReplicas: 1
|
|
maxReplicas: 20
|
|
metrics:
|
|
- type: Resource
|
|
resource:
|
|
name: cpu
|
|
target:
|
|
type: Utilization
|
|
averageUtilization: 100
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: frontend
|
|
spec:
|
|
selector:
|
|
service: frontend
|
|
ports:
|
|
- port: 80
|
|
targetPort: http
|
|
name: http
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: EPP
|
|
annotations:
|
|
cloud.google.com/l4-rbs: enabled
|
|
networking.gke.io/weighted-load-balancing: pods-per-node
|
|
spec:
|
|
type: LoadBalancer
|
|
# Traffic is directly delivered to a node, preserving the original source IP.
|
|
externalTrafficPolicy: Local
|
|
ipFamilies: [IPv4, IPv6]
|
|
ipFamilyPolicy: RequireDualStack
|
|
selector:
|
|
service: frontend
|
|
ports:
|
|
- port: 700
|
|
targetPort: epp
|
|
name: epp
|
|
---
|
|
apiVersion: net.gke.io/v1
|
|
kind: ServiceExport
|
|
metadata:
|
|
name: frontend
|