Skip to content

Instantly share code, notes, and snippets.

@viktortnk
Created June 20, 2018 07:52
Show Gist options
  • Save viktortnk/099b24db67e86d1d516a4da4191f2e78 to your computer and use it in GitHub Desktop.
Save viktortnk/099b24db67e86d1d516a4da4191f2e78 to your computer and use it in GitHub Desktop.
Example of k8s service with ingress
# service-with-ingress.yml
apiVersion: v1
kind: Service
metadata:
name: my-frontend
labels:
app: my-frontend
env: dev
spec:
type: NodePort
ports:
- port: 80
targetPort: service
protocol: TCP
name: http
selector:
app: my-frontend
env: dev
---
apiVersion: v1
kind: Service
metadata:
name: my-backend
labels:
app: my-backend
env: dev
spec:
type: NodePort
ports:
- port: 80
targetPort: service
protocol: TCP
name: http
selector:
app: my-backend
env: dev
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-ingress
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
tls:
- hosts:
- my-service.example.com
secretName: tls-secret
rules:
- host: my-service.example.com
http:
paths:
- path: /api
backend:
serviceName: my-backend
servicePort: http
- path: /
backend:
serviceName: my-frontend
servicePort: http
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment