Skip to content

Instantly share code, notes, and snippets.

@userbradley
Created October 6, 2022 11:17
Show Gist options
  • Save userbradley/bdf5b8b3d053c28d945f966ba32ec9ba to your computer and use it in GitHub Desktop.
Save userbradley/bdf5b8b3d053c28d945f966ba32ec9ba to your computer and use it in GitHub Desktop.
service attachment
## deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: psc-ilb
spec:
replicas: 3
selector:
matchLabels:
app: psc-ilb
template:
metadata:
labels:
app: psc-ilb
spec:
containers:
- name: whereami
image: us-docker.pkg.dev/google-samples/containers/gke/whereami:v1.2.8
ports:
- name: http
containerPort: 8080
readinessProbe:
httpGet:
path: /healthz
port: 8080
scheme: HTTP
initialDelaySeconds: 5
timeoutSeconds: 1
## service.yml
apiVersion: v1
kind: Service
metadata:
name: service-connect
annotations:
networking.gke.io/load-balancer-type: "Internal"
spec:
type: LoadBalancer
selector:
app: psc-ilb
ports:
- port: 80
targetPort: 8080
protocol: TCP
## Service-attachment.yml
apiVersion: networking.gke.io/v1
kind: ServiceAttachment
metadata:
name: whereami
namespace: default
spec:
connectionPreference: ACCEPT_AUTOMATIC
natSubnets:
- service-subnet-1
proxyProtocol: false
resourceRef:
kind: Service
name: service-connect
# This will error for a while, chillax.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment