Kubectl create deplpoyment and service at same time

Kubectl create deplpoyment and service at same time

Simply add entries for both the deployment and the service in the same manifest, separeted by ---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: helloserver
spec:
  replicas: 1
  selector:
    matchLabels:
      app: helloserver
  template:
    metadata:
      labels:
        app: helloserver
    spec:
      containers:
      - name: helloserver
        image: 192.168.1.2:5000/helloserver:latest
        ports:
        - containerPort: 3333
---
apiVersion: v1
kind: Service
metadata:
  labels:
    run: helloserver
  name: helloserver
spec:
  ports:
  - port: 3333
    nodePort: 33333
  selector:
    app: helloserver
  type: LoadBalancer