Skip to content

Instantly share code, notes, and snippets.

@lastcoolnameleft
Last active June 11, 2020 14:19
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 lastcoolnameleft/4498ea9582561ab8c0c3cc991f8480de to your computer and use it in GitHub Desktop.
Save lastcoolnameleft/4498ea9582561ab8c0c3cc991f8480de to your computer and use it in GitHub Desktop.
Combining APIM + AKS
## Overview
There are 3 options listed here: https://docs.microsoft.com/en-us/azure/api-management/api-management-kubernetes
* APIM + Public AKS Service, no shared Vnet
* APIM + Public AKS Ingress, no shared Vnet
* APIM + Private AKS in same Vnet, no ingress
A missing scenario is:
* APIM + Private AKS in same Subnet, with ingress
To make this work:
* Create APIM instance
* Create Blank API
* API URL suffix:
* e.g. dev-pod-info
* Web service: http://<IP of Ingress>/<same value as API URL Suffix>
* e.g. https://tmfflux.azure-api.net/dev-pod-info
Create ingress similiar to template below
* The /$2 is important to remove the "dev-pod-info" path as it comes through since your app is likely not expecting it.
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
# the /$2 is to remove the
nginx.ingress.kubernetes.io/rewrite-target: /$2
name: podinfo-ingress
namespace: demo
spec:
rules:
- http:
paths:
- backend:
serviceName: podinfo
servicePort: 9898
path: /dev-pod-info
- http:
paths:
- backend:
serviceName: podinfo
servicePort: 9898
path: /prod-pod-info
# Assumes ingress controller is already running
# Make sure to replace IP of Ingress Controller Service
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: kuard
spec:
replicas: 1
template:
metadata:
labels:
app: kuard
spec:
containers:
- name: kuard
image: gcr.io/kuar-demo/kuard-amd64:1
ports:
- containerPort: 8080
name: http
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
name: kuard
labels:
name: kuard
spec:
type: ClusterIP
ports:
- port: 80
targetPort: 8080
protocol: TCP
selector:
app: kuard
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: kuard
spec:
rules:
- host: kuard.<IP of Ingress Controller Service>.nip.io
http:
paths:
- path: /
backend:
serviceName: kuard
servicePort: 80
# Assumes ingress controller is already running
# Make sure to replace IP of Ingress Controller Service
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: podinfo
labels:
app: podinfo
spec:
selector:
matchLabels:
app: podinfo
template:
metadata:
labels:
app: podinfo
spec:
containers:
- name: podinfod
image: stefanprodan/podinfo:3.1.5
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 9898
protocol: TCP
- name: http-metrics
containerPort: 9797
protocol: TCP
- name: grpc
containerPort: 9999
protocol: TCP
command:
- ./podinfo
- --port=9898
- --port-metrics=9797
- --grpc-port=9999
- --grpc-service-name=podinfo
- --level=info
- --random-delay=false
- --random-error=false
- --random-error=false
- --ui-message='Service #1'
env:
- name: PODINFO_UI_COLOR
value: "#34577c"
---
apiVersion: v1
kind: Service
metadata:
name: podinfo
labels:
app: podinfo
spec:
type: ClusterIP
selector:
app: podinfo
ports:
- name: http
port: 9898
protocol: TCP
targetPort: http
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: podinfo
spec:
rules:
- host: podinfo.<IP of Ingress Controller Service>.nip.io
http:
paths:
- path: /
backend:
serviceName: podinfo
servicePort: 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment