Nginx Ingress Controller in Docker for Windows
Docker for Windows is a great product which has build in Kubernetes
All magic with networking done by vpnkit which makes so you can localhost into your deployments, but how about ingress?
Here is a simple and easy way to get ingress up and running
First of all we gonna need to deploy ingress controller:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.0.4/deploy/static/provider/cloud/deploy.yaml
Quickstart and fresh versions are available here
Note: be sure to turn off IIS or any other software which might listen ports 80 and 443
To make life easier mark nginx
as default ingress class
kubectl patch ingressclass nginx --patch "{\"metadata\":{\"annotations\":{\"ingressclass.kubernetes.io/is-default-class\":\"true\"}}}"
And test whether it works:
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:alpine
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
type: ClusterIP
selector:
app: nginx
ports:
- protocol: TCP
port: 80
targetPort: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
labels:
app: nginx
name: nginx
spec:
rules:
- host: nginx.vcap.me
http:
paths:
- backend:
service:
name: nginx
port:
number: 80
path: /
pathType: ImplementationSpecific
Note
*.vcap.me
is a free wildcard dns which resolves to localhost, so you should be able to open nginx.vcap.me