Skip to content

Instantly share code, notes, and snippets.

@huksley
Created August 8, 2019 13:08
Show Gist options
  • Save huksley/3d67671e52da16093a98d5580f777e8b to your computer and use it in GitHub Desktop.
Save huksley/3d67671e52da16093a98d5580f777e8b to your computer and use it in GitHub Desktop.
# Deploy pods with Nginx container
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
selector:
matchLabels:
app: nginx
replicas: 2 # tells deployment to run 2 pods matching the template
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
# Define service using Pods labelled app=nginx
apiVersion: v1
kind: Service
metadata:
name: nginx-service
labels:
app: nginx
spec:
selector:
app: nginx
ports:
- protocol: TCP
port: 80
targetPort: 80
# Define ingress accepting connections on port 80 host nginx for service named nginx-service
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: nginx-ingress
spec:
rules:
- host: nginx
http:
paths:
- backend:
serviceName: nginx-service
servicePort: 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment