# Deployment
apiVersion: apps/v1 
kind: Deployment 
metadata: 
 name: my-deployment 
spec: 
 replicas: 2 
 strategy: 
  type: Recreate 
 selector: 
  matchLabels: 
   app: my-app 
 template: 
   metadata: 
    labels: 
     app: my-app 
     env: prod 
   spec: 
    containers: 
    - name: my-deployment-container 
      image: nginx
---
# ClusterIP
apiVersion: v1
kind: Service
metadata:
 name: example-prod
spec:
 selector:
   app: my-app
   env: prod
 type: ClusterIP
 ports:
 - protocol: TCP
   port: 80
   targetPort: 8080
---
# NodePort
apiVersion: v1
kind: Service
metadata:
 name: example-prod
spec:
 type: NodePort
 selector:
   app: my-app
   env: prod
 ports:
 - nodePort: 32410
   protocol: TCP
   port: 80
   targetPort: 80
---
# ExternalName
apiVersion: v1
kind: Service
metadata:
 name: example-prod
spec:
 type: ExternalName
 externalName: example.com
---
# Headless
apiVersion: v1
kind: Service
metadata:
 name: app
spec:
 clusterIP: None
 selector:
   app: my-app
   env: prod
 ports:
 - protocol: TCP
   port: 80
   targetPort: 80
---
# LoadBalancer
apiVersion: v1
kind: Service
metadata:
 name: example-prod
spec:
 type: LoadBalancer
 selector:
  app: my-app
  env: prod
 ports:
 - protocol: TCP
   port: 80
   targetPort: 80
