<p>I have been using kubernetes for a while now.</p>

<pre><code>$ kubectl version                                                                                    
Client Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.0+2831379", GitCommit:"283137936a
498aed572ee22af6774b6fb6e9fd94", GitTreeState:"not a git tree", BuildDate:"2016-07-05T15:40:25Z", GoV
ersion:"go1.6.2", Compiler:"gc", Platform:"darwin/amd64"}                                            
Server Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.0", GitCommit:"5cb86ee022267586db
386f62781338b0483733b3", GitTreeState:"clean", BuildDate:"", GoVersion:"", Compiler:"", Platform:""} 
</code></pre>

<p>I usually set an Ingress, Service and Replication Controller for each project.</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  namespace: portifolio
  name: portifolio-ingress
spec:
  rules:
  - host: www.cescoferraro.xyz
    http:
      paths:
      - path: /
        backend:
          serviceName: portifolio
          servicePort: 80
---
apiVersion: v1
kind: Service
metadata:
  namespace: portifolio
  name: portifolio
  labels:
    name: portifolio
spec:
  selector:
    name: portifolio
  ports:
  - name: web
    port: 80
    targetPort: 80
    protocol: TCP

---
apiVersion: v1
kind: ReplicationController
metadata:
  namespace: portifolio
  name: portifolio
  labels:
    name: portifolio
spec:
  replicas: 1
  selector:
    name: portifolio
  template:
    metadata:
      namespace: portifolio
      labels:
        name: portifolio
    spec:
      containers:
        - image: cescoferraro/portifolio:latest
          imagePullPolicy: Always
          name: portifolio
          env:
          - name: KUBERNETES
            value: "true"
          - name: BRANCH
            value: "production"
</code></pre>

<p>My "problem" is that for deploying my app I usually do:</p>

<pre><code>kubectl -f delete kubernetes.yaml
kubectl -f create kubernetes.yaml
</code></pre>

<p>I wish I could use a single command to deploy, whenever my app is up or down. Rolling updates do not work when I use the same image,(I think its a bug on my kubernetes server version). But it also do not work when the app has never been deployed at all.</p>

<p>I have read about Deployments, I wonder how it would help me?</p>

<p><strong>Goals</strong>
 1. Deploy if app is brand new
 2. Replace existing pods with new ones using a new image from docker registry.</p>

<p>I don't think keeping all resources inside one single manifest helps you with what you want to achieve, since your Service, Ingress and ReplicationController are not likely to change simultaneously.</p>

<p>If all you want to do is roll out new pods, I would recommend you to replace your ReplicationController with a <strong>Deployment</strong>. Manifests have almost the exact same syntax so it's easy to migrate from standard RCs, and you could perform a server-side rolling update with a single <code>kubectl replace -f manifest.yml</code>.</p>

<p>Please note that even with a Deployment resource you can't trigger a redeployment if nothing changed in your manifest. <code>kubectl replace</code> would just do nothing. Therefore you could for example increment or change a tag inside your manifest in order to force the deployment, if needed (eg. <code>revision: 003</code>).</p>
