Skip to content

Instantly share code, notes, and snippets.

@gbrayut
Created September 29, 2025 22:27
Show Gist options
  • Select an option

  • Save gbrayut/d329e541f50bec6a87de8c22eb2df97a to your computer and use it in GitHub Desktop.

Select an option

Save gbrayut/d329e541f50bec6a87de8c22eb2df97a to your computer and use it in GitHub Desktop.
ServiceDirectoryRegistrationPolicy.yaml
apiVersion: networking.gke.io/v1alpha1
kind: ServiceDirectoryRegistrationPolicy
metadata:
# Only the name "default" is allowed.
name: default
# The ServiceDirectoryRegistrationPolicy is a namespaced resource
namespace: app-1
spec:
resources:
# Kind specifies the types of Kubernetes resources that can be synced into Service Directory.
- kind: Service
# Selector is a label selector for the resource types specified in Kind.
selector:
matchLabels:
sd-import: "true"
# annotationsToSync specifies the annotations that are matched and imported.
# Any annotations that do not match this set of keys will not be imported into Service Directory.
annotationsToSync:
- networking.gke.io/load-balancer-type
---
# or for existing use: kubectl label -n app-1 service whereami sd-import="true"
apiVersion: "v1"
kind: "Service"
metadata:
name: "whereami"
namespace: app-1
annotations:
networking.gke.io/load-balancer-type: Internal
labels:
sd-import: "true"
spec:
ports:
- port: 80
targetPort: 8080
appProtocol: http
name: http
selector:
app: "whereami"
type: "LoadBalancer"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment