<p>This is my kubernetes.yml</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: servicetwo
  labels:
    name: servicetwo
  namespace: sock-shop
spec:
  replicas: 1
  template:
    metadata:
      labels:
        name: servicetwo
    spec:
      containers:
      - name: servicetwo
        image: nik/pythonserviceone
        ports:
         - containerPort: 5000
        
---
apiVersion: v1
kind: Service
metadata:
  name: servicetwo
  labels:
    name: servicetwo
  namespace: sock-shop
spec:
  ports:
    # the port that this service should serve on
  - port: 5000
    targetPort: 5000
    nodePort: 30003
  selector:
    name: servicetwo
  type: NodePort  
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: servicethree
  labels:
    name: servicethree
  namespace: sock-shop
spec:
  replicas: 1
  template:
    metadata:
      labels:
        name: servicethree
    spec:
      containers:
      - name: servicetwo
        image: nik/pythonservicetwo
        ports:
         - containerPort: 7000
---
apiVersion: v1
kind: Service
metadata:
  name: servicethree
  labels:
    name: servicethree
  namespace: sock-shop
spec:
  ports:
    # the port that this service should serve on
  - port: 7000
    targetPort: 7000
    nodePort: 30002
  selector:
    name: servicethree
  type: NodePort 
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: apigateway
  labels:
    name: apigateway
  namespace: sock-shop
spec:
  replicas: 1
  template:
    metadata:
      labels:
        name: apigateway
    spec:
      containers:
      - name:  apigateway
        image: ni/aggregatornew
        ports:
        - containerPort: 9000
        
---
apiVersion: v1
kind: Service
metadata:
  name:  apigateway
  labels:
    name:  apigateway
  namespace: sock-shop
spec:
  type: NodePort
  ports:
  - port: 9000
    targetPort: 9000
    nodePort: 30001
  selector:
    name: apigateway
---
</code></pre>
<p>I know this error is because of new version of kubernetes ,but I am unable to fix the issue ,when I change extensions/v1beta1 to apps/v1 I start getting error servicetwo not found while running <code>kubectl apply -f kubernets.yml</code>.With kuberentes 1.10 its running perfectly ,any help would be really appreciated thanks</p>

<p>In addition to change to <code>apps/v1</code> you also need to add the <strong>new required field</strong> <code>selector:</code> in the <code>spec:</code></p>
<p>something like this should work for you:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: servicetwo
  labels:
    name: servicetwo
  namespace: sock-shop
spec:
  replicas: 1
  selector:               // new required field
    matchLabels:
      name: servicetwo     // must match your labels
  template:
    metadata:
      labels:
        name: servicetwo
    spec:
      containers:
      - name: servicetwo
        image: nik/pythonserviceone
        ports:
         - containerPort: 5000
</code></pre>
