Skip to content

Instantly share code, notes, and snippets.

@aojea
Last active September 18, 2020 10:31
Show Gist options
  • Select an option

  • Save aojea/ee37cc43f2513afbf5918c7ffddd807d to your computer and use it in GitHub Desktop.

Select an option

Save aojea/ee37cc43f2513afbf5918c7ffddd807d to your computer and use it in GitHub Desktop.
kubernetes deployment with hostnetwork and nodeport service
apiVersion: apps/v1
kind: Deployment
metadata:
name: hostnet-deployment
labels:
app: MyApp
spec:
replicas: 3
selector:
matchLabels:
app: MyApp
template:
metadata:
labels:
app: MyApp
spec:
hostNetwork: true
containers:
- name: agnhost
image: k8s.gcr.io/e2e-test-images/agnhost:2.21
args:
- netexec
- --http-port=8080
- --udp-port=8080
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: nodeport-service
spec:
type: NodePort
selector:
app: MyApp
ports:
- protocol: TCP
port: 80
targetPort: 8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment