apiVersion: v1
kind: Service
metadata:
name: mongo
labels:
run: mongo
spec:
ports:
– port: 27017
targetPort: 27017
protocol: TCP
selector:
run: mongo
—
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: mongo
spec:
template:
metadata:
labels:
run: mongo
spec:
containers:
– name: mongo
image: mongo
ports:
– containerPort: 27017
Try this:
apiVersion: v1
kind: Service
metadata:
labels:
run: mongo
name: mongo
spec:
ports:
- port: 27017
protocol: TCP
targetPort: 27017
selector:
run: mongo
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: mongo
name: mongo
spec:
replicas: 1
selector:
matchLabels:
run: mongo
template:
metadata:
labels:
run: mongo
spec:
containers:
- image: mongo
name: mongo
I generated it using:
kubectl run --image=mongo mongo --dry-run -o yaml
kubectl expose deployment mongo --port=27017 --dry-run -o yaml