<p>I am very new to azure kubernetes! Right now I am just playing around with it, trying to work out how to create things using kubectl.
I already have my cluster set up, and I have created a couple of pods using an existing container in our registry. I also created an ingress controller using azure application gateway.</p>
<p>What I want to do next is use a deployment yaml file to add a new replicated set of pods to the cluster, with a different image in there, and add the new service endpoint to the ingress controller. Remember, I am very new to this, so I am not sure if this is what you should do, or if you should create the pods/service first and then change the ingress controller?
Or if you should have a separate deployment yaml for the ingress and recreate it on its own?</p>
<p>Anyway, here is the deployment yaml file that I have. When I try and run it with :</p>
<pre><code>kubectl apply -f deployment.yml
</code></pre>
<p>I just get the error :</p>
<pre><code>error: error validating &quot;deployment.yml&quot;: error validating data: invalid object to validate; if you choose to ignore these errors, turn validation off with --validate=false
</code></pre>
<p>So I guess my question is, am I doing this right? And if this is the way I should be adding to my cluster, any idea what is wrong with this yaml?</p>
<pre><code>---
  apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: new-kuber-endpoint
    namespace: kuber-ut
  spec:
    replicas: 2
    selector:
      matchLabels:
        app: new-kuber-endpoint
    template:
      metadata:
        labels:
          app: new-kuber-endpoint
      spec:
        nodeSelector:
          kubernetes.io/os: linux
        containers:
          - name: amica-endpoint
            image: mycontainerreg.azurecr.io/new-endpoint:20220707.1
            ports:
              - containerPort: 80
            resources:
              requests:
                cpu: '0'
                memory: '0'
              limits:
                cpu: '256'
                memory: 11400G
---
  apiVersion: v1
  kind: Service
  metadata:
    name: new-kuber-endpoint-service
    namespace: kuber-ut
  spec:
    type: LoadBalancer
    ports:
      - targetPort: 80
        name: port80
        port: 80
        protocol: TCP
    selector:
      app: new-kuber-endpoint
---
  apiVersion: networking.k8s.io/v1
  kind: Ingress
  metadata:
    name: kuberdevingress
    namespace: kuber-ut
    uid: d9d490f0-1d3a-4433-bb03-7f1ba0dc611f
    resourceVersion: '1490171'
    generation: 3
  spec:
    rules:
      - http:
          paths:
            - path: /old
              pathType: Prefix
              backend:
                service:
                  name: old-endpoint-service
                  port:
                    number: 80
            - path: /new
              pathType: Prefix
              backend:
                service:
                  name: new-kuber-endpoint-service
                  port:
                    number: 80
  status:
    loadBalancer:
      ingress:
        - ip: &lt;IP goes here&gt;
</code></pre>
<p>I copied the kuberdevingress section from the azure portal, so I am not confident that is how I would recreate that ingress?</p>

evolmonster
<p>You can use the single YAML file and manage it as per the requirement of creating multiple files for different resources that are on you.</p>
<p>If you want to update the deployment you can simply update the YAML and run</p>
<pre><code>kubectl apply -f &lt;filename&gt;.yaml 
</code></pre>
<p>Also, there is an issue with your YAML, you can separate the resource using the <code>---</code> in YAML if you don't manage the three different files for deployment, service, and ingress</p>
<pre><code>  apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: new-kuber-endpoint
    namespace: kuber-test
  spec:
    replicas: 2
    selector:
      matchLabels:
        app: new-kuber-endpoint
    template:
      metadata:
        labels:
          app: new-kuber-endpoint
      spec:
        nodeSelector:
          kubernetes.io/os: linux
        containers:
          - name: new-endpoint
            image: mycontainerregistry.azurecr.io/new-endpoint:20220707.1
            ports:
              - containerPort: 80
            resources:
              requests:
                cpu: '0'
                memory: '0'
              limits:
                cpu: '256'
                memory: 11400G
---
  apiVersion: v1
  kind: Service
  metadata:
    name: new-kuber-endpoint-service
    namespace: kuber-test
  spec:
    type: LoadBalancer
    ports:
      - targetPort: 80
        name: port80
        port: 80
        protocol: TCP
    selector:
      app: new-kuber-endpoint
---
  apiVersion: v1
  kind: Ingress
  metadata:
    name: kuberdevingress
    namespace: kuber-test
    annotations:
      kubernetes.io/ingress.class: azure/application-gateway
  spec:
    rules:
      - http:
          paths:
            - path: /
              pathType: Prefix
              backend:
                service:
                  name: old-endpoint-service
                  port:
                    number: 80
            - path: /
              pathType: Prefix
              backend:
                service:
                  name: new-endpoint-service
                  port:
                    number: 80
</code></pre>
<p>You can now update any field in the above YAML and re-apply the changes again to the Kubernetes cluster, it will update the changes.</p>
<p>If it's in service it will update that, if it's in ingress it will update those changes accordingly.</p>
<p>If you want to change the docker image you can update the deployment image with a different docker tag it will fetch and deploy that version.</p>
