https://github.com/ericchiang/kube-rollback-controller
Example Kubernetes controller
https://github.com/ericchiang/kube-rollback-controller
Last synced: 3 months ago
JSON representation
Example Kubernetes controller
- Host: GitHub
- URL: https://github.com/ericchiang/kube-rollback-controller
- Owner: ericchiang
- License: mit
- Created: 2017-02-16T08:45:04.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-16T20:33:21.000Z (over 9 years ago)
- Last Synced: 2025-01-25T07:24:07.668Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 1.33 MB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Auto Rollback Controller
A Kubernetes controller example
In v1.5 Kubernetes added a new field to the `Deployments` spec, [`progressDeadlineSeconds`][rollback-config]. As of `v1.5` a `Deployment` will be marked as failed if it fails to make progress within the allotted time. However, it won't automatically roll back.
This means the following deployment:
```
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: hello
spec:
progressDeadlineSeconds: 5
replicas: 3
template:
metadata:
labels:
app: hello
spec:
containers:
- name: hello
image: alpine:3.5
command:
- /bin/sh
- -c
- "while :; do echo 'Goodbye'; exit 1; sleep 1; done"
```
doesn't roll back in v1.5.
The `kube-rollback-controller` loops, looking for failed deployments, then automatically does this rollback.
## Example
In one terminal, start the rollback controller:
```
$ go get github.com/ericchiang/kube-rollback-controller
$ kube-rollback-controller --client=kubectl
```
In another create a deployment, then roll to a bad version of the deployment:
```
$ kubectl create -f examples/good.yaml
$ # Wait a bit for the deployment to succeed...
$ kubectl replace -f examples/bad.yaml
```
The second deployment should roll back to the first.
[rollback-config]: https://github.com/kubernetes/kubernetes/blob/v1.5.0/pkg/apis/extensions/v1beta1/types.go#L292-L303