Google Kubernetes Engine Python client Docker image.
This image is based on the official Python image and contains the Google Cloud SDK and the Kubernetes client.
$ docker pull motomotomato/python-gcloud-k8s-client
To run Python script, you can use CMD instruction in Dockerfile.
FROM motomotomato/python-gcloud-k8s-client
ENV CLUSTER_NAME=cluster-name
ENV REGION=region
ENV PROJECT_ID=project-id
COPY main.py .
CMD ["main.py"]
By default, this image uses automatically authentication with the Google Cloud SDK. If you want to use a service account, you can override ENTRYPOINT instruction in Dockerfile by entorypoint.sh script.
entrypoint.sh
#!/bin/bash
gcloud auth activate-service-account --key-file=service-account.json
gcloud container clusters get-credentials ${CLUSTER_NAME} --region ${REGION} --project ${PROJECT_ID}
python $@
By using docker-compose, you can use the service account file and environment variables.
docker-compose.yml
services:
python-gcloud-k8s-client:
image: motomotomato/python-gcloud-k8s-client
volumes:
- ./service-account.json:/service-account.json
- ./main.py:/main.py
- ./entrypoint.sh:/entrypoint.sh
environment:
GOOGLE_APPLICATION_CREDENTIALS: /service-account.json
CLUSTER_NAME: cluster-name
REGION: region
PROJECT_ID: project-id
command: /main.py
gcloud container | Google Cloud CLI Documentation
https://cloud.google.com/sdk/gcloud/reference/container
kubernetes-client/python: Official Python client library for kubernetes
https://github.com/kubernetes-client/python
Install kubectl and configure cluster access | Google Kubernetes Engine (GKE) | Google Cloud
https://cloud.google.com/kubernetes-engine/docs/how-to/cluster-access-for-kubectl
MIT License
Content type
Image
Digest
sha256:a1f7d0e3c…
Size
290.6 MB
Last updated
8 months ago
docker pull motomotomato/python-gcloud-k8s-client