<p>I recently started learning <code>kubernetes</code>. Many blog posts use the terms <code>objects</code> and <code>resources</code> kind of interchangably(I cannot make out the difference from the context). </p>

<p>Also, the <code>controllers</code> are described to manage some specific object(e.g. responding to <code>create/delete/update events</code> corresponding to that object). So, are the controllers just another <em>object intended to manage some other object</em> or a completely different construct?</p>

<p>Any Explanation is appreciated. Thanks :)</p>

Arpit Bhadauria
<p>I agree that many people using object and resources interchangeably.</p>

<p><strong>Kubernetes Resources</strong> </p>

<p>If you are talking about <code>Kubernetes resources</code> you are talking about general collection of everything you can use/create inside Kubernetes (<code>Services</code>, <code>Pods</code>, <code>Deployments</code>, <code>events</code>, <code>quotas</code>, etc).
You can type in your cluster to check list of resources using in Kubernetes:</p>

<pre><code>$ kubectl api-resources
NAME                              SHORTNAMES   APIGROUP                       NAMESPACED   KIND
bindings                                                                      true         Binding
componentstatuses                 cs                                          false        ComponentStatus
configmaps                        cm                                          true         ConfigMap
endpoints                         ep                                          true         Endpoints
events                            ev                                          true         Event
limitranges                       limits                                      true         LimitRange
namespaces                        ns                                          false        Namespace
nodes                             no                                          false        Node
persistentvolumeclaims            pvc                                         true         PersistentVolumeClaim
...
</code></pre>

<p>and much more, but there is no point to post them all.</p>

<p>Each <code>Kubernetes</code> object need proper specification. More details can be found <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/kubernetes-objects/#describing-a-kubernetes-object" rel="nofollow noreferrer">here</a>. </p>

<p>This specification is usualy created in <code>YAML</code> or <code>JSON</code> format. Kubernetes object <strong>must have</strong> sepcified <code>apiVersion</code>, <code>Kind</code>, <code>metadata</code> and <code>spec</code>. You should also keep in mind that YAML and JSON have their own Syntax. If all requirements are met, <code>Kubernetes</code> will create <code>object</code>.</p>

<p><strong>Kubernetes Object</strong> is Kubernetes resource but with special <code>spec</code> and <code>status</code>. Please check <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/kubernetes-objects/#object-spec-and-status" rel="nofollow noreferrer">this docs</a></p>

<blockquote>
  <p>Every Kubernetes object includes two nested object fields that govern the object’s configuration: the object spec and the object status. The spec, which you must provide, describes your desired state for the object–the characteristics that you want the object to have. The status describes the actual state of the object, and is supplied and updated by the Kubernetes system. At any given time, the Kubernetes Control Plane actively manages an object’s actual state to match the desired state you supplied.</p>
</blockquote>

<p>If you will have for example 3 deployments.</p>

<pre><code>$ kubectl get deploy
NAME         READY   UP-TO-DATE   AVAILABLE   AGE
httpd        1/1     1            1           114s
nginx-test   1/1     1            1           90s
ngxin        1/1     1            1           3m46s
</code></pre>

<p><code>nginx</code> is an one object as it have defined object <code>spec</code> and object <code>status</code>. <code>nginx-test</code> is also object but with different <code>spec</code> and <code>status</code>. It will be more visible if you will check deployment in yaml format.</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
  creationTimestamp: "2020-01-28T15:21:18Z"
  generation: 1
  labels:
    run: ngxin
  name: ngxin
  namespace: default
  resourceVersion: "11169617"
  selfLink: /apis/extensions/v1beta1/namespaces/default/deployments/ngxin
  uid: d51d4dd8-41e1-11ea-bfb3-42010aa40078
spec:                                                    ########### Here you have spec of this deployment - first requirement
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      run: ngxin
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        run: ngxin
    spec:                                                 #### this is container spec, its specific for deployment 
      containers:
      - image: nginx
        imagePullPolicy: Always
        name: ngxin
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
status:                                                      ########### Status of deployment - second requirement
  availableReplicas: 1
  conditions:
  - lastTransitionTime: "2020-01-28T15:21:20Z"
    lastUpdateTime: "2020-01-28T15:21:20Z"
    message: Deployment has minimum availability.
    reason: MinimumReplicasAvailable
    status: "True"
    type: Available
  - lastTransitionTime: "2020-01-28T15:21:18Z"
    lastUpdateTime: "2020-01-28T15:21:20Z"
    message: ReplicaSet "ngxin-6b9746db7f" has successfully progressed.
    reason: NewReplicaSetAvailable
    status: "True"
    type: Progressing
  observedGeneration: 1
  readyReplicas: 1
  replicas: 1
  updatedReplicas: 1
</code></pre>

<p>In short, <code>Kubernetes resource</code> is collection of everything that can be created/use in Cluster. <code>Kubernetes object</code> is <code>Kubernetes resource</code> but with special specification and status which allows to determine/distinguish from other resources.</p>

<p><strong>Kubernetes controller</strong></p>

<p>As per <a href="https://kubernetes.io/docs/concepts/architecture/controller/" rel="nofollow noreferrer">docs</a></p>

<blockquote>
  <p>In Kubernetes, controllers are control loops that watch the state of your cluster, then make or request changes where needed. Each controller tries to move the current cluster state closer to the desired state.</p>
</blockquote>

<p>As you mentioned, controllers monitoring specific resource. For example form <a href="https://www.stratoscale.com/blog/kubernetes/kubernetes-way-pod-controller-label/" rel="nofollow noreferrer">this artice</a>.</p>

<p><strong>Deployment Controller</strong></p>

<blockquote>
  <p>A deployment defines a desired state for logical group of pods and
  replica sets. It creates new resources or replaces the existing
  resources, if necessary. A deployment can be updated, rolled out, or
  rolled back. A practical use case for a deployment is to bring up a
  replica set and pods, then update the deployment to re-create the pods
  (for example, to use a new image). Later, the deployment can be rolled
  back to an earlier revision if the current deployment is not stable.</p>
</blockquote>

<p>Hope it will help.</p>
