Skip to content

Instantly share code, notes, and snippets.

@ryancurrah
Created February 11, 2021 21:28
Show Gist options
  • Save ryancurrah/50eb99aa9d19663764434d5c890e90d4 to your computer and use it in GitHub Desktop.
Save ryancurrah/50eb99aa9d19663764434d5c890e90d4 to your computer and use it in GitHub Desktop.
MetalLB and Nginx Ingress Example
---
apiVersion: v1
kind: Service
metadata:
name: ingress
namespace: ingress
spec:
selector:
name: nginx-ingress-microk8s
type: LoadBalancer
# loadBalancerIP is optional. MetalLB will automatically allocate an IP from its pool if not
# specified. You can also specify one manually.
# loadBalancerIP: x.y.z.a
ports:
- name: http
protocol: TCP
port: 80
targetPort: 80
- name: https
protocol: TCP
port: 443
targetPort: 443
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- host: hello.info
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: hello-service
port:
number: 8080
---
kind: Pod
apiVersion: v1
metadata:
name: hello-app
labels:
app: hello
spec:
containers:
- name: hello
image: ryancurrah/hello
---
kind: Service
apiVersion: v1
metadata:
name: hello-service
spec:
selector:
app: hello
ports:
- port: 8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment