Skip to content
This repository has been archived by the owner on Oct 3, 2020. It is now read-only.

Commit

Permalink
use from_env() in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hjacobs committed Sep 3, 2019
1 parent 0502a29 commit 46f2738
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Query for all ready pods in a custom namespace:
import operator
import pykube
api = pykube.HTTPClient(pykube.KubeConfig.from_file("~/.kube/config"))
api = pykube.HTTPClient(pykube.KubeConfig.from_file())
pods = pykube.Pod.objects(api).filter(namespace="gondor-system")
ready_pods = filter(operator.attrgetter("ready"), pods)
Expand Down
10 changes: 3 additions & 7 deletions docs/howtos/write-an-operator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@ Pykube can be used to implement Kubernetes Operators. Here is how to write a ver
import pykube, time
while True:
try:
# running in cluster
config = pykube.KubeConfig.from_service_account()
except FileNotFoundError:
# not running in cluster => load local ~/.kube/config for testing
config = pykube.KubeConfig.from_file()
# loads in-cluster auth or local ~/.kube/config for testing
config = pykube.KubeConfig.from_env()
api = pykube.HTTPClient(config)
for deploy in pykube.Deployment.objects(api, namespace=pykube.all):
if 'pykube-test-operator' in deploy.annotations:
Expand Down Expand Up @@ -51,7 +47,7 @@ Create a ``Dockerfile`` in the same directory as ``main.py``:

.. code-block:: Dockerfile
FROM python:3.7-alpine3.9
FROM python:3.7-alpine3.10
WORKDIR /
Expand Down

0 comments on commit 46f2738

Please sign in to comment.