Skip to content

Instantly share code, notes, and snippets.

@devops-school
Created April 7, 2024 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devops-school/8f319ee1e52bbc1431daec9c5a2a70ee to your computer and use it in GitHub Desktop.
Save devops-school/8f319ee1e52bbc1431daec9c5a2a70ee to your computer and use it in GitHub Desktop.
Example Deployment YAML for Multi-cluster Ingress with FrontendConfig and BackendConfig
# Application Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-app
namespace: default
spec:
replicas: 2
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: nginx
ports:
- containerPort: 80
---
# Cluster-local Service
apiVersion: v1
kind: Service
metadata:
name: web-service
namespace: default
spec:
selector:
app: web
ports:
- protocol: TCP
port: 80
targetPort: 80
---
# MultiClusterService for cross-cluster service discovery
apiVersion: networking.gke.io/v1
kind: MultiClusterService
metadata:
name: web-mcs
namespace: default
spec:
template:
spec:
selector:
app: web
ports:
- name: http
protocol: TCP
port: 80
targetPort: 80
clusters:
- linkName: cluster1
- linkName: cluster2
---
# MultiClusterIngress to expose the MultiClusterService externally
apiVersion: networking.gke.io/v1
kind: MultiClusterIngress
metadata:
name: web-mci
namespace: default
spec:
template:
spec:
frontendConfig:
name: web-frontendconfig
rules:
- host: web.example.com
http:
paths:
- path: /*
pathType: ImplementationSpecific
backend:
service:
name: web-mcs
port:
number: 80
---
# FrontendConfig for custom frontend settings
apiVersion: networking.gke.io/v1beta1
kind: FrontendConfig
metadata:
name: web-frontendconfig
namespace: default
spec:
sslPolicy: custom-ssl-policy
redirectToHttps:
enabled: true
---
# BackendConfig for custom backend settings
apiVersion: cloud.google.com/v1
kind: BackendConfig
metadata:
name: web-backendconfig
namespace: default
spec:
healthCheck:
checkIntervalSec: 30
timeoutSec: 5
healthyThreshold: 2
unhealthyThreshold: 3
requestPath: /healthz
sessionAffinity:
affinityType: CLIENT_IP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment