Skip to content

Instantly share code, notes, and snippets.

@andymotta
Last active April 24, 2020 01:01
Show Gist options
  • Save andymotta/b33e34582430db92adc626422d97759f to your computer and use it in GitHub Desktop.
Save andymotta/b33e34582430db92adc626422d97759f to your computer and use it in GitHub Desktop.
Kubernetes: Deploy Microservices under the nginx-ingress controller
apiVersion: v1
kind: Service
metadata:
name: product-web
spec:
type: ClusterIP
selector:
app: product-web
ports:
- protocol: TCP
port: 8000
targetPort: 8000
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: product-web
labels:
app: product-web
spec:
replicas: 2
selector:
matchLabels:
app: product-web
template:
metadata:
labels:
app: product-web
spec:
containers:
- name: product-web
image: andylukem/product-web
env:
- name: ENDPOINT
value: "internal-xxxxxxxxxxxxxxxxxxx-000000000.us-west-2.elb.amazonaws.com"
---
apiVersion: v1
kind: Service
metadata:
name: products
spec:
type: ClusterIP
selector:
app: products
ports:
- protocol: TCP
port: 8001
targetPort: 8001
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: products
labels:
app: products
spec:
replicas: 2
selector:
matchLabels:
app: products
template:
metadata:
labels:
app: products
spec:
containers:
- name: products
image: andylukem/products
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-ingress
annotations: {}
# kubernetes.io/ingress.class: nginx
spec:
rules:
- host: internal-xxxxxxxxxxxxxxxxxxx-000000000.us-west-2.elb.amazonaws.com
http:
paths:
- path: /
backend:
serviceName: product-web
servicePort: 8000
- path: /products
backend:
serviceName: products
servicePort: 8001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment