cmd/gitmirror: use a Deployment instead of a ReplicationController

ReplicationControllers are hard to update. Deployments are the new shiny
and we should use those.

Change-Id: I4ea7b6a1a592466c7411ddf9c9ad462580152727
Reviewed-on: https://go-review.googlesource.com/c/build/+/328310
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
diff --git a/cmd/gitmirror/Makefile b/cmd/gitmirror/Makefile
index d1dcdaa..d4c33be 100644
--- a/cmd/gitmirror/Makefile
+++ b/cmd/gitmirror/Makefile
@@ -23,6 +23,7 @@
 	docker push $(IMAGE_STAGING):$(VERSION)
 
 deploy-prod: push-prod
-	kubectl rolling-update gitmirror-rc --image=$(IMAGE_PROD):$(VERSION)
+	kubectl set image deployment/gitmirror-deployment gitmirror=$(IMAGE_PROD):$(VERSION)
 deploy-staging: push-staging
-	kubectl rolling-update gitmirror-rc --image=$(IMAGE_STAGING):$(VERSION)
+	echo "no staging configuration"
+	exit 1
diff --git a/cmd/gitmirror/rc-prod.yaml b/cmd/gitmirror/deployment.yaml
similarity index 74%
rename from cmd/gitmirror/rc-prod.yaml
rename to cmd/gitmirror/deployment.yaml
index 562b2f6..0329070 100644
--- a/cmd/gitmirror/rc-prod.yaml
+++ b/cmd/gitmirror/deployment.yaml
@@ -1,19 +1,21 @@
-apiVersion: v1
-kind: ReplicationController
+apiVersion: apps/v1
+kind: Deployment
 metadata:
-  name: gitmirror-rc
+  name: gitmirror-deployment
+  labels:
+    app: gitmirror
 spec:
+  strategy:
+    rollingUpdate:
+      maxUnavailable: 1
   replicas: 2
   selector:
-    app: gitmirror
+    matchLabels:
+      app: gitmirror
   template:
     metadata:
-      name: gitmirror
       labels:
         app: gitmirror
-      annotations:
-        container.seccomp.security.alpha.kubernetes.io/gitmirror: docker/default
-        container.apparmor.security.beta.kubernetes.io/gitmirror: runtime/default
     spec:
       volumes:
       - name: cache-volume
@@ -39,3 +41,4 @@
           limits:
             cpu: "3"
             memory: "6Gi"
+
diff --git a/cmd/gitmirror/rc-staging.yaml b/cmd/gitmirror/rc-staging.yaml
deleted file mode 100644
index 7e79d7d..0000000
--- a/cmd/gitmirror/rc-staging.yaml
+++ /dev/null
@@ -1,41 +0,0 @@
-apiVersion: v1
-kind: ReplicationController
-metadata:
-  name: gitmirror-rc
-spec:
-  replicas: 2
-  selector:
-    app: gitmirror
-  template:
-    metadata:
-      name: gitmirror
-      labels:
-        app: gitmirror
-      annotations:
-        container.seccomp.security.alpha.kubernetes.io/gitmirror: docker/default
-        container.apparmor.security.beta.kubernetes.io/gitmirror: runtime/default
-    spec:
-      volumes:
-      - name: cache-volume
-        emptyDir:
-          medium: Memory
-      containers:
-      - name: gitmirror
-        image: gcr.io/go-dashboard-dev/gitmirror:latest
-        imagePullPolicy: Always
-        env:
-        - name: XDG_CACHE_HOME
-          value: "/cache"
-        command: ["/tini", "--", "/gitmirror", "-http=:8585", "-cachedir=/cache/gitmirror"]
-        volumeMounts:
-        - mountPath: /cache
-          name: cache-volume
-        ports:
-        - containerPort: 8585
-        resources:
-          requests:
-            cpu: "1"
-            memory: "2Gi"
-          limits:
-            cpu: "2"
-            memory: "4Gi"