Created
May 11, 2020 09:42
-
-
Save alexeldeib/c65b8bacdbdd7df723b6ccba696c2ffc to your computer and use it in GitHub Desktop.
Cross-namespace Ingress via External Name
This file contains hidden or 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
--- | |
# Deployment to serve backend requests | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: healthz | |
namespace: default | |
labels: | |
app: healthz | |
spec: | |
replicas: 5 | |
selector: | |
matchLabels: | |
app: healthz | |
template: | |
metadata: | |
labels: | |
app: healthz | |
spec: | |
containers: | |
- name: healthz | |
image: server:latest | |
ports: | |
- containerPort: 80 | |
readinessProbe: | |
httpGet: | |
path: /healthz | |
port: 80 | |
initialDelaySeconds: 1 | |
periodSeconds: 5 | |
livenessProbe: | |
httpGet: | |
path: /livez | |
port: 80 | |
initialDelaySeconds: 1 | |
periodSeconds: 5 | |
--- | |
# Real service accepting requests in default namespace | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: healthz-svc | |
namespace: default | |
spec: | |
ports: | |
- port: 80 | |
targetPort: 80 | |
protocol: TCP | |
selector: | |
app: healthz | |
--- | |
# Dummy service in same namespace as ingress object | |
# Redirects to "real" service in some other namespace | |
# Required because cross-ns references are not possible for ingress | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: healthcheck | |
namespace: external | |
spec: | |
type: ExternalName | |
externalName: healthz-svc.healthz.svc.cluster.local | |
ports: | |
- protocol: TCP | |
port: 80 | |
targetPort: 80 | |
clusterIP: "" | |
--- | |
# External facing ingress object | |
apiVersion: networking.k8s.io/v1beta1 | |
kind: Ingress | |
metadata: | |
name: healthz | |
namespace: external | |
annotations: | |
kubernetes.io/ingress.class: external | |
nginx.ingress.kubernetes.io/ssl-redirect: "false" | |
spec: | |
rules: | |
- host: "*.cloudapp.azure.com" | |
http: &health | |
paths: | |
- path: /healthz | |
backend: | |
serviceName: healthz | |
servicePort: 80 | |
- host: "*.trafficmanager.net" | |
http: *health | |
--- | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment