freshpod

command module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2018 License: Apache-2.0 Imports: 20 Imported by: 0

README

freshpod

freshpod automatically restarts Pods when the image they use is rebuilt or updated. It’s suitable for single-instance Kubernetes clusters, such as Minikube.

A command line demo of freshpod replacing pods when the image is updated

It works by listening to docker-engine image tag events, and deletes the Pods running an updated image. It assumes that the deleted Pods will be replaced with new ones. Therefore you should use a high-level controller such as Deployment, and not use Pods directly in your manifests.

Try it out

Deploy to your Minikube cluster with provided manifest file:

minikube start
kubectl apply -Rf ./yaml/install

Check the Pod is running:

$ kubectl get pods -n kube-system
NAME                          READY     STATUS    RESTARTS   AGE
freshpod-5cbb9955cb-tcvmb     1/1       Running   0          20s

Verify it connected to Docker and Kubernetes APIs.

$ kubectl logs -n kube-system freshpod-5cbb9955cb-tcvmb
2017/11/29 22:33:26 connected kubernetes apiserver (v1.8.0)
2017/11/29 22:33:26 connected docker api (api: v1.30, version: 17.06.0-ce)
2017/11/29 22:33:26 [TRACK] pod default/hello-5766f88f9c-d5rqf
2017/11/29 22:33:26 [TRACK] pod default/hello-5766f88f9c-67lgz
...

See it in action

Get some test images and tag 1.0 image as hello:latest:

eval $(minikube docker-env)
docker pull gcr.io/google-samples/hello-app:1.0
docker pull gcr.io/google-samples/hello-app:2.0
docker tag  gcr.io/google-samples/hello-app:1.0 hello:latest

Run a 2-replica Deployment and NodePort Service with hello:latest image:

kubectl run hello --image=hello --port 8080 --replicas=2 \
  --image-pull-policy=IfNotPresent

kubectl expose deploy/hello --type=NodePort

Visit the app (note the 1.0.0):

$ URL=$(minikube service hello --url)
$ curl "$URL"
Hello, world!
Version: 1.0.0
Hostname: hello-5766f88f9c-67lgz

Re-tag the hello:latest image with the 2.0 version:

docker tag gcr.io/google-samples/hello-app:2.0 hello

Visit the app again (note the 2.0.0):

$ curl "$URL"
Hello, world!
Version: 2.0.0
Hostname: hello-5766f88f9c-h88df
Contributing

See CONTRIBUTING.md for more information.


This is not an official Google product.

Documentation

Overview

Copyright 2017 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2017 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2017 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2017 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL